Skip to content

Commit

Permalink
Apply suggestions from review
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Sherman <[email protected]>
  • Loading branch information
bentsherman committed Dec 11, 2024
1 parent 53d6c61 commit e7aa3a7
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ class CmdInspect extends CmdBase {

@Override
void run() {
ContainerInspectMode.activate(!concretize)
ContainerInspectMode.activate(true)
ContainerInspectMode.concretize(concretize)
// configure quiet mode
LoggerHelper.setQuiet(true)
// setup the target run command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ContainerHandler {
if( normalizedImageName.startsWith('docker://') && config.canRunOciImage() )
return normalizedImageName
final requiresCaching = normalizedImageName =~ IMAGE_URL_PREFIX
if( ContainerInspectMode.active() && requiresCaching )
if( ContainerInspectMode.concretizeEnabled() && requiresCaching )
return imageName
final result = requiresCaching ? createSingularityCache(this.config, normalizedImageName) : normalizedImageName
return Escape.path(result)
Expand All @@ -82,7 +82,7 @@ class ContainerHandler {
if( normalizedImageName.startsWith('docker://') && config.canRunOciImage() )
return normalizedImageName
final requiresCaching = normalizedImageName =~ IMAGE_URL_PREFIX
if( ContainerInspectMode.active() && requiresCaching )
if( ContainerInspectMode.concretizeEnabled() && requiresCaching )
return imageName
final result = requiresCaching ? createApptainerCache(this.config, normalizedImageName) : normalizedImageName
return Escape.path(result)
Expand All @@ -94,7 +94,7 @@ class ContainerHandler {
// if the imagename starts with '/' it's an absolute path
// otherwise we assume it's in a remote registry and pull it from there
final requiresCaching = !imageName.startsWith('/')
if( ContainerInspectMode.active() && requiresCaching )
if( ContainerInspectMode.concretizeEnabled() && requiresCaching )
return imageName
final result = requiresCaching ? createCharliecloudCache(this.config, normalizedImageName) : normalizedImageName
return Escape.path(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,14 @@ class ContainerInspectMode {

private static Boolean active

private static Boolean concretize = true

static boolean active() { return active==true }

static void activate(boolean value) { active = value }

static boolean concretizeEnabled() { return concretize==true }

static void concretize(boolean value) { concretize = value }

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class ContainersInspector {
for( final process : ScriptMeta.allProcesses() ) {
try {
// get container preview
final task = process.getTaskProcessor().createTaskPreview()
final task = process.createTaskProcessor().createTaskPreview()
final containerName = task.getContainer()
containers[process.name] = containerName
if( containerName )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,14 @@ class ProcessDef extends BindableDef implements IterableDef, ChainableDef {
output = new ChannelOut(declaredOutputs.clone())

// start processor
getTaskProcessor().run()
createTaskProcessor().run()

// the result channels
assert declaredOutputs.size()>0, "Process output should contains at least one channel"
return output
}

TaskProcessor getTaskProcessor() {
TaskProcessor createTaskProcessor() {
if( !processConfig )
initialize()
final executor = session
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import groovy.transform.PackageScope
import groovy.util.logging.Slf4j
import nextflow.Global
import nextflow.Session
import nextflow.container.inspect.ContainerInspectMode
import nextflow.exception.AbortOperationException
import nextflow.exception.AbortRunException
import nextflow.plugin.Plugins
Expand Down Expand Up @@ -226,8 +227,8 @@ class ScriptRunner {
protected void parseScript( ScriptFile scriptFile, String entryName ) {
scriptParser = new ScriptParser(session)
scriptParser.setEntryName(entryName)
// don't execute entry workflow if preview action (i.e. inspect command) is specified
if( previewAction )
// don't execute entry workflow in the inspect command
if( ContainerInspectMode.acitve() )

Check failure on line 231 in modules/nextflow/src/main/groovy/nextflow/script/ScriptRunner.groovy

View workflow job for this annotation

GitHub Actions / Check for spelling errors

acitve ==> active
scriptParser.setModule(true)
scriptParser.parse(scriptFile.main)
session.script = scriptParser.script
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ContainersInspectorTest extends Specification {
}
final processDef = Mock(ProcessDef) {
getName() >> name
getTaskProcessor() >> Mock(TaskProcessor) {
createTaskProcessor() >> Mock(TaskProcessor) {
createTaskPreview() >> Mock(TaskRun) {
getContainer() >> container
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class WaveClient {
fingerprint: assets.fingerprint(),
freeze: config.freezeMode(),
format: assets.singularity ? 'sif' : null,
dryRun: ContainerInspectMode.active(),
dryRun: ContainerInspectMode.concretizeEnabled(),
mirror: config.mirrorMode(),
scanMode: config.scanMode(),
scanLevels: config.scanAllowedLevels()
Expand All @@ -249,7 +249,7 @@ class WaveClient {
towerEndpoint: tower.endpoint,
workflowId: tower.workflowId,
freeze: config.freezeMode(),
dryRun: ContainerInspectMode.active(),
dryRun: ContainerInspectMode.concretizeEnabled(),
mirror: config.mirrorMode(),
scanMode: config.scanMode(),
scanLevels: config.scanAllowedLevels()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ class WaveClientTest extends Specification {

def 'should create request object with dry-run mode' () {
given:
ContainerInspectMode.activate(true)
ContainerInspectMode.concretize(false)
def session = Mock(Session) { getConfig() >> [:]}
def IMAGE = 'foo:latest'
def wave = new WaveClient(session)
Expand All @@ -306,7 +306,7 @@ class WaveClientTest extends Specification {
req.timestamp instanceof String

cleanup:
ContainerInspectMode.activate(false)
ContainerInspectMode.concretize(true)
}

def 'should create request object and platform' () {
Expand Down

0 comments on commit e7aa3a7

Please sign in to comment.