Something that bothers me with our stub tests is t...
# team-maintainers
j
Something that bothers me with our stub tests is that we get lots of 'unused variable' warnings with the language server, which is caused by the
def args
that we don't use within the code execution. What would people think of adding a
echo ${args}
to the stub execution code block to satisfy the language server. Also I guess when running a stub run you can also test ext.args is wroking properly. Alternative'l we could remove the
def args
from stubs thoughts?
s
I would say remove args from stub sections as they are not used...mostly just prefix is used to touch files
💯 2
j
But is it worth checking for someone their args has been picked up by the module correctly? Or not really
s
havent seen any PRs with anybody doing that
🤷
j
Me niether
s
mostly its just mkdir and touch $prefix.txt
j
Thinking more for --dry-run pipeline runs
when we have pipleines that are fully compatible
m
For me the logic of recreating the files we do in the stub only needs the args if it affect the naming and existence of said files
👍 1
j
Right
So then def args shouldn't be in teh stub?
m
most of the time not needed indeed
m
My vote is to remove it too
m
I'd go keep it if it affects the naming and existence of output files
otherwise kill it
j
Ok so user should add if necessary
nod 1
m
At the pipeline level it's more tricky
In #rnaseq for example, we're looking at file content to assess if the quality of the fastq are good
that's not possible on an empty file, so we can't reproduce the pipeline behavior with stubs
s
also did we agree upon removing this as well ?
Copy code
when:
    task.ext.when == null || task.ext.when
m
isn't the syntax changing for this?
and you want to remove this from where?
s
all modules i guess.... what the new syntax going to be ?
m
I did like this possibility
but I can see why you'd like it remove
I'd say keep it for now, and re-assess later
m
I say remove it when it's finally removed. It's only deprecated for now, and has another purpose that a few people use
👍 1
s
ya havent seen any pipelines use it actually
m
The other use is for the users to disable parts that don't have a flag to disable them
You won't see it in a pipeline
s
ok...anyway we can decide on this another day but, for now I think removing args from stub is a go
👍🏽 1
👍 1
j
Can someone check if a module linting will fail if it's removed?
I've run out of time before meeting
s
i ll try ur pr
m
I use (when) in sarek a lot
s
show us
m
But that's to reduce the
filter
and
branching
right (which is what should be used)?
The original intention of
ext.when
was to enable conditional execution of a process based on something in config ( which you can't access in the script ). but I don't think anyone has that.
s
finally got to see an example of it in use...thanks @Maxime Garcia
🙏 1
m
We had that since @Mahesh Binzer-Panchal added this feature to #modules I'm fairly sure
nod 1
(more or less)
Always happy to show some more #sarek code @Sateesh_Peri 🤣
s
ya i try to stay away from sarek as much as I can homer disappear
🤣 1
m
I cannot blame you
s
I've used
when
to turn off parts of pipelines that aren't working or I don't need. But @Ben Sherman doesn't like it and wants to ditch it.
The $args in stubs me and others have just been removing as the modules are updated.
But yeah, if it is in the template for the stub then be good to remove that.
j
OK but it doesn't complain?
s
what doesn't complain about what? The linter and Removing the args from the stub? Yeah, loads of modules have been updated to remove them from the stub.
j
image.png
We should remove from template and maybe a mass removal?
MEGA PR TIMEEEE
s
Yeah, but as noted above some of the modules stubs do use the args
j
That's fine
Those won't have the warning on the language server
s
yep
f
I already always removed them when I saw that they were unused haha
😬 1
a
I’m just dropping in to repeat what I have said to James on the PR:
Would it be potentially better to do
echo $args
in the
stub
section?
This has a couple of benefits over dropping the `$args`:
• maintains consistency between
script
and
stub
section logic
• adds a simplistic level of testing that
args
are behaving as expected
• keeps the language server happy
I understand there seems to be some difference of opinion on the purpose/use of the
stub
. For me it has the power to operate more a complete dry-run test by running the same logic as the
script
(currently manually duplicated unless this issue gets picked up). Personally I find this to be more in line with what a user might expect a dry-run/stub to test and I have also found it very helpful for testing internal module logic in cases where getting meaningful minimised test-data is not easy/possible.
➕ 1
j
<!subteam^S044DU0NG68> thoughts?
In fact I wonder if we could extend it slightly:
Copy code
stub
"""
echo"command \\
   $args \\
   $input"

touch ${prefix}

<...>
"""
It would just mean a module author copying the command(s) in
script
and wrapping in
echo
In addition to the
touches
m
I like where this is going
That sounds easy enough to lint for even
j
(actuaylly exactly like @Arthur’s workaround in the issue, now I've read it 😅 )
j
Hello all, bringing this up again to try and make a final decision 😄 Please read the thread for context ☝🏻 and vote! ✉️ 1️⃣ Add
echo $args
to all modules
stub
2️⃣ Remove def
args = teask.ext.args ?: ""
from all modules
stub
3️⃣ Both: add echo to the template but allow removing both lines if the module doesn't use it
1️⃣ 2
3️⃣ 14
n
I'm all for number two but some modules do need
args
in their stub to determine which files should be touched. So I'd say a mix of the two options 😛
A third option, maybe? Only keep it when needed?
j
What's the harm of having it though, I've never understood people's reservations on it. But I guess having it by default in the template with a TODO to remove both lines if you don't want to test it is an ok compromise I guess
j
Why to add the
echo $args
to all modules, I will with @Nicolas Vannieuwkerke that only keep them when needed to name the files
🎉 1
n
Yeah there's absolutely no harm in having it 😛
j
I edited the message to add option 3
thanks 1
n
Thank you!
j
Context: currently Args is in all stubs. Language server doesn't like it as srgs not used the the stub script itself. We considered moving it but @Arthur said actually it can be a very good check to make sure Args logic is actually working correctly
r
It would not be the worst to validate the args though. especially if there are more complicated setups. if/else/closures/dependencies. Although that would have to happen on the pipeline level
👍 2
s
So you are talking about doing this:
Copy code
stub:
    def args = task.ext.args ?: ''
    def prefix = task.ext.prefix ?: "${meta.id}"
    """
    echo $args
    touch ${prefix}.bam

    cat <<-END_VERSIONS > versions.yml
    "${task.process}":
        samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
    END_VERSIONS
    """
j
I was thinking actually:
Copy code
stub:
    def args = task.ext.args ?: ''
    def prefix = task.ext.prefix ?: "${meta.id}"
    """
    echo "samtools sort $args ..."
    touch ${prefix}.bam

    cat <-END_VERSIONS  versions.yml
    "${task.process}":
        samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
    END_VERSIONS
    """
shake no 2
Like literally copy the actual command(s) from the script block andjust wrapping in in an echo
But ocnceptually yes
n
That will be difficult to keep in sync I think? That should be done on the Nextflow level IMO
s
Maybe with something to explain what the args line actually is:
Copy code
stub:
    def args = task.ext.args ?: ''
    def prefix = task.ext.prefix ?: "${meta.id}"
    """
    echo "args:" $args
    touch ${prefix}.bam

    cat <<-END_VERSIONS > versions.yml
    "${task.process}":
        samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
    END_VERSIONS
    """
👍 1
j
That will be difficult to keep in sync I think? That should be done on the Nextflow level IMO
Copy pasting is hard now?!
nod 2
But fair enough, at a bareminium `echo "args: $args" is fine for me
🎉 1
n
Copy pasting is hard now?!
No, but remembering to update the stub everytime you change the command is 😉
👍 2
👍🏻 1
r
Copy pasting is hard now?!
meow yes
💯 2
😂 7