I'm trying to integrate all the framework code gen...
# help
a
I'm trying to integrate all the framework code generated by
nf-core pipeline create
into my baby workflow. I'm getting a stack overflow. I tried debugging using these instructions and I could connect to the process but IntelliJ doesn't stop at my breakpoint. Via many log messages and gradual incorporation of changes, I've narrowed my problem down to the following: Having
Copy code
params {
    validate_params            = true
}
in my nextflow.config. If I comment this line out, problem does not occur. Then, even if I pass
--validate_params false
on the command line. with setting confirmed by
Copy code
Other parameters
...
  validate_params       : false
I've added log messages to subworkflows/nf-core/utils_nfschema_plugin/main.nf
Copy code
<http://log.info|log.info>("Before validateParameters: validate_params=${validate_params}, parameters_schema=${parameters_schema}")
    if(validate_params) {
        validateOptions = [:]
        if(parameters_schema) {
            validateOptions << [parametersSchema: parameters_schema]
        }
        <http://log.info|log.info>("Before validateParameters")
        validateParameters(validateOptions)
        <http://log.info|log.info>("After validateParameters")
    }
And I get
Copy code
Before validateParameters: validate_params=false, parameters_schema=null
Before validateParameters
ERROR ~ Unexpected error [StackOverflowError]
So it's weird that despite validate_params being false, the if statement is executed. Log file contains the stack trace, which is lots of
Copy code
at groovy.json.DefaultJsonGenerator.writeIterator(DefaultJsonGenerator.java:416)
	at groovy.json.DefaultJsonGenerator.writeObject(DefaultJsonGenerator.java:206)
	at groovy.json.DefaultJsonGenerator.writeObject(DefaultJsonGenerator.java:168)
	at groovy.json.DefaultJsonGenerator.writeIterator(DefaultJsonGenerator.java:416)
	at groovy.json.DefaultJsonGenerator.writeObject(DefaultJsonGenerator.java:206)
	at groovy.json.DefaultJsonGenerator.writeObject(DefaultJsonGenerator.java:168)
	at groovy.json.DefaultJsonGenerator.writeIterator(DefaultJsonGenerator.java:416)
Given that nf-schema is a plugin that I guess is downloaded on demand, I don't even see how to debug with log message. Help!
m
what version of nf-core cli, nextflow and nf-schema?
also cc @Nicolas Vannieuwkerke
a
N E X T F L O W ~ version 26.02.0-edge nf-schema: 2.6.1 (I don't have this configured anywhere but I see in .nextflow.log
{"plugins":[{"id":"nf-schema","releases":[{"version":"2.6.1"
nf-core 3.5.2
m
the nf-schema plugin version should be pinned in you
nextflow.config
but doesn't matter. could you try with a non-edge version (
NXF_EDGE=1 nextflow self-update
)
n
You are using typed params, right?
a
Ah, adding parameter type for
validate_params
causes
--validate_params false
to be respected. However if I leave it as the default of true, I still get the stack overflow. And IntelliJ doesn't work to set breakpoints.
n
Would you be able to create an MRE (minimal reproducible example)? I can take a look at it tomorrow
a
Maybe. I realize that the nextflow_schema.json that was created by
nf-core pipelines create
has lots of stuff that is not created by
nf-core pipelines schema build
. I'm going to try including all that gorp and see what happens.
👍 1
m
a
Hi @Nicolas Vannieuwkerke, ok, I've done some debugging. The problem is triggered by having a process with some
path
inputs:
Copy code
process MAPMYCELLS_FROMSPECIFIEDMARKERS {
    label 'process_medium'
    label 'mapmycells'
    
    container 'us-docker.pkg.dev/mccarroll-scrna-seq/us.gcr.io/mapmycells:current'
    memory '16 GB'
    scratch true // use local disk for input files because sqlite is slow over gcsfuse
    stageInMode 'copy' // ensure files are copied to local scratch, rather than symlinked

    input:
        path query_markers_json
        path precomputed_stats_h5ad
        path dge_h5ad
        path gene_mapping
        val mmc_args
        val analysis_identifier
When I run with the debugger, I can see that the stack overflow is when precomputed_stats_h5ad value is being converted to json. If I change the process definition so that input param is no longer a path, then I get the stack overflow for the next path. Stack trace:
Copy code
"main" #1 [4867] prio=5 os_prio=31 cpu=2580.15ms elapsed=143.14s tid=0x000000012c008200 nid=4867 at breakpoint [0x000000016b8d5000]
   java.lang.Thread.State: RUNNABLE
	at groovy.json.DefaultJsonGenerator.writeIterator(DefaultJsonGenerator.java:408)
	at groovy.json.DefaultJsonGenerator.writeObject(DefaultJsonGenerator.java:206)
	at groovy.json.DefaultJsonGenerator.writeObject(DefaultJsonGenerator.java:168)
	at groovy.json.DefaultJsonGenerator.toJson(DefaultJsonGenerator.java:102)
	at groovy.json.JsonOutput.toJson(JsonOutput.java:146)
	at nextflow.trace.ResourcesAggregator.renderSummaryJson(ResourcesAggregator.groovy:120)
	at nextflow.trace.ReportObserver.renderSummaryJson(ReportObserver.groovy:201)
	at nextflow.trace.ReportObserver.renderPayloadJson(ReportObserver.groovy:205)
	at nextflow.trace.ReportObserver.renderHtml(ReportObserver.groovy:216)
	at nextflow.trace.ReportObserver.onFlowComplete(ReportObserver.groovy:129)
	at nextflow.Session$_notifyFlowComplete_lambda38.doCall(Session.groovy:1082)
	at nextflow.Session$$Lambda/0x0000000800729a08.accept(Unknown Source)
	at nextflow.Session.notifyEvent(Session.groovy:1112)
	at nextflow.Session.notifyFlowComplete(Session.groovy:1082)
	at nextflow.Session.shutdown0(Session.groovy:779)
	at nextflow.Session.abort(Session.groovy:834)
	at nextflow.script.ScriptRunner.execute(ScriptRunner.groovy:139)
	at nextflow.cli.CmdRun.run(CmdRun.groovy:435)
	at nextflow.cli.Launcher.run(Launcher.groovy:515)
	at nextflow.cli.Launcher.main(Launcher.groovy:675)
sorry, not done yet. Simple repro procedure coming.
If you run this little program, you get a stack overflow:
Copy code
import groovy.json.JsonOutput;

import java.nio.file.Path;

public class reproduce_bug
{
    public static void main(String[] args) {
        final Path path = Path.of("/Users/alecw");
        System.out.println(JsonOutput.toJson(path));
    }
}
That looks like this:
Copy code
/Users/alecw/.sdkman/candidates/java/21-tem/bin/java -javaagent:/Applications/IntelliJ IDEA 3.app/Contents/lib/idea_rt.jar=49471 -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath /Users/alecw/Documents/work/mccarroll_nextflow/out/production/mccarroll_nextflow:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-cli-commons-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-astbuilder-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-cli-picocli-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-dateutil-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-datetime-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-contracts-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-groovydoc-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-docgenerator-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-ant-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-jmx-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-ginq-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-jsr223-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-json-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-console-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-groovysh-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-macro-library-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-macro-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-sql-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-nio-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-swing-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-typecheckers-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-templates-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-test-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-testng-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-toml-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-test-junit5-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-xml-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-5.0.0.jar:/Users/alecw/Documents/work/mccarroll_nextflow/lib/groovy-servlet-5.0.0.jar:/Users/alecw/.nextflow/framework/26.02.0-edge/nextflow-26.02.0-edge-one.jar reproduce_bug
Exception in thread "main" java.lang.StackOverflowError
	at java.base/sun.nio.fs.UnixPath.getNameCount(UnixPath.java:303)
	at java.base/java.nio.file.Path$1.next(Path.java:930)
	at java.base/java.nio.file.Path$1.next(Path.java:920)
	at groovy.json.DefaultJsonGenerator.writeIterator(DefaultJsonGenerator.java:414)
	at groovy.json.DefaultJsonGenerator.writeObject(DefaultJsonGenerator.java:206)
<clip>
I believe this is a bug in groovy.json.JsonOutput.toJson(). One work-around would be to convert Paths to Files before converting to json.
or even Path.toString()
n
Thanks for the debugging work! We unfortunately have to use
Path
objects for file path validation as these use the extended classes built-in to Nextflow
Could you provide a small Nextflow workflow that manages to fail every time?
a
The bug is triggered by parameter validation in code created by
nf-core pipelines create
. It generates 160 files. I'm a nextflow novice so I don't think I'd be able to prune that down. If ~160 files is considered a small workflow, maybe I could do it. I'm not suggesting you don't use Path. Rather, I'm suggesting that Paths be converted to strings in
nextflow.trace.ResourcesAggregator.renderSummaryJson
. Also, I'm new to groovy. I don't know how to report bugs in the groovy library nor see if a bug has been fixed. It's obviously a groovy library bug,. Is nextflow using the latest groovy library? Maybe it's already been fixed.
n
I think I know how to fix this on our side, but yeah might be nice trying to fix this in groovy itself. I don't know how to submit a fix either though...
Would you mind putting all your findings in an issue on the nf-schema repository?
n
Thanks!