一个python助手库,用于报告度量并与polyaxon通信。
polyaxon-helper的Python项目详细描述
Polyaxon助手
polyaxon helper是一个轻量级的python库,用于报告度量并与polyaxon通信信息。
安装
$ pip install -U polyaxon-helper
对于Python3
$ pip3 install -U polyaxon-helper
安装Polyaxon
请检查polyaxon installation guide
安装在polyaxonfile中
如果要在生成过程中将安装委托给Polyaxon,
在polyaxonfile中的run
部分添加新步骤:
...build:image:...build_steps:-...-pip install -U polyaxon-helper-...run:cmd:...
用法
获取polyaxon定义的env变量
frompolyaxon_helperimport(get_cluster_def,get_declarations,get_experiment_info,get_task_info,get_tf_config,get_job_info,get_outputs_path,get_outputs_refs_paths,get_data_paths,get_log_level)cluster_def=get_cluster_def()declarations=get_declarations()experiment_info=get_experiment_info()task_info=get_task_info()job_info=get_job_info()outputs_path=get_outputs_path()outputs_refs_paths=get_outputs_refs_paths()data_paths=get_data_paths()tf_config=get_tf_config()log_level=get_log_level()
get_cluster_def
:返回polyaxon创建的集群定义。{"master":["plxjob-master0-8eefb7a1146f476ca66e3bee9b88c1de:2000"],"worker":["plxjob-worker1-8eefb7a1146f476ca66e3bee9b88c1de:2000","plxjob-worker2-8eefb7a1146f476ca66e3bee9b88c1de:2000"],"ps":["plxjob-ps3-8eefb7a1146f476ca66e3bee9b88c1de:2000"],}
get_declarations
:返回基于两者的所有实验声明,- 声明部分
- 矩阵部分
get_tf_config
:返回定义集群和当前任务的tfu配置。 如果envvar
不为空,它将使用envvar
设置和环境变量。get_experiment_info
:返回有关实验的信息。- 项目名称
- 实验组名称
- 实验名称
- 项目编号
- 实验组
- 实验
get_job_info
:返回有关作业的信息。- 项目名称
- 工作名称
- 项目编号
- 作业ID
get_task_info
:返回任务信息:{"type": str, "index": int}
。outputs_path
:polyaxon基于实验层次结构生成的输出路径。`user/project/group/experiment/files`
data_paths
:为作业/实验装载的数据路径:{ 'data1': '/data/1', 'data-foo': '/data/foo', }
outputs_path
:引用输出用户请求的路径, 顺序遵循用户指定的顺序:{ 'experiments': [ `user/project/job12/files`, ], 'experiments': [ `user/project/group/experiment1/files`, `user/project/experiment100/files` ] }
get_log_level
:如果在polyaxonfile上设置,它将返回日志级别。
向Polyaxon报告指标
为了报告实验的度量,只需在程序中添加这些行。
frompolyaxon_helperimportsend_metricssend_metrics(accuracy=0.9,precision=0.95)
快速启动
请检查我们的quick start guide开始训练您的第一个实验。