如何在python中获取condor作业号并将其添加到输出脚本中?

2024-05-29 07:39:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我想要两件事:

  1. python中的作业编号
  2. 输入到输出文件中

我的提交脚本如下所示:

####################
#
# Simple HTCondor submit description file
#
####################

Executable = test_condor.py
Log          = condor_job_log.out
Output       = condor_job_stdout.out
Error        = condor_job_stdout.out
# Use this to make sure 1 gpu is available. The key words are case insensitive. 
REquest_gpus = 1
# Note: to use multiple CPUs instead of the default (one CPU), use request_cpus as well
Request_cpus = 4
# E-mail option
Notify_user = me@gmail.com

# "Queue" means add the setup until this line to the queue (needs to be at the end of script).
Queue

我希望输出文件中附加作业编号,如:

Log          = condor_job_log{$JOB_ID}.out

我试图通过在python中打印所有环境变量来查找环境名称,但没有任何帮助:

 os.environ = environ({'_CONDOR_ANCESTOR_2148': '3092:1586844319:3811816668', '_CONDOR_ANCESTOR_18122': '18123:1588528659:3276981140', '_CONDOR_ANCESTOR_3092': '18122:1588528659:978447114', 'TEMP': '/srv/condor/execute/dir_18122', '_CONDOR_SCRATCH_DIR': '/srv/condor/execute/dir_18122', '_CONDOR_SLOT': 'slot1_4', 'BATCH_SYSTEM': 'HTCondor', 'TMPDIR': '/srv/condor/execute/dir_18122', '_CONDOR_CHIRP_CONFIG': '/srv/condor/execute/dir_18122/.chirp.config', '_CONDOR_JOB_PIDS': '', 'TMP': '/srv/condor/execute/dir_18122', 'OMP_NUM_THREADS': '4', '_CONDOR_AssignedGPUs': 'CUDA1', '_CONDOR_JOB_AD': '/srv/condor/execute/dir_18122/.job.ad', 'CUDA_VISIBLE_DEVICES': '1', '_CONDOR_JOB_IWD': '/home/me/repo/repo-proj/code', '_CHIRP_DELAYED_UPDATE_PREFIX': 'Chirp', 'GPU_DEVICE_ORDINAL': '1', '_CONDOR_MACHINE_AD': '/srv/condor/execute/dir_18122/.machine.ad'})

因为jobnumber应该是类似于:

Submitting job(s).
1 job(s) submitted to cluster 11011.

我试着在中搜索那个号码,但没有成功。所以我不能从python中获得它…那么我如何获得它呢


这没有帮助:https://www-auth.cs.wisc.edu/lists/htcondor-users/2005-February/msg00202.shtml

因为我不知道什么是'没有环境变量作为标准,但有另一种方式与预定义的宏

将其包括在环境中(例如) 环境=CONDOR_ID=$(集群)。$(进程)`意味着。我在提交脚本中是否这样做?但是我的提交脚本是一个python脚本…我很困惑。我尝试查看所有环境变量的名称,但没有任何内容符合我的预期


Tags: theto脚本execute环境dir作业环境变量
1条回答
网友
1楼 · 发布于 2024-05-29 07:39:48

如果要在输出文件的名称中输入作业id,请尝试以下操作

output = my_job_$(CLUSTER).out

请注意,condor作业id有两部分,“集群”和“进程”。如果您仅以

queue

声明。如果您使用每个群集提交多个进程

queue 100

然后进程将从0变为99

在这种情况下,您可能希望将集群和proc放入文件名中,如下所示

output = my_job_$(CLUSTER).$(PROCESS).out

将集群id放入环境并不困难,假设您希望将其放入环境变量MY_JOB_id中。然后您可以将其添加到提交文件中(在队列语句之前)

environment = MY_JOB_ID = $(CLUSTER)

然后,python脚本将在名为MY_JOB_id的环境变量中看到集群id

相关问题 更多 >

    热门问题