Skip to content

Commit 0faaf13

Browse files
committed
Move PluginExecAware to nextflow module
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
1 parent c537b68 commit 0faaf13

File tree

10 files changed

+38
-35
lines changed

10 files changed

+38
-35
lines changed

modules/nf-cli-v1/src/main/groovy/nextflow/cli/PluginAbstractExec.groovy renamed to modules/nextflow/src/main/groovy/nextflow/plugin/cli/PluginAbstractExec.groovy

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@
1515
*
1616
*/
1717

18-
package nextflow.cli
19-
20-
import java.nio.file.Paths
18+
package nextflow.plugin.cli
2119

2220
import groovy.transform.CompileStatic
2321
import nextflow.Session
24-
import nextflow.config.ConfigCmdAdapter
22+
import nextflow.SysEnv
2523
import nextflow.exception.AbortOperationException
2624
import org.slf4j.Logger
2725
import org.slf4j.LoggerFactory
26+
2827
import static PluginExecAware.CMD_SEP
2928

3029
/**
@@ -38,23 +37,13 @@ trait PluginAbstractExec implements PluginExecAware {
3837
private static Logger log = LoggerFactory.getLogger(PluginAbstractExec)
3938

4039
private Session session
41-
private Launcher launcher
4240

4341
Session getSession() { session }
4442

45-
Launcher getLauncher() { launcher }
46-
4743
abstract List<String> getCommands()
4844

4945
@Override
50-
final int exec(Launcher launcher1, String pluginId, String cmd, List<String> args) {
51-
this.launcher = launcher1
52-
// create the config
53-
final config = new ConfigCmdAdapter()
54-
.setOptions(launcher1.options)
55-
.setBaseDir(Paths.get('.'))
56-
.build()
57-
46+
final int exec(String pluginId, String cmd, List<String> args) {
5847
if( !cmd || cmd !in getCommands() ) {
5948
def msg = cmd ? "Invalid command '$pluginId:$cmd' - usage: nextflow plugin ${pluginId}${CMD_SEP}<command>" : "Usage: nextflow plugin ${pluginId}${CMD_SEP}<command>"
6049
msg += "\nAvailable commands:"
@@ -64,7 +53,8 @@ trait PluginAbstractExec implements PluginExecAware {
6453
}
6554

6655
// create the session object
67-
this.session = new Session(config)
56+
this.session = new Session(getConfig())
57+
6858
// invoke the command
6959
try {
7060
exec(cmd, args)
@@ -78,7 +68,16 @@ trait PluginAbstractExec implements PluginExecAware {
7868
return 0
7969
}
8070

81-
abstract int exec(String cmd, List<String> args)
71+
private Map getConfig() {
72+
final result = [
73+
workDir: SysEnv.get('NXF_WORK') ?: 'work'
74+
]
75+
final cloudCachePath = SysEnv.get('NXF_CLOUDCACHE_PATH')
76+
if( cloudCachePath )
77+
result.cloudcache = [ enabled: true, path: cloudCachePath ]
78+
return result
79+
}
8280

81+
abstract int exec(String cmd, List<String> args)
8382

8483
}

modules/nf-cli-v1/src/main/groovy/nextflow/cli/PluginExecAware.groovy renamed to modules/nextflow/src/main/groovy/nextflow/plugin/cli/PluginExecAware.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*/
1717

18-
package nextflow.cli
18+
package nextflow.plugin.cli
1919

2020
/**
2121
* Define the interface for plugin commands
@@ -26,6 +26,6 @@ interface PluginExecAware {
2626

2727
static final String CMD_SEP = ':'
2828

29-
int exec(Launcher launcher, String pluginId, String cmd, List<String> args)
29+
int exec(String pluginId, String cmd, List<String> args)
3030

3131
}

modules/nf-cli-v1/src/main/groovy/nextflow/cli/CmdPlugin.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
package nextflow.cli
1919

20-
import static nextflow.cli.PluginExecAware.CMD_SEP
21-
2220
import java.nio.file.Path
2321

2422
import com.beust.jcommander.DynamicParameter
@@ -27,8 +25,11 @@ import com.beust.jcommander.Parameters
2725
import groovy.transform.CompileStatic
2826
import nextflow.exception.AbortOperationException
2927
import nextflow.plugin.Plugins
28+
import nextflow.plugin.cli.PluginExecAware
3029
import nextflow.plugin.util.PluginRefactor
3130
import org.eclipse.jgit.api.Git
31+
32+
import static nextflow.plugin.cli.PluginExecAware.CMD_SEP
3233
/**
3334
* Plugin manager command
3435
*
@@ -86,7 +87,7 @@ class CmdPlugin extends CmdBase {
8687
mapped << "$it.value".toString()
8788
}
8889
args.addAll(mapped)
89-
final ret = plugin.exec(getLauncher(), target, cmd, args)
90+
final ret = plugin.exec(target, cmd, args)
9091
// use explicit exit to invoke the system shutdown hooks
9192
System.exit(ret)
9293
}

modules/nf-cli-v1/src/main/groovy/nextflow/config/ConfigCmdAdapter.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ class ConfigCmdAdapter {
352352
if( cmdRun.libPath )
353353
config.libDir = cmdRun.libPath
354354

355-
else if ( !config.isSet('libDir') && env.get('NXF_LIB') )
355+
else if ( !config.libDir && env.get('NXF_LIB') )
356356
config.libDir = env.get('NXF_LIB')
357357

358358
// -- override 'process' parameters defined on the cmd line

plugins/nf-tower/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ configurations {
2929
}
3030

3131
dependencies {
32-
compileOnly project(':nf-cli-v1')
32+
compileOnly project(':nextflow')
3333
compileOnly 'org.slf4j:slf4j-api:2.0.17'
3434
compileOnly 'org.pf4j:pf4j:3.12.0'
3535

plugins/nf-tower/src/main/io/seqera/tower/plugin/CacheCommand.groovy

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ package io.seqera.tower.plugin
1919

2020
import groovy.transform.CompileStatic
2121
import groovy.util.logging.Slf4j
22-
import nextflow.cli.PluginAbstractExec
22+
import nextflow.plugin.cli.PluginAbstractExec
2323
/**
2424
* Implements nextflow cache and restore commands
2525
*
@@ -44,20 +44,22 @@ class CacheCommand implements PluginAbstractExec {
4444

4545
protected void cacheBackup() {
4646
log.debug "Running Nextflow cache backup"
47-
if( !getSession().cloudCachePath ) {
47+
final env = System.getenv()
48+
if( !env.get('NXF_CLOUDCACHE_PATH') ) {
4849
// legacy cache manager
49-
new CacheManager(System.getenv()).saveCacheFiles()
50+
new CacheManager(env).saveCacheFiles()
5051
}
5152
else {
52-
new LogsHandler(getSession(), System.getenv()).saveFiles()
53+
new LogsHandler(getSession(), env).saveFiles()
5354
}
5455
}
5556

5657
protected void cacheRestore() {
57-
if( !getSession().cloudCachePath ) {
58+
final env = System.getenv()
59+
if( !env.get('NXF_CLOUDCACHE_PATH') ) {
5860
log.debug "Running Nextflow cache restore"
5961
// legacy cache manager
60-
new CacheManager(System.getenv()).restoreCacheFiles()
62+
new CacheManager(env).restoreCacheFiles()
6163
}
6264
else {
6365
// this command is only kept for backward compatibility

plugins/nf-tower/src/main/io/seqera/tower/plugin/TowerPlugin.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package io.seqera.tower.plugin
2020
import groovy.transform.CompileStatic
2121
import groovy.util.logging.Slf4j
2222
import nextflow.plugin.BasePlugin
23-
import nextflow.cli.PluginExecAware
23+
import nextflow.plugin.cli.PluginExecAware
2424
import org.pf4j.PluginWrapper
2525
/**
2626
* Seqera Platform plugin
@@ -31,7 +31,8 @@ import org.pf4j.PluginWrapper
3131
@CompileStatic
3232
class TowerPlugin extends BasePlugin implements PluginExecAware {
3333

34-
@Delegate private CacheCommand delegate
34+
@Delegate
35+
private CacheCommand delegate
3536

3637
TowerPlugin(PluginWrapper wrapper) {
3738
super(wrapper)

plugins/nf-wave/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ configurations {
2929
}
3030

3131
dependencies {
32-
compileOnly project(':nf-cli-v1')
32+
compileOnly project(':nextflow')
3333
compileOnly 'org.slf4j:slf4j-api:2.0.17'
3434
compileOnly 'org.pf4j:pf4j:3.12.0'
3535
compileOnly 'io.seqera:lib-trace:0.1.0'

plugins/nf-wave/src/main/io/seqera/wave/plugin/WavePlugin.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
package io.seqera.wave.plugin
1919

2020
import io.seqera.wave.plugin.cli.WaveCmdEntry
21-
import nextflow.cli.PluginExecAware
2221
import nextflow.plugin.BasePlugin
22+
import nextflow.plugin.cli.PluginExecAware
2323
import org.pf4j.PluginWrapper
2424
/**
2525
* Wave plugin entrypoint

plugins/nf-wave/src/main/io/seqera/wave/plugin/cli/WaveCmdEntry.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ import groovy.util.logging.Slf4j
2626
import io.seqera.wave.plugin.ContainerConfig
2727
import io.seqera.wave.plugin.packer.Packer
2828
import io.seqera.wave.plugin.util.BasicCliOpts
29-
import nextflow.cli.PluginAbstractExec
3029
import nextflow.exception.AbortOperationException
3130
import nextflow.io.BucketParser
31+
import nextflow.plugin.cli.PluginAbstractExec
3232
/**
3333
* Implements Wave CLI tool
3434
*

0 commit comments

Comments
 (0)