-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added groovy functions in lib to reduce boilerplate code #857
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #857 +/- ##
==========================================
+ Coverage 71.73% 73.75% +2.01%
==========================================
Files 30 29 -1
Lines 3386 3231 -155
==========================================
- Hits 2429 2383 -46
+ Misses 957 848 -109
Continue to review full report at Codecov.
|
Made the NfcoreSchema.groovy class now independent from Headers.groovy. Everything seems to be working, but if we only want to include the header then it will just be copy-pasting back some code (or reverting the commit), so no harm done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great :-)
I think this is good and as generic as we could have it. In cases where e.g. RNAseq needs to add some extra lib functions, this could be done in a separate file in lib/ and thus imported accordingly. That would make it possible to keep things consistent across pipelines for the majority of this functionality, while making it possible to have only tiny bits of code in the main file :-) Great job :-) |
Great :) Let's see then, I would say we keep the stuff in |
nf_core/pipeline-template/{{cookiecutter.name_noslash}}/lib/NfcoreSchema.groovy
Outdated
Show resolved
Hide resolved
if (params.help) { | ||
helpMessage() | ||
def command = "nextflow run {{ cookiecutter.name }} --input '*_R{1,2}.fastq.gz' -profile docker" | ||
log.info NfcoreSchema.params_help(workflow, params, json_schema, command) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that it might be nice to have a new lint test that just checks for certain lines in certain files. So for example to check that this function is actually being called in main.nf
(to force people to remove the old style help message)
…coreSchema.groovy Co-authored-by: Phil Ewels <phil.ewels@scilifelab.se>
Alright I removed the Otherwise everything is as before. If you're happy we can just merge this (I guess we add the new linter function in the next release?) |
Did I miss the removal of |
Discussion was on Slack sorry, mostly came from me. Two things:
Happy to discuss further, but keen to get this release out so was trying to keep things simple.. |
Small addition: I've enclosed the |
Sigh. This will cause more problems than just those values, every single config file in nf-core/configs uses the same syntax. Can we just relax the parameter validation to allow spaces? I nearly did that anyway. |
Adjusted the pattern, removed the quotes 👌 |
Sorry if I missed it then - probably jumped in that thread from time to time but wasn't 100% keeping up with the development. Fine by me and it makes sense to probably update the e-mail code at once & add the functionality then to the Completion.groovy file |
I was just playing around with @apeltzer 's port of this code into eager (already), and noticed a couple of things:
Truncation:
|
Hi James, thanks for testing this!
|
Okay so regarding the truncation, I had a closer look at the code and if I read it right the parameter summary only prints out params that are either specified via command line or in some config file. Regarding the ordering, it should be the same as in the schema 🤔 (but maybe @drpatelh can correct me If I'm wrong here). |
I've added the default value to the help message, output looks like this:
|
This happens relatively regularly (at least in my experience with eager) where a user reports something didn't run or a parameter they set weren't used - but it actually comes to down to a typo in the parameter (e.g. flipping Therefore I would argue for any unexpected parameters are automatically warned at the beginning of the run. If you have your schema and
|
Ah and one additional point that just came to mind (although might be more relevant a comment on the schema). The section for the profile information in the help message is currently called Maybe it would be better to call it: |
Good points, and I think I agree with @jfy133 on the reporting of unexpected parameter. After all, we have Okay actually the default parameters in the schema are not used in the pipeline I think, but only as a means to print the the help message and for validation. So the defaults specified there might not really be the truth. Or am I missing something and are the used somehow? 🤔 |
I would assume I actually sort of liked the behaviour that only display parameters that are changed from default (if a message was stated accordingly), because otherwise for eager you would be displaying 136 parameters in the summary,w hich might be overhill 😅 |
Yes they should be the same ... and linting should tell you if they aren't. So in theory we could totally leave it like that, there are a lot of checks in place that should ideally scream if it's not the case 🤷 Okay I think that's the behaviour it has right now as well, or not? Only the help message gives you all of it. |
I thikn so! Other than suggestion the A message suggesiton could be such as:
Or something along those lines. It could also be at the end of the summary even. |
Sorry both, just catching up with this discussion. Regarding warning about unexpected params - this was before we had Though actually this might also be problematic, as we need to append to that config instead of overwriting it. So that won't work for now. Also needs more thought 🤔 Regarding the defaults, yes it's a bit tricky - the vanilla pipeline should match the schema (did linting not tell you that stuff was wrong @jfy133 ? Maybe we should investigate if not..?). But there's nothing to stop you running There's no perfect option here I think. Either we use the schema and it may not display the truth of what will run by default, or we use the config and it may not match the documentation. I'm not sure that it really matters much tbh as the end result is the same - that we should really try to make sure that the schema matches the config by default! I would prefer to go for showing the schema defaults I think. The summary should show any params that don't match the schema when launching so any differences should be shown there explicitly anyway. +1 for ditching the Also +1 for having a log message that explains that the summary only shows stuff varying from the pipeline defaults. |
Okay everything ready to merge from my side. It's still printing unexpected params only when failing - that's the only thing we might want to change, or leave as is. If you're happy with them being printed out on fail only we can merge. |
If you're happy to always warn (not just in fail) that's fine with me. The other possible option (I don't know how complicted it would be to implement) would be to have some form of param that specifies verbosity? In large pipelines such as But maybe for simplier pipelines it is overkill to always report discrepencies.... and regarding schema vs config, agreed - it seems there direction nf-core is going is schema focused anyway, so a linting message that |
Sounds reasonable to me, too. if (unexpectedParams.size() > 0) {
println ''
def warn_msg = 'Found unexpected parameters:'
for (unexpectedParam in unexpectedParams) {
warn_msg = warn_msg + "\n* --${unexpectedParam}: ${paramsJSON[unexpectedParam].toString()}"
}
log.warn warn_msg
} outside the @ewels if you're happy with that I'll do the changes and we can merge. |
This PR adds some of the functions written by @drpatelh to the template, specifically the classes:
Headers.groovy
Completion.groovy
NfcoreSchema.groovy
This should close #577
Wherever possible I deleted pipeline-specific code.