Skip to content

Commit 6e825d5

Browse files
committed
Replace staged input file with original URL
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
1 parent ff0b211 commit 6e825d5

4 files changed

Lines changed: 26 additions & 46 deletions

File tree

src/main/groovy/nextflow/prov/renderers/BcoRenderer.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class BcoRenderer implements Renderer {
112112
"step_number": task.id,
113113
"name": task.hash.toString(),
114114
"description": task.name,
115-
"input_list": task.getInputFilesMap().collect { name, source -> [
115+
"input_list": ProvHelper.getTaskInputs(task).collect { name, source -> [
116116
"uri": normalizePath(source)
117117
] },
118118
"output_list": ProvHelper.getTaskOutputs(task).collect { source -> [

src/main/groovy/nextflow/prov/renderers/DagRenderer.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class DagRenderer implements Renderer {
6666
private Map<TaskRun,Vertex> getVertices(Set<TaskRun> tasks) {
6767
Map<TaskRun,Vertex> result = [:]
6868
for( final task : tasks ) {
69-
final inputs = task.getInputFilesMap()
69+
final inputs = ProvHelper.getTaskInputs(task)
7070
final outputs = ProvHelper.getTaskOutputs(task)
7171

7272
result[task] = new Vertex(result.size(), task.name, inputs, outputs)

src/main/groovy/nextflow/prov/renderers/WrrocRenderer.groovy

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class WrrocRenderer implements Renderer {
230230

231231
final inputFiles = workflowInputs
232232
.findAll { source ->
233-
!ProvHelper.isStagedInput(source, session) && !ProvHelper.isTmpInput(source, session)
233+
!ProvHelper.isTmpInput(source, session)
234234
}
235235
.collect { source ->
236236
final paramName = paramInputFiles[source]
@@ -390,19 +390,6 @@ class WrrocRenderer implements Renderer {
390390
}
391391

392392
// -- workflow execution
393-
final stagedInputs = workflowInputs
394-
.findAll { source -> ProvHelper.isStagedInput(source, session) }
395-
.collect { source ->
396-
final name = getStagedInputName(source, session)
397-
398-
withoutNulls([
399-
"@id" : "#stage/${name}",
400-
"@type" : "CreativeWork",
401-
"name" : name,
402-
"encodingFormat": getEncodingFormat(source),
403-
])
404-
}
405-
406393
final tmpInputs = workflowInputs
407394
.findAll { source -> ProvHelper.isTmpInput(source, session) }
408395
.collect { source ->
@@ -417,10 +404,9 @@ class WrrocRenderer implements Renderer {
417404
final taskCreateActions = tasks
418405
.collect { task ->
419406
final processDef = processLookup[task.processor]
420-
final inputs = task.getInputFilesMap().collect { name, source ->
407+
final inputs = ProvHelper.getTaskInputs(task).collect { name, source ->
421408
final id =
422409
source in taskLookup ? getTaskOutputId(taskLookup[source], source)
423-
: ProvHelper.isStagedInput(source, session) ? "#stage/${getStagedInputName(source, session)}"
424410
: ProvHelper.isTmpInput(source, session) ? "#tmp/${source.name}"
425411
: normalizePath(source)
426412
["@id": id]
@@ -507,7 +493,6 @@ class WrrocRenderer implements Renderer {
507493
"mainEntity" : ["@id": mainScriptId],
508494
"mentions" : [
509495
["@id": "#${session.uniqueId}"],
510-
*asReferences(stagedInputs),
511496
*asReferences(tmpInputs),
512497
*asReferences(taskCreateActions),
513498
*asReferences(taskOutputs),
@@ -608,7 +593,6 @@ class WrrocRenderer implements Renderer {
608593
*datasetParts,
609594
*propertyValues,
610595
*controlActions,
611-
*stagedInputs,
612596
*tmpInputs,
613597
*taskCreateActions,
614598
*taskOutputs,

src/main/groovy/nextflow/prov/util/ProvHelper.groovy

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package nextflow.prov.util
1818

1919
import java.nio.file.Path
20+
import java.util.stream.Collectors
2021

2122
import groovy.transform.CompileStatic
2223
import nextflow.Session
@@ -59,6 +60,20 @@ class ProvHelper {
5960
return session.workDir.resolve("stage-${session.uniqueId}")
6061
}
6162

63+
/**
64+
* Get the input files for a task as a mapping from stage name to source path.
65+
*
66+
* @param task
67+
*/
68+
static Map<String,Path> getTaskInputs(TaskRun task) {
69+
final entries = task.getInputFiles().values().stream()
70+
.filter(files -> files != null)
71+
.flatMap(files -> files.stream())
72+
.map(holder -> Map.entry(holder.getStageName(), holder.getSourcePath()))
73+
.toList() as Map.Entry<String,Path>[]
74+
return Map.ofEntries(entries)
75+
}
76+
6277
/**
6378
* Get the list of output files for a task.
6479
*
@@ -77,12 +92,11 @@ class ProvHelper {
7792
* @param tasks
7893
*/
7994
static Map<Path,TaskRun> getTaskLookup(Set<TaskRun> tasks) {
80-
final result = [:] as Map<Path,TaskRun>
81-
82-
for( def task : tasks )
95+
final Map<Path,TaskRun> result = [:]
96+
for( def task : tasks ) {
8397
for( def output : getTaskOutputs(task) )
8498
result[output] = task
85-
99+
}
86100
return result
87101
}
88102

@@ -94,28 +108,10 @@ class ProvHelper {
94108
* @param taskLookup
95109
*/
96110
static Set<Path> getWorkflowInputs(Set<TaskRun> tasks, Map<Path,TaskRun> taskLookup) {
97-
final result = [] as Set<Path>
98-
99-
tasks.each { task ->
100-
task.getInputFilesMap().each { name, path ->
101-
if( taskLookup[path] )
102-
return
103-
104-
result << path
105-
}
106-
}
107-
108-
return result
109-
}
110-
111-
/**
112-
* Determine whether a task input file was staged into the work directory.
113-
*
114-
* @param source
115-
* @param session
116-
*/
117-
static boolean isStagedInput(Path source, Session session) {
118-
return source.startsWith(getStageDir(session))
111+
return tasks.stream()
112+
.flatMap(task -> getTaskInputs(task).values().stream())
113+
.filter(path -> !taskLookup[path])
114+
.collect(Collectors.toSet())
119115
}
120116

121117
/**

0 commit comments

Comments
 (0)