Comments (7)
Did you check out each
and map
?
from piper.
Yes, each
doesn't sound like a loop
as it's done in parallel. map
is as maps are. next
type of functionality is what i need. Unless i am mistaken, none of the existing constructs seem to be able to do that.
from piper.
Maybe you can describe your use case.
from piper.
Use case is a usual programmatic flow.
Task 1 -> Task 2 (if condition then Task 5 else Task 3) -> Task 3 -> Task 4 -> End
\-> Task 5 -> Task 6 -> Task 7 (if condition then Task 3 else Task 5)
Basically depending on conditions I may want to either jump ahead some tasks or go back to a previous task in the flow. switch
allows me to do conditional branching but ability to alter flow by jumping to a task is missing.
From what i have understood so far, the DefaultTaskCompletionHandler handle()
gets the next task to execute. A simple approach would be to use a next
field to jump to a particular task
based on task id.
Any thoughts on this approach?
from piper.
That's the change basically, and seems to work. Of course, next
is working of internal task ids (starting with 0) and any change there would break this.
@@ -61,6 +61,7 @@ public class DefaultTaskCompletionHandler implements TaskCompletionHandler {
@Override
public void handle (TaskExecution aTask) {
log.debug("Completing task {}, {}", aTask.getId(), jobRepository.toString());
+ int next = aTask.getInteger("next", -1);
Job job = jobRepository.findJobByTaskId (aTask.getId());
if(job!=null) {
SimpleTaskExecution task = SimpleTaskExecution.createForUpdate(aTask);
@@ -74,7 +75,10 @@ public class DefaultTaskCompletionHandler implements TaskCompletionHandler {
contextRepository.push(job.getId(), newContext);
}
if(hasMoreTasks(mjob)) {
- mjob.setCurrentTask(mjob.getCurrentTask()+1);
+ if (next > 0)
+ mjob.setCurrentTask(next);
+ else
+ mjob.setCurrentTask(mjob.getCurrentTask()+1);
jobRepository.merge(mjob);
jobExecutor.execute(mjob);
}
The sample script
label: My Pipeline
inputs:
- name: name
type: string
required: true
tasks:
- label: Print a greeting
type: print
text: Hello ${name}
next: 2
- name: randomNumber
label: Generate a random number
type: randomInt
startInclusive: 0
endInclusive: 5000
next: 4
- name: randomNumber2
label: Generate a random number
type: randomInt
startInclusive: 5000
endInclusive: 15000
- label: Print a farewell
type: print
text: Is this task skipped ${name}
next: 1
- label: Print a farewell
type: print
text: Goodbye ${name}
from piper.
That looks a lot like a goto. Not something I'd want to introduce. Seems like an if/else support would be more suitable for what you're trying to do.
from piper.
switch
gives us if/else but doesn't give me the control I want. For now I will stick with my solution.
PS: just fyi, another flow control language is the Amazon state language, which does exactly the same with next
from piper.
Related Issues (20)
- Parallel task handler is executing tasks sequentially
- Fork/Join results not returning HOT 2
- Your first pipeline example does not work HOT 2
- Can I use BPMN with piper? HOT 4
- The Coordinator Shutsdown HOT 3
- Branch fork/join documentation issue HOT 3
- Switch not working as per document
- Application startup failed due to org.springframework.amqp.AmqpIOException: java.io.IOException HOT 5
- Logical control type support HOT 3
- Unknown pipeline: video/hls_single HOT 1
- Distributed computing issue when deployed on multiple nodes with kubernetes HOT 1
- How to get more then 20 items in jobs list HOT 2
- How to run project after importing in STS
- Docker setup help, Failed to obtain JDBC Connection HOT 2
- Resuming a task within switch executes all tasks in hierarchy of parent switch
- /scripts/build.sh fails two unit tests HOT 5
- two sequential events for same task are send to two different queues
- test issue HOT 1
- another test issue HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from piper.