简体   繁体   English

sbatch中未传递命令行参数

[英]Command line arguments not being passed in sbatch

I am trying to submit a job using the SLURM job scheduler and am finding that when I use the --export=VAR=VALUE syntax then some of my variables are not being passed (often the variable in the first instance of export ). 我试图使用SLURM作业计划程序提交作业,并且发现当我使用--export=VAR=VALUE语法时,我的某些变量没有被传递(通常是在export的第一个实例中)。 My understanding is that I need to specify --export=... for each variable, eg 我的理解是,我需要为每个变量指定--export=... ,例如

sbatch --export=build=true --export=param=p100_256 run.py

My script "run.py" looks like this: 我的脚本“ run.py”如下所示:

#! /usr/bin/env python                                                                                                                                                                                                      
import os,fnmatch

print(os.environ["SLURM_JOB_NAME"])
print(os.environ["SLURM_JOB_ID"])

print(fnmatch.filter(os.environ.keys(),"b*"))
print(fnmatch.filter(os.environ.keys(),"p*"))

I'd prefer to submit a python script as all of my existing scripts (used previously with PBS) are already in python and I don't want to have to rewrite them in shell scripts. 我宁愿提交一个python脚本,因为所有现有脚本(以前与PBS一起使用)已经在python中,并且我不想用shell脚本重写它们。 My problem is best demonstrated through a short example. 我的问题最好通过一个简短的例子来说明。

Firstly, 首先,

> sbatch --export=build=true --export=param=p100_256 run.py
> Submitted batch job 2249581

produces a log file with the following: 生成具有以下内容的日志文件:

run.py
2249581
[]
['param']

If I reverse the order of the export flags for 'build' and 'param', 如果我反转“ build”和“ param”的export标志的顺序,

> sbatch --export=param=true --export=build=p100_256 run.py
> Submitted batch job 2249613

then the log file now looks like, 那么日志文件现在看起来像

run.py
2249613
['build']
[]

which would suggest that only the final instance of the export flag is being passed. 这表明仅传递了export标志的最终实例。 If I add in a third instance of export , 如果我添加了export的第三个实例,

 > sbatch --export=param=1 --export=build=p100_256 --export=build_again=hello  run.py
 > Submitted batch job 2249674

then the log file returns, 然后日志文件返回,

run.py
2249674
['build_again']
[]

So does anybody know why only the final instance of export is being passed? 那么,有人知道为什么仅通过export的最终实例吗? Have I got the syntax incorrect? 我的语法有误吗? Do I need to specify an additional flag? 我是否需要指定其他标志?

Thanks! 谢谢!

Yes, looks like I had the syntax incorrect. 是的,看起来我的语法不正确。 I missed in the documentation that additional variables should be comma separated and specified with a single export flag, eg 我在文档中错过了其他变量应该用逗号分隔并用单个export标志指定的示例,例如

> sbatch --export=build=true,param=p100_256 run.py

So previous instances of export must be being replaced each time export is specified. 如此以往实例export必须每次都被替换export指定。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 命令行参数无法识别 - command line arguments not being recognised 如何打开命令行中传递的文件 arguments - How to open a file passed in the command line arguments 如果没有传递命令行参数,则为Python默认参数 - Python default parameter if no command line arguments are passed 传递给 grpc_tools.protoc 的命令行参数是什么 - What are the command line arguments passed to grpc_tools.protoc 传递给函数并作为字典返回的命令行参数问题 - Issue with command line arguments passed to function and returned as dictionary 在python中作为命令行参数传递的数字不会被解释为整数 - Numbers passed as command line arguments in python not interpreted as integers 如何将 arguments 传递给正在传递到 discord 机器人中的 bot.get_command() 的命令? - How to pass arguments into a command being passed into bot.get_command() in a discord bot? Linux:如何将命令行参数传递给正在传递给脚本的命令行参数? - Linux:How to pass command line argument to an command line argument that is being passed to a script? 有没有一种方法可以在 python 中传递 0 命令行 arguments 并且如果传递了特定参数则具有相同的结果? - Is there a way that I can pass 0 command line arguments in python and have the same result if a particular argument is passed? python中的命令行参数 - Command line arguments in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM