Skip to content

POC: Global Cache #6100

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions modules/nextflow/src/main/groovy/nextflow/Session.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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()
}
Expand Down
10 changes: 9 additions & 1 deletion modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2418,7 +2418,7 @@ class TaskProcessor {
}

@PackageScope boolean isResumable() {
isCacheable() && session.resumeMode
isCacheable() && (session.resumeMode || session.globalCache)
}

/**
Expand Down
Loading