英文:
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_ID
和 AZ_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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论