diff --git a/modules/nextflow/src/main/groovy/nextflow/Session.groovy b/modules/nextflow/src/main/groovy/nextflow/Session.groovy index d45f26c528..2a640d0e23 100644 --- a/modules/nextflow/src/main/groovy/nextflow/Session.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/Session.groovy @@ -16,6 +16,8 @@ package nextflow +import nextflow.util.CacheHelper + import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths @@ -128,6 +130,11 @@ class Session implements ISession { */ boolean resumeMode + /** + * whenever it has been launched with globalCache + */ + boolean globalCache + /** * The folder where workflow outputs are stored */ @@ -358,6 +365,10 @@ class Session implements ISession { resumeMode = true uniqueId = UUID.fromString(config.resume as String) } + else if ( config.globalcache ){ + globalCache = true + uniqueId = UUID.nameUUIDFromBytes(CacheHelper.hasher(FileHelper.asPath(config.globalcache as String).normalize().toString()).hash().asBytes()) + } else { uniqueId = systemEnv.get('NXF_UUID') ? UUID.fromString(systemEnv.get('NXF_UUID')) : UUID.randomUUID() } diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy index d096e678e6..ce29864fff 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy @@ -121,6 +121,9 @@ class CmdRun extends CmdBase implements HubOptions { @Parameter(names=['-with-cloudcache'], description = 'Enable the use of object storage bucket as storage for cache meta-data') String cloudCachePath + @Parameter(names=['-with-globalcache'], description = 'Enable the use of a global cache meta-data') + String globalCachePath + /** * Defines the parameters to be passed to the pipeline script */ @@ -316,7 +319,12 @@ class CmdRun extends CmdBase implements HubOptions { if( offline && latest ) throw new AbortOperationException("Command line options `-latest` and `-offline` cannot be specified at the same time") - + if( globalCachePath && workDir ) + throw new AbortOperationException("Command line options `-with-globalcache` and `-workdir` cannot be specified at the same time. Global cache already set the 'workDir") + if( globalCachePath && cloudCachePath ) + throw new AbortOperationException("Command line options `-with-globalcache` and `-with-cloudcache` cannot be specified at the same time. Global cache already set the 'cloudcache'") + if( globalCachePath && resume ) + throw new AbortOperationException("Command line options `-with-globalCache` and `-resume` cannot be specified at the same time. '-resume' is implicitly activated in global cache runs") checkRunName() printBanner() diff --git a/modules/nextflow/src/main/groovy/nextflow/config/ConfigBuilder.groovy b/modules/nextflow/src/main/groovy/nextflow/config/ConfigBuilder.groovy index 0341f73523..23485c564e 100644 --- a/modules/nextflow/src/main/groovy/nextflow/config/ConfigBuilder.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/config/ConfigBuilder.groovy @@ -531,6 +531,12 @@ class ConfigBuilder { @PackageScope void configRunOptions(ConfigObject config, Map env, CmdRun cmdRun) { + if( cmdRun.globalCachePath ) { + log.warn("Enabling global cache. This will overwrite 'cloudcache' and 'workDir' parameters.") + config.globalcache = cmdRun.globalCachePath + cmdRun.workDir = "${cmdRun.globalCachePath}/work" + cmdRun.cloudCachePath = "${cmdRun.globalCachePath}/.nf-global-cache" + } // -- set config options if( cmdRun.cacheable != null ) config.cacheable = cmdRun.cacheable diff --git a/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy b/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy index c4860deaeb..7fec7879f2 100644 --- a/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy @@ -2418,7 +2418,7 @@ class TaskProcessor { } @PackageScope boolean isResumable() { - isCacheable() && session.resumeMode + isCacheable() && (session.resumeMode || session.globalCache) } /**