【问题标题】:How do I get the condor job number in python and to the output script?如何在 python 和输出脚本中获取 condor 作业编号?
【发布时间】:2020-08-18 05:19:37
【问题描述】:

我想要两件事:

  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

因为我不知道 `no env 变量作为标准是什么,但预定义宏还有另一种方法

将其包含在环境中(例如) environment = CONDOR_ID=$(Cluster).$(Process)`的意思。我在我的提交脚本中这样做吗?但是我的提交脚本是一个python脚本......我很困惑。我尝试查看所有环境变量名称,但没有任何符合我预期的名称。

【问题讨论】:

  • 为什么链接没有帮助?
  • @AlexeyMints 感谢您的澄清!我会更新。我不知道no env variable as standard but there is another way with the predefined macros include it the environment with (for example) environment = CONDOR_ID=$(Cluster).$(Process) 是什么意思。我在我的提交脚本中这样做吗?但是我的提交脚本是一个python脚本......我很困惑。我尝试查看所有环境变量名称,但没有符合我的预期。

标签: python condor


【解决方案1】:

如果您希望输出文件的 name 中包含作业 ID,请尝试类似

output = my_job_$(CLUSTER).out

请注意,condor 作业 ID 有两部分,“集群”和“过程”。如果您只是以 a 结束提交文件,则 proc 始终为 0

queue

声明。如果您使用

为每个集群提交多个 proc
queue 100

那么 procs 将从 0 变为 99。

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

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

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

environment = MY_JOB_ID = $(CLUSTER)

那么你的 python 脚本将在名为 MY_JOB_ID 的环境变量中看到集群 ID

【讨论】:

  • 天哪!这样可行!您是如何找到所有这些信息的?几天来我一直在尝试谷歌,但我发现没有任何用处。格雷格的秘诀是什么? ;)
  • Greg,proc 编号是否类似于 slurm 数组作业? (您一次将多个作业发送到集群)
  • 啊,是的,如果你熟悉 slurm,proc 编号就像作业数组。
猜你喜欢
  • 2014-01-27
  • 1970-01-01
  • 2010-10-19
  • 2022-11-24
  • 1970-01-01
  • 1970-01-01
  • 2017-12-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多