Skip to content
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

Include all processes in inspect command #5580

Merged
merged 8 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class CmdInspect extends CmdBase {

protected void applyInspect(Session session) {
// run the inspector
new ContainersInspector(session.dag, concretize)
new ContainersInspector(concretize)
.withFormat(format)
.withIgnoreErrors(ignoreErrors)
.printContainers()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import groovy.json.JsonBuilder
import groovy.json.JsonOutput
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import nextflow.dag.DAG
import nextflow.exception.AbortOperationException
import nextflow.processor.TaskRun
import nextflow.script.ScriptMeta
import org.codehaus.groovy.util.ListHashMap
/**
* Preview the list of containers used by a pipeline.
Expand All @@ -37,16 +37,13 @@ import org.codehaus.groovy.util.ListHashMap
@CompileStatic
class ContainersInspector {

private DAG dag

private String format

private boolean ignoreErrors

private boolean concretize

ContainersInspector(DAG dag, boolean concretize) {
this.dag = dag
ContainersInspector(boolean concretize) {
this.concretize = concretize
}

Expand Down Expand Up @@ -83,15 +80,10 @@ class ContainersInspector {
final containers = new ListHashMap<String,String>()

List<TaskRun> tasks = new ArrayList<>()
for( def vertex : dag.vertices ) {
// skip nodes that are not processes
final process = vertex.process
if( !process )
continue

for( final process : ScriptMeta.allProcesses() ) {
try {
// get container preview
final task = process.createTaskPreview()
final task = process.getTaskProcessor().createTaskPreview()
final containerName = task.getContainer()
containers[process.name] = containerName
if( containerName )
Expand Down
24 changes: 14 additions & 10 deletions modules/nextflow/src/main/groovy/nextflow/script/ProcessDef.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import nextflow.Global
import nextflow.Session
import nextflow.exception.ScriptRuntimeException
import nextflow.extension.CH
import nextflow.processor.TaskProcessor
import nextflow.script.params.BaseInParam
import nextflow.script.params.BaseOutParam
import nextflow.script.params.EachInParam
Expand Down Expand Up @@ -208,20 +209,23 @@ class ProcessDef extends BindableDef implements IterableDef, ChainableDef {
// make a copy of the output list because execution can change it
output = new ChannelOut(declaredOutputs.clone())

// create the executor
final executor = session
.executorFactory
.getExecutor(processName, processConfig, taskBody, session)

// create processor class
session
.newProcessFactory(owner)
.newTaskProcessor(processName, executor, processConfig, taskBody)
.run()
// start processor
getTaskProcessor().run()

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

TaskProcessor getTaskProcessor() {
bentsherman marked this conversation as resolved.
Show resolved Hide resolved
if( !processConfig )
initialize()
final executor = session
.executorFactory
.getExecutor(processName, processConfig, taskBody, session)
return session
.newProcessFactory(owner)
.newTaskProcessor(processName, executor, processConfig, taskBody)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ class ScriptMeta {
return result
}

static Set<ProcessDef> allProcesses() {
final result = new HashSet()
for( final entry : REGISTRY.values() ) {
final processes = entry.getDefinitions().findAll { d -> d instanceof ProcessDef }
result.addAll(processes)
}
return result
}

static void addResolvedName(String name) {
resolvedProcessNames.add(name)
}
Expand Down
Loading