[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: replacement string for running jobs number(not job number{#})
From: |
Ole Tange |
Subject: |
Re: replacement string for running jobs number(not job number{#}) |
Date: |
Mon, 12 May 2014 11:10:39 +0200 |
On Tue, May 6, 2014 at 11:59 AM, Ole Tange <ole@tange.dk> wrote:
> On Mon, May 5, 2014 at 7:33 PM, max <magicdirac@gmail.com> wrote:
>> Long question in short is I need a replacement string for the job slot
>> number. say "parallel -k -j2" , we opened two slots for all the jobs to
>> run, I want to know the slots number through which the job is running. As at
>> any time there could be only two jobs running, one should be running through
>> slot 1 and the other through slot 2. I need a replacement string to tell me
>> which slot the jobs is running through.
>
> Ahhh... Yes, that is useful, and will be implemented.
>
> https://savannah.gnu.org/bugs/?42041
The simplest way to do this is simply taking the job sequence {#}
modulo number of jobs. But that may lead to nasty surprises:
parallel -kj 2 'sleep {};echo slot:{%} seq:{#} sleep:{}' ::: 5 1 1 1 1
slot:1 seq:1 sleep:5
slot:2 seq:2 sleep:1
slot:1 seq:3 sleep:1
slot:2 seq:4 sleep:1
slot:1 seq:5 sleep:1
But what you probably want is instead:
slot:1 seq:1 sleep:5
slot:2 seq:2 sleep:1
slot:2 seq:3 sleep:1
slot:2 seq:4 sleep:1
slot:2 seq:5 sleep:1
So the job in slot 1 can assume no other jobs are running as slot 1
(e.g. maybe it appends to a file whose name depends on the slot:
>>out.{%}). And that is much harder to implement: The command line is
generated without knowing which slot it will be run in, and with
--retry the slot may even change.
I am not really sure how this can be done, as there is a
chicken-and-egg problem here.
/Ole