如何从CONDOR获得队列号到R任务

时间:2022-04-26 17:40:22

I think I have a simple problem because I was looking up and down the internet and couldn't find someone else asking this question: My university has a Condor set-up. I want to run several repetitions of the same code (e.g. 100 times). My R code has a routine to store the results in a file, i.e.:

我想我有一个简单的问题,因为我在网上到处找,却找不到别人问我这个问题:我的大学有一个秃鹰的装置。我想对相同的代码重复几次(比如100次)。我的R代码有一个例程将结果存储在一个文件中,即:

write.csv(res, file=paste(paste(paste(format(Sys.time(), '%y%m%d'),'res', queue, sep="_"), sep='/'),'.csv',sep='',collapse=''))

res are my results (a data.frame), I indicate that this file contains the results with 'res' and finally I want to add the queue number of this calculation (otherwise files would be replaced, wouldn't they?). It should look like: 140109_res_1.csv, 140109_res_2.csv, ...

res是我的结果(一个data.frame),我指出这个文件包含带有'res'的结果,最后我想添加这个计算的队列号(否则文件会被替换,不是吗?)它应该是:140109_res_1。csv、140109 _res_2。csv,……

My submit file to condor looks like this:

我提交给condor的文件是这样的:

universe = vanilla
executable = /usr/bin/R 
arguments =  --vanilla 
log =  testR.log
error = testR.err
input = run_condor.r
output = testR$(Process).txt
requirements = (opsys == "LINUX") && (arch == "X86_64") && (HAS_R_2_13 =?= True)
request_memory = 1000
should_transfer_files = YES
transfer_executable = FALSE
when_to_transfer_output = ON_EXIT
queue 3

I wonder how do I get the 'queue' number into my R code? I tried a simple example with

我想知道如何将“队列”号输入到R码中?我尝试了一个简单的例子

print(queue)
print(Queue)

But there is no object found called queue or Queue. Any suggestions? Best wishes, Marco

但是没有找到称为队列或队列的对象。有什么建议吗?最好的祝愿,马可

1 个解决方案

#1


2  

Okay, I solved the problem. This is how it goes:

我解决了这个问题。事情是这样的:

  1. I had to change my submit file. I changed the slot arguments to:

    我必须修改我的提交文件。我将槽参数更改为:

    arguments = --vanilla --args $(Process)

    参数= -vanilla -args $(进程)

  2. Now the process number is forwarded to the R code. There you retrieve it with the following line. The value will be stored as a character. Therefore, you should convert it to a numeric value (also check whether a number like 10 is passed on as '1' and '0' in which case you should also collapse the values).

    现在流程号被转发到R代码。在那里你可以用下面一行来检索它。值将以字符的形式存储。因此,您应该将它转换为一个数值(还应该检查像10这样的数字是否作为“1”和“0”传递,在这种情况下,还应该折叠这些值)。

    run <- commandArgs(TRUE)

    < - commandArgs运行(真正的)

Here is an example of the code I let run.

下面是我让它运行的代码示例。

> run <- commandArgs(TRUE)
> run
[1] "0"
> class(run)
[1] "character"
> try(as.numeric(run))
[1] 0
> try(run <- as.numeric(paste(run, collapse='')) )
> try(print(run))
[1] 0
> try(write(run, paste(run,'csv', sep='.')))

You can also find information how to pass on variables/arguments to your code here: http://research.cs.wisc.edu/htcondor/manual/v7.6/condor_submit.html

您还可以在这里找到如何将变量/参数传递给代码的信息:http://research.cs.wisc.edu/htcondor/manual/v7.6/condor_submit.html

I hope this helps anyone. Cheers and thanks for all other commenters! Marco

我希望这能帮助任何人。谢谢所有的评论!马可

#1


2  

Okay, I solved the problem. This is how it goes:

我解决了这个问题。事情是这样的:

  1. I had to change my submit file. I changed the slot arguments to:

    我必须修改我的提交文件。我将槽参数更改为:

    arguments = --vanilla --args $(Process)

    参数= -vanilla -args $(进程)

  2. Now the process number is forwarded to the R code. There you retrieve it with the following line. The value will be stored as a character. Therefore, you should convert it to a numeric value (also check whether a number like 10 is passed on as '1' and '0' in which case you should also collapse the values).

    现在流程号被转发到R代码。在那里你可以用下面一行来检索它。值将以字符的形式存储。因此,您应该将它转换为一个数值(还应该检查像10这样的数字是否作为“1”和“0”传递,在这种情况下,还应该折叠这些值)。

    run <- commandArgs(TRUE)

    < - commandArgs运行(真正的)

Here is an example of the code I let run.

下面是我让它运行的代码示例。

> run <- commandArgs(TRUE)
> run
[1] "0"
> class(run)
[1] "character"
> try(as.numeric(run))
[1] 0
> try(run <- as.numeric(paste(run, collapse='')) )
> try(print(run))
[1] 0
> try(write(run, paste(run,'csv', sep='.')))

You can also find information how to pass on variables/arguments to your code here: http://research.cs.wisc.edu/htcondor/manual/v7.6/condor_submit.html

您还可以在这里找到如何将变量/参数传递给代码的信息:http://research.cs.wisc.edu/htcondor/manual/v7.6/condor_submit.html

I hope this helps anyone. Cheers and thanks for all other commenters! Marco

我希望这能帮助任何人。谢谢所有的评论!马可