There are two ways to make a task parameter default value. Which will appear when using wdltool inp

LeeTL1220LeeTL1220 Arlington, MAMember, Broadie, Dev ✭✭✭

I have a task that I would like to default the mem parameter to 4. I can do that two ways:

task foo{
    Int mem=4
    .... snip...
    runtime {
        ${mem}
        ....snip...
    }
}

OR

task foo{
    Int? mem
    .... snip...
    runtime {
        ${default=4 mem}
        ....snip....
    }
}

If I do wdltool inputs ...., will the mem parameter appear if I use the former example?

Best Answer

Answers

  • LeeTL1220LeeTL1220 Arlington, MAMember, Broadie, Dev ✭✭✭
    Accepted Answer

    It will not. Only the latter.

  • Geraldine_VdAuweraGeraldine_VdAuwera Cambridge, MAMember, Administrator, Broadie admin

    I'm guessing testing it took less time than writing the question ;)

    You could declare an optional mem variable at the workflow level that you would feed into your task call. That workflow level variable would then show up in the inputs template. Potentially useful if you want to optionally impose the same memory setting on multiple calls/tasks, while allowing different defaults.

    But then that could be done with either of the task-levels syntaxes you show. Ultimately the main difference between the two is that (1) is more obvious/explicit and will apply to any instances of mem used in the command (in the unlikely event that it's used multiple times) while (2) is a tad less explicit yet gives you more flexibility in the event that you need that.

  • LeeTL1220LeeTL1220 Arlington, MAMember, Broadie, Dev ✭✭✭

    @Geraldine_VdAuwera Two things:

    1) I thought I couldn't test it at the time I wrote the question. Luckily, it turned out I had been the victim of alternative facts and once that was rectified, I ran the test.
    2) If we want more coarse control over the mem settings, we'll do that in a different PR.

Sign In or Register to comment.