nextflow-io / nf-schema

Functionality for working with pipeline and sample sheet schema files in Nextflow pipelines
https://nextflow-io.github.io/nf-schema/
Apache License 2.0
12 stars 21 forks source link

Migration to nf-schema 2: `samplesheetToList` not found in `plugin/nf-schema` #28

Closed Tobiaspk closed 3 weeks ago

Tobiaspk commented 6 months ago

Problem occured during migration from nf-vallidation to nf-schema. Aim is to migrate to newere sample sheet reader function.

Reproducible steps

  1. Create new template pipeline
    # nf-core version 2.13.1
    nf-core create
  2. Update plugin in nextflow.config
    plugins {
    id 'nf-schema@2.0.0' 
    }
  3. Update imports in subworkflows/local/utils_nfcore_training_pipeline/main.nf
    include { samplesheetToList } from 'plugin/nf-schema'
  4. Run with
    nextflow run . \
    -profile test,docker \
    --outdir test_results

Error stack

Apr-23 12:39:13.829 [main] DEBUG nextflow.cli.Launcher - $> nextflow run . -profile test,docker --outdir test_results
Apr-23 12:39:13.880 [main] INFO  nextflow.cli.CmdRun - N E X T F L O W  ~  version 23.10.1
Apr-23 12:39:13.892 [main] DEBUG nextflow.plugin.PluginsFacade - Setting up plugin manager > mode=prod; embedded=false; plugins-dir=/Users/krauset/.nextflow/plugins; core-plugins: nf-amazon@2.1.4,nf-azure@1.3.3,nf-cloudcache@0.3.0,nf-codecommit@0.1.5,nf-console@1.0.6,nf-ga4gh@1.1.0,nf-google@1.8.3,nf-tower@1.6.3,nf-wave@1.0.1
Apr-23 12:39:13.898 [main] INFO  o.pf4j.DefaultPluginStatusProvider - Enabled plugins: []
Apr-23 12:39:13.899 [main] INFO  o.pf4j.DefaultPluginStatusProvider - Disabled plugins: []
Apr-23 12:39:13.901 [main] INFO  org.pf4j.DefaultPluginManager - PF4J version 3.4.1 in 'deployment' mode
Apr-23 12:39:13.908 [main] INFO  org.pf4j.AbstractPluginManager - No plugins
Apr-23 12:39:14.425 [main] DEBUG nextflow.config.ConfigBuilder - Found config local: /Users/krauset/projects/tools/pipelines/temp/nf-core-temp/nextflow.config
Apr-23 12:39:14.426 [main] DEBUG nextflow.config.ConfigBuilder - Parsing config file: /Users/krauset/projects/tools/pipelines/temp/nf-core-temp/nextflow.config
Apr-23 12:39:14.433 [main] DEBUG nextflow.config.ConfigBuilder - Applying config profile: `test,docker`
Apr-23 12:39:15.074 [main] DEBUG nextflow.config.ConfigBuilder - Available config profiles: [cfc_dev, uzl_omics, ifb_core, denbi_qbic, alice, mjolnir_globe, uppmax, incliva, ilifu, uge, rosalind_uge, lugh, unibe_ibu, vai, czbiohub_aws, jax, ccga_med, scw, unc_longleaf, tigem, tubingen_apg, google, apollo, ipop_up, vsc_calcua, pdc_kth, googlels, daisybio, eddie, medair, biowulf, apptainer, bi, bigpurple, adcra, cedars, pawsey_setonix, vsc_kul_uhasselt, pawsey_nimbus, ucl_myriad, utd_ganymede, charliecloud, icr_davros, ceres, munin, arm, rosalind, hasta, cfc, uzh, ebi_codon_slurm, ebc, ku_sund_dangpu, ccga_dx, crick, marvin, biohpc_gen, shifter, mana, mamba, york_viking, unc_lccc, wehi, awsbatch, wustl_htcf, arcc, imperial, maestro, software_license, utd_europa, genotoul, nci_gadi, abims, janelia, nu_genomics, googlebatch, oist, sahmri, mpcdf, leicester, vsc_ugent, create, sage, cambridge, jex, podman, ebi_codon, cheaha, xanadu, nyu_hpc, test, computerome, ucd_sonic, seg_globe, sanger, dkfz, pasteur, einstein, ethz_euler, m3c, test_full, imb, ucl_cscluster, tuos_stanage, azurebatch, hki, crukmi, csiro_petrichor, qmul_apocrita, docker, engaging, gis, hypatia, psmn, eva, nygc, fgcz, conda, crg, singularity, self_hosted_runner, tufts, uw_hyak_pedslabs, utd_sysbio, debug, genouest, cbe, phoenix, gitpod, seawulf, uod_hpc, fub_curta, uct_hpc, aws_tower, binac]
Apr-23 12:39:15.103 [main] DEBUG nextflow.cli.CmdRun - Applied DSL=2 from script declararion
Apr-23 12:39:15.113 [main] INFO  nextflow.cli.CmdRun - Launching `./main.nf` [modest_turing] DSL2 - revision: 4a2d25f07b
Apr-23 12:39:15.113 [main] DEBUG nextflow.plugin.PluginsFacade - Plugins declared=[nf-validation@1.1.3, nf-schema@2.0.0]
Apr-23 12:39:15.114 [main] DEBUG nextflow.plugin.PluginsFacade - Plugins default=[]
Apr-23 12:39:15.114 [main] DEBUG nextflow.plugin.PluginsFacade - Plugins resolved requirement=[nf-validation@1.1.3, nf-schema@2.0.0]
Apr-23 12:39:15.114 [main] DEBUG nextflow.plugin.PluginUpdater - Installing plugin nf-validation version: 1.1.3
Apr-23 12:39:15.121 [main] INFO  org.pf4j.AbstractPluginManager - Plugin 'nf-validation@1.1.3' resolved
Apr-23 12:39:15.121 [main] INFO  org.pf4j.AbstractPluginManager - Start plugin 'nf-validation@1.1.3'
Apr-23 12:39:15.129 [main] DEBUG nextflow.plugin.BasePlugin - Plugin started nf-validation@1.1.3
Apr-23 12:39:15.129 [main] DEBUG nextflow.plugin.PluginUpdater - Installing plugin nf-schema version: 2.0.0
Apr-23 12:39:15.132 [main] INFO  org.pf4j.AbstractPluginManager - Plugin 'nf-schema@2.0.0' resolved
Apr-23 12:39:15.132 [main] INFO  org.pf4j.AbstractPluginManager - Start plugin 'nf-schema@2.0.0'
Apr-23 12:39:15.134 [main] DEBUG nextflow.plugin.BasePlugin - Plugin started nf-schema@2.0.0
Apr-23 12:39:15.140 [main] DEBUG n.secret.LocalSecretsProvider - Secrets store: /Users/krauset/.nextflow/secrets/store.json
Apr-23 12:39:15.142 [main] DEBUG nextflow.secret.SecretsLoader - Discovered secrets providers: [nextflow.secret.LocalSecretsProvider@2801827a] - activable => nextflow.secret.LocalSecretsProvider@2801827a
Apr-23 12:39:15.206 [main] DEBUG nextflow.Session - Session UUID: 92b7f431-9cde-4a16-a180-27527e8082dd
Apr-23 12:39:15.206 [main] DEBUG nextflow.Session - Run name: modest_turing
Apr-23 12:39:15.207 [main] DEBUG nextflow.Session - Executor pool size: 10
Apr-23 12:39:15.217 [main] DEBUG nextflow.file.FilePorter - File porter settings maxRetries=3; maxTransfers=50; pollTimeout=null
Apr-23 12:39:15.221 [main] DEBUG nextflow.util.ThreadPoolBuilder - Creating thread pool 'FileTransfer' minSize=10; maxSize=30; workQueue=LinkedBlockingQueue[10000]; allowCoreThreadTimeout=false
Apr-23 12:39:15.249 [main] DEBUG nextflow.cli.CmdRun - 
  Version: 23.10.1 build 5891
  Created: 12-01-2024 22:01 UTC (17:01 EDT)
  System: Mac OS X 13.3.1
  Runtime: Groovy 3.0.19 on OpenJDK 64-Bit Server VM 20.0.1
  Encoding: UTF-8 (UTF-8)
  Process: 7776@LSKI4053 [172.18.232.166]
  CPUs: 10 - Mem: 16 GB (72.4 MB) - Swap: 3 GB (798.2 MB)
Apr-23 12:39:15.260 [main] DEBUG nextflow.Session - Work-dir: /Users/krauset/projects/tools/pipelines/temp/nf-core-temp/work [Mac OS X]
Apr-23 12:39:15.260 [main] DEBUG nextflow.Session - Script base path does not exist or is not a directory: /Users/krauset/projects/tools/pipelines/temp/nf-core-temp/bin
Apr-23 12:39:15.267 [main] DEBUG nextflow.executor.ExecutorFactory - Extension executors providers=[]
Apr-23 12:39:15.273 [main] DEBUG nextflow.Session - Observer factory: DefaultObserverFactory
Apr-23 12:39:15.305 [main] DEBUG nextflow.cache.CacheFactory - Using Nextflow cache factory: nextflow.cache.DefaultCacheFactory
Apr-23 12:39:15.311 [main] DEBUG nextflow.util.CustomThreadPool - Creating default thread pool > poolSize: 11; maxThreads: 1000
Apr-23 12:39:15.351 [main] DEBUG nextflow.Session - Session start
Apr-23 12:39:15.353 [main] DEBUG nextflow.trace.TraceFileObserver - Workflow started -- trace file: /Users/krauset/projects/tools/pipelines/temp/nf-core-temp/test_results/pipeline_info/execution_trace_2024-04-23_12-39-15.txt
Apr-23 12:39:15.479 [main] DEBUG nextflow.script.ScriptRunner - > Launching execution
Apr-23 12:39:15.752 [main] DEBUG nextflow.script.IncludeDef - Loading included plugin extensions with names: [paramsSummaryMap:paramsSummaryMap]; plugin Id: nf-validation
Apr-23 12:39:16.013 [main] DEBUG nextflow.script.IncludeDef - Loading included plugin extensions with names: [paramsHelp:paramsHelp]; plugin Id: nf-validation
Apr-23 12:39:16.013 [main] DEBUG nextflow.script.IncludeDef - Loading included plugin extensions with names: [paramsSummaryLog:paramsSummaryLog]; plugin Id: nf-validation
Apr-23 12:39:16.013 [main] DEBUG nextflow.script.IncludeDef - Loading included plugin extensions with names: [validateParameters:validateParameters]; plugin Id: nf-validation
Apr-23 12:39:16.014 [main] DEBUG nextflow.script.IncludeDef - Loading included plugin extensions with names: [paramsSummaryMap:paramsSummaryMap]; plugin Id: nf-validation
Apr-23 12:39:16.014 [main] DEBUG nextflow.script.IncludeDef - Loading included plugin extensions with names: [samplesheetToList:samplesheetToList]; plugin Id: nf-schema
Apr-23 12:39:16.015 [main] DEBUG nextflow.script.ScriptRunner - Parsed script files:
  Script_a7d371fe23db7aab: /Users/krauset/projects/tools/pipelines/temp/nf-core-temp/./workflows/../subworkflows/local/utils_nfcore_temp_pipeline/../../nf-core/utils_nfvalidation_plugin/main.nf
  Script_be0adedc591c66cc: /Users/krauset/projects/tools/pipelines/temp/nf-core-temp/./workflows/../subworkflows/nf-core/utils_nfcore_pipeline/main.nf
  Script_b1634edd947fcf7e: /Users/krauset/projects/tools/pipelines/temp/nf-core-temp/./workflows/temp.nf
  Script_4ba798786ecd6418: /Users/krauset/projects/tools/pipelines/temp/nf-core-temp/./workflows/../modules/nf-core/fastqc/main.nf
  Script_1fb3f031c8bfc44b: /Users/krauset/projects/tools/pipelines/temp/nf-core-temp/./workflows/../subworkflows/local/utils_nfcore_temp_pipeline/main.nf
  Script_e6212041ff99d3c1: /Users/krauset/projects/tools/pipelines/temp/nf-core-temp/main.nf
  Script_11299cb12a111d0f: /Users/krauset/projects/tools/pipelines/temp/nf-core-temp/./workflows/../modules/nf-core/multiqc/main.nf
Apr-23 12:39:16.015 [main] DEBUG nextflow.Session - Session aborted -- Cause: Extension 'samplesheetToList' it isn't defined by plugin nf-schema
Apr-23 12:39:16.021 [main] ERROR nextflow.cli.Launcher - @unknown
java.lang.IllegalStateException: Extension 'samplesheetToList' it isn't defined by plugin nf-schema
    at nextflow.plugin.extension.PluginExtensionProvider.loadPluginExtensionMethods(PluginExtensionProvider.groovy:156)
    at nextflow.plugin.extension.PluginExtensionProvider.loadPluginExtensionMethods(PluginExtensionProvider.groovy:119)
    at nextflow.script.IncludeDef.loadPlugin0(IncludeDef.groovy:221)
    at nextflow.script.IncludeDef.load0(IncludeDef.groovy:117)
    at nextflow.script.IncludeDef$load0$1.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
    at Script_1fb3f031c8bfc44b.runScript(Script_1fb3f031c8bfc44b:13)
    at nextflow.script.BaseScript.run0(BaseScript.groovy:144)
    at nextflow.script.BaseScript.run(BaseScript.groovy:192)
    at nextflow.script.ScriptParser.runScript(ScriptParser.groovy:236)
    at nextflow.script.ScriptParser.runScript(ScriptParser.groovy:222)
    at nextflow.script.IncludeDef.memoizedMethodPriv$loadModule0PathMapSession(IncludeDef.groovy:151)
    at nextflow.script.IncludeDef.access$0(IncludeDef.groovy)
    at nextflow.script.IncludeDef$__clinit__closure2.doCall(IncludeDef.groovy)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:578)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:274)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1030)
    at groovy.lang.Closure.call(Closure.java:427)
    at org.codehaus.groovy.runtime.memoize.Memoize$MemoizeFunction.lambda$call$0(Memoize.java:137)
    at org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:137)
    at org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:113)
    at org.codehaus.groovy.runtime.memoize.Memoize$MemoizeFunction.call(Memoize.java:136)
    at nextflow.script.IncludeDef.loadModule0(IncludeDef.groovy)
    at nextflow.script.IncludeDef.load0(IncludeDef.groovy:123)
    at nextflow.script.IncludeDef$load0$1.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
    at Script_b1634edd947fcf7e.runScript(Script_b1634edd947fcf7e:12)
    at nextflow.script.BaseScript.run0(BaseScript.groovy:144)
    at nextflow.script.BaseScript.run(BaseScript.groovy:192)
    at nextflow.script.ScriptParser.runScript(ScriptParser.groovy:236)
    at nextflow.script.ScriptParser.runScript(ScriptParser.groovy:222)
    at nextflow.script.IncludeDef.memoizedMethodPriv$loadModule0PathMapSession(IncludeDef.groovy:151)
    at nextflow.script.IncludeDef.access$0(IncludeDef.groovy)
    at nextflow.script.IncludeDef$__clinit__closure2.doCall(IncludeDef.groovy)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:578)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:274)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1030)
    at groovy.lang.Closure.call(Closure.java:427)
    at org.codehaus.groovy.runtime.memoize.Memoize$MemoizeFunction.lambda$call$0(Memoize.java:137)
    at org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:137)
    at org.codehaus.groovy.runtime.memoize.ConcurrentCommonCache.getAndPut(ConcurrentCommonCache.java:113)
    at org.codehaus.groovy.runtime.memoize.Memoize$MemoizeFunction.call(Memoize.java:136)
    at nextflow.script.IncludeDef.loadModule0(IncludeDef.groovy)
    at nextflow.script.IncludeDef.load0(IncludeDef.groovy:123)
    at nextflow.script.IncludeDef$load0$1.call(Unknown Source)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
    at Script_e6212041ff99d3c1.runScript(Script_e6212041ff99d3c1:20)
    at nextflow.script.BaseScript.run0(BaseScript.groovy:144)
    at nextflow.script.BaseScript.run(BaseScript.groovy:192)
    at nextflow.script.ScriptParser.runScript(ScriptParser.groovy:236)
    at nextflow.script.ScriptRunner.run(ScriptRunner.groovy:242)
    at nextflow.script.ScriptRunner.execute(ScriptRunner.groovy:137)
    at nextflow.cli.CmdRun.run(CmdRun.groovy:372)
    at nextflow.cli.Launcher.run(Launcher.groovy:500)
    at nextflow.cli.Launcher.main(Launcher.groovy:672)
nvnieuwk commented 6 months ago

Have you tried deleting the cache?

rm -rf ~/.nextflow/plugins/nf-schema/
awgymer commented 6 months ago

Confirming I can recreate this error with a brand new install of nf-schema and the above steps.

Not clear exactly what the issue is, given validateParameters imports fine, and the import appears to work in the tests for the plugin.

I guess it may relate to the fact the method is defined with overloading (none of the other methods imported successfully are)

Tobiaspk commented 6 months ago

Have you tried deleting the cache?

rm -rf ~/.nextflow/plugins/nf-schema/

Removing cache did not fix this for me.

Confirming I can recreate this error with a brand new install of nf-schema and the above steps.

Not clear exactly what the issue is, given validateParameters imports fine, and the import appears to work in the tests for the plugin.

I guess it may relate to the fact the method is defined with overloading (none of the other methods imported successfully are)

Odd, validateParameters, paramsHelp, paramsSummaryMap all worked for me, even after rm cache.

nvnieuwk commented 6 months ago

What version of Nextflow are you using? What operating system are you using? What's the version of nf-core tools you used?

At first I would think this is some nextflow bug, but I'm not sure yet. I'll give it a try later

nvnieuwk commented 6 months ago

NVM, my last post :grin: all the answers are in your first message

nvnieuwk commented 6 months ago

I just tried the steps you laid out with a fresh install of nf-schema. I didn't get any issues with it :/. Can you point me to a repository where you have this issue?

awgymer commented 6 months ago

When you say a fresh install do you mean a manual install from source? Or letting NF pull it?

FWIW my setup used

Nextflow 23.10.1 Mac OS Sonoma (M1)

nvnieuwk commented 6 months ago

I deleted the cache and let Nextflow redownload it.

nvnieuwk commented 6 months ago

@Tobiaspk and @awgymer I managed to recreate the error using Nextflow version 23.10.1. I was using verion 24.02.0-edge in my test. Can you guys confirm on your end that it works on the newer edge releases?

nvnieuwk commented 6 months ago

After some additional testing I also managed to get it to work by converting all include statements to use nf-schema instead of nf-validation. So these should also be updated in subworkflows/nf-core/utils_nfvalidation_plugin and in your main pipeline workflow <pipelinename>.nf

awgymer commented 6 months ago

Ok I have a theory and a bit of testing has me believing I am correct but paging @bentsherman as a groovy/nextflow expert who can hopefully confirm.

All the following can be recreated with nextflow.config:

plugins {
    id 'nf-validation@1.1.3' // Validation of pipeline parameters and creation of an input channel from a sample sheet
    id 'nf-schema@2.0.0'
}

So here goes...

main_schema.nf

include { validateParameters; samplesheetToList } from 'plugin/nf-schema'

workflow {

    println "A test"

}

Ouput:

A test

main_validation.nf

include { validateParameters; fromSamplesheet } from 'plugin/nf-validation'

workflow {

    println "A test"

}

Output:

A test

main_schema_validation.nf

include { validateParameters; samplesheetToList } from 'plugin/nf-schema'
include { fromSamplesheet } from 'plugin/nf-validation'

workflow {

    println "A test"

}

Output:

ERROR ~ Extension 'fromSamplesheet' it isn't defined by plugin nf-validation

main_validation_schema.nf

include { fromSamplesheet } from 'plugin/nf-validation'
include { validateParameters; samplesheetToList } from 'plugin/nf-schema'

workflow {

    println "A test"

}

Output:

ERROR ~ Extension 'samplesheetToList' it isn't defined by plugin nf-schema

So the issue... 🥁

Both nf-schema and nf-validation have their actual plugin code under src/main/nextflow/validation and thus in the groovy code as nextflow.validation.

I am guessing that what happens is that both plugins are "loaded" but the compiled code of the first one loaded is what is actually available under both plugins.

This leads to this seemingly impossible successful include (remember samplesheetToList is not in nf-validation):

main_schema_validation_wrong_import.nf

include { validateParameters } from 'plugin/nf-schema'
include { samplesheetToList } from 'plugin/nf-validation'

workflow {

    println "A test"

}

Output:

ERROR ~ Extension 'samplesheetToList' it isn't defined by plugin nf-schema
nvnieuwk commented 6 months ago

Thank you for investigating! Does this issue still occur with the edge versions of Nextflow? (just curious :grin:)

awgymer commented 6 months ago

Seems like the issue is not present in 24.01

I am only able to do this surface level testing though so I am not clear what happens for methods that exist in both extensions e.g. validateParameters - whether the correct version for the plugin is installed or if that is yet another possible edge-case!

Will need someone more keyed in with nextflow (and the underlying changes in 24 vs 23 I guess) to explain further.

bentsherman commented 6 months ago

Nextflow was upgraded from Groovy 3 to 4 in 24.01.0-edge, which might have something to do with it. But the basic issue seems to be that both plugins are using the same namespace and have some conflicting extensions? I see they both have a validateParameters function

awgymer commented 6 months ago

Technically the issue isn't the conflicting extensions really (eg validateParamters). It's that they share a "code namespace" (nextflow.validation) whilst appearing to be unique namespaces to the naive user plugin/nf-schema vs plugin/nf-validation.

If nothing in the plugin arch has changed that would support this but the groovy 3->4 change is the cause of the conflict not occurring in edge it makes me even more concerned that it may only be a partial resolution or concealing more edge-cases/bugs?

bentsherman commented 6 months ago

Using the same namespace by itself isn't necessarily a problem, only if you have two classes with the same fully qualified name e.g. nextflow.validation.SchemaValidator.

At the same time, a major version bump like Groovy 3 -> 4 can bring many mysterious changes. If the issue went away in Groovy 4, maybe they improved something in the class loader which can handle the duplicate class names correctly.

nvnieuwk commented 3 weeks ago

Some additional checks have been implemented in nf-core version 3.0 that should prevent this from happening if your pipeline passes the linting checks.