Skip to content

Commit 1bd7b4a

Browse files
committed
Remove deprecated workflow publish [DSL2]
1 parent 6b655b1 commit 1bd7b4a

File tree

5 files changed

+4
-95
lines changed

5 files changed

+4
-95
lines changed

modules/nextflow/src/main/groovy/nextflow/ast/NextflowDSLImpl.groovy

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,10 @@ class NextflowDSLImpl implements ASTTransformation {
108108
static class DslCodeVisitor extends ClassCodeVisitorSupport {
109109

110110
@Deprecated final static String WORKFLOW_GET = 'get'
111+
@Deprecated final static String WORKFLOW_PUBLISH = 'publish'
111112
final static String WORKFLOW_TAKE = 'take'
112113
final static String WORKFLOW_EMIT = 'emit'
113114
final static String WORKFLOW_MAIN = 'main'
114-
@Deprecated final static String WORKFLOW_PUBLISH = 'publish'
115115

116116
final static Random RND = new Random()
117117

@@ -415,10 +415,6 @@ class NextflowDSLImpl implements ASTTransformation {
415415
return createAssignX(stat, body, type, uniqueNames)
416416
}
417417

418-
if( type == WORKFLOW_PUBLISH ) {
419-
return createAssignX(stat, body, type, uniqueNames)
420-
}
421-
422418
syntaxError(stat, "Workflow malformed parameter definition")
423419
return stat
424420
}
@@ -509,9 +505,7 @@ class NextflowDSLImpl implements ASTTransformation {
509505
syntaxError(stm, "Workflow 'get' is not supported anymore use 'take' instead")
510506

511507
case WORKFLOW_PUBLISH:
512-
if( !anonymous ) {
513-
syntaxError(stm, "Publish declaration is only allowed in main workflow definition")
514-
}
508+
syntaxError(stm, "Workflow 'publish' is not supported anymore use process 'publishDir' instead")
515509

516510
case WORKFLOW_TAKE:
517511
case WORKFLOW_EMIT:

modules/nextflow/src/main/groovy/nextflow/script/WorkflowDef.groovy

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import groovyx.gpars.dataflow.DataflowWriteChannel
2323
import nextflow.exception.MissingValueException
2424
import nextflow.exception.ScriptRuntimeException
2525
import nextflow.extension.CH
26-
import nextflow.extension.PublishOp
27-
2826
/**
2927
* Models a script workflow component
3028
*
@@ -42,8 +40,6 @@ class WorkflowDef extends BindableDef implements ChainableDef, ExecutionContext
4240

4341
private List<String> declaredOutputs
4442

45-
private Map<String,Map> declaredPublish
46-
4743
private Set<String> variableNames
4844

4945
private BaseScript owner
@@ -67,7 +63,6 @@ class WorkflowDef extends BindableDef implements ChainableDef, ExecutionContext
6763
// now it can access the parameters
6864
this.declaredInputs = new ArrayList<>(resolver.getTakes().keySet())
6965
this.declaredOutputs = new ArrayList<>(resolver.getEmits().keySet())
70-
this.declaredPublish = new LinkedHashMap<>(resolver.getPublish())
7166
this.variableNames = getVarNames0()
7267
}
7368

@@ -164,29 +159,7 @@ class WorkflowDef extends BindableDef implements ChainableDef, ExecutionContext
164159
}
165160
return new ChannelOut(channels)
166161
}
167-
168-
protected publishOutputs(Map<String,Map> publishDefs) {
169-
for( Map.Entry<String,Map> pub : publishDefs.entrySet() ) {
170-
final name = pub.key
171-
final opts = pub.value
172-
if( !binding.hasVariable(name) )
173-
throw new MissingValueException("Missing workflow publish parameter: $name")
174-
final obj = binding.getVariable(name)
175-
176-
if( CH.isChannel(obj) ) {
177-
new PublishOp(CH.getReadChannel(obj), opts).apply()
178-
}
179-
180-
else if( obj instanceof ChannelOut ) {
181-
for( DataflowWriteChannel ch : ((ChannelOut)obj) ) {
182-
new PublishOp(CH.getReadChannel(ch), opts).apply()
183-
}
184-
}
185-
186-
else throw new IllegalArgumentException("Illegal workflow publish parameter: $name value: $obj")
187-
}
188-
}
189-
162+
190163

191164
Object run(Object[] args) {
192165
binding = new WorkflowBinding(owner)
@@ -208,7 +181,6 @@ class WorkflowDef extends BindableDef implements ChainableDef, ExecutionContext
208181
closure.call()
209182
// collect the workflow outputs
210183
output = collectOutputs(declaredOutputs)
211-
publishOutputs(declaredPublish)
212184
return output
213185
}
214186

@@ -223,12 +195,10 @@ class WorkflowParamsResolver implements GroovyInterceptable {
223195

224196
static final private String TAKE_PREFIX = '_take_'
225197
static final private String EMIT_PREFIX = '_emit_'
226-
@Deprecated static final private String PUBLISH_PREFIX = '_publish_'
227198

228199

229200
Map<String,Object> takes = new LinkedHashMap<>(10)
230201
Map<String,Object> emits = new LinkedHashMap<>(10)
231-
Map<String,Map> publish = new LinkedHashMap<>(10)
232202

233203
@Override
234204
def invokeMethod(String name, Object args) {
@@ -238,14 +208,8 @@ class WorkflowParamsResolver implements GroovyInterceptable {
238208
else if( name.startsWith(EMIT_PREFIX) )
239209
emits.put(name.substring(EMIT_PREFIX.size()), args)
240210

241-
else if( name.startsWith(PUBLISH_PREFIX)) {
242-
log.warn1 "Workflow `publish` is deprecated -- Use process directive `publishDir` instead"
243-
publish.put(name.substring(PUBLISH_PREFIX.size()), argToPublishOpts(args))
244-
}
245-
246211
else
247212
throw new MissingMethodException(name, WorkflowDef, args)
248-
249213
}
250214

251215
private Map argsToMap(Object args) {

modules/nextflow/src/test/groovy/nextflow/script/WorkflowDefTest.groovy

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,8 @@ class WorkflowDefTest extends Dsl2Spec {
183183

184184
when:
185185
def script = (TestScript)new GroovyShell(new ScriptBinding(), config).parse(SCRIPT).run()
186-
def meta = ScriptMeta.get(script)
187186
then:
188-
meta.definitions.size() == 1
189-
meta.getWorkflow(null) .declaredInputs == []
190-
meta.getWorkflow(null) .declaredVariables == ['baz.out', 'x', '$out0']
191-
meta.getWorkflow(null) .getDeclaredPublish() == [foo: [:], bar: [to:'some/path'], '$out0': [to:'other/path']]
187+
thrown(MultipleCompilationErrorsException)
192188
}
193189

194190
def 'should not allow publish is sub-workflow' () {

tests/checks/workflow-publish-dsl2.nf/.checks

Lines changed: 0 additions & 15 deletions
This file was deleted.

tests/workflow-publish-dsl2.nf

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)