获取Azure Batch作业和任务的ID从Python中

huangapple go评论83阅读模式
英文:

Get Azure Batch job and task ID from python

问题

在使用Azure Batch运行自定义Python脚本时,我想获取并记录正在计算节点上运行的任务的JobID和TaskID,主要是为了以后的可追溯性和调试目的。我的愿望是从正在计算节点上执行的Python脚本内部获取这些参数。我已经查阅了Microsoft的文档,但未能找出如何访问这些信息。

我曾假设它与我通过activity.json访问自定义作业参数的方式类似,但似乎并非如此。

如何从正在执行任务的Python脚本内部获取Azure Batch任务的JobID和TaskID?

英文:

When running a custom python script using Azure Batch I am interested in getting access to, and logging, the JobID and TaskID of the tasks I am running on the compute node. Mainly for later traceability and debugging purposes. My desire is to get access to these parameters from within the python script that is being executed on the compute node. I have trawled through the Microsoft documentation, but have been unable to figure out how to access this information.

I had assumed that it was similar to the way I'm accessing the custom job parameters through the activity.json, but that does not appear to be the case.

How do I get the job ID and task ID of the Azure Batch task from within the python script that is being executed by the task?

答案1

得分: 1

Azure Batch 在任务在计算节点上执行时填充了各种运行时环境变量。您可以通过环境变量 AZ_BATCH_JOB_IDAZ_BATCH_TASK_ID 分别检索作业和任务的 ID。查看完整的环境变量列表

英文:

Azure Batch populates various runtime environment variables for use while tasks are executed on compute nodes. You can retrieve the job and task id via the environment variables AZ_BATCH_JOB_ID and AZ_BATCH_TASK_ID, respectively. See the complete list of environment variables.

huangapple
  • 本文由 发表于 2023年1月9日 18:16:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/75055788.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定