Skip to content
Snippets Groups Projects
Commit d8e86f0b authored by Ivan Kondov's avatar Ivan Kondov
Browse files

re-checked the demos, created yaml of demos, renamed the files, rewrote print_func

parent 11ece075
No related branches found
No related tags found
No related merge requests found
{
"name": "Store and retrieve files",
"fws": [
{
"fw_id": 1,
"name": "Store a file to FilePad",
"spec": {
"_tasks": [
{
"_fw_name": "DeleteFilesTask",
"identifiers": ["gridka-school-fireworks/testing/wf.dot"]
},
{
"_fw_name": "AddFilesTask",
"paths": ["wf.dot"],
"identifiers": ["gridka-school-fireworks/testing/wf.dot"]
}
]
}
},
{
"fw_id": 2,
"name": "Retrieve a file from FilePad",
"spec": {
"_tasks": [
{
"_fw_name": "GetFilesTask",
"identifiers": ["gridka-school-fireworks/testing/wf.dot"]
}
]
}
}
],
"links": {
"1": [
2
],
"2": []
},
"metadata": {}
}
......@@ -28,7 +28,7 @@
}
],
"input string": {
"type": "string",
"type": "data",
"value": "Hello world!"
}
}
......
fws:
- fw_id: 1
name: Run a command and store the result
spec:
_tasks:
- _fw_name: CommandLineTask
command_spec:
command: [echo]
input string: {source: input string}
output file:
source: {type: stdout}
target: {type: path, value: /tmp}
inputs: [input string]
outputs: [output file]
input string: {type: data, value: Hello world!}
links: {}
metadata: {}
name: CommandLineTask demo
......@@ -18,7 +18,7 @@
"separator": "="
},
"source": {
"type": "string",
"type": "data",
"value": "second"
}
},
......@@ -58,7 +58,7 @@
"type": "stdout"
},
"target": {
"type": "string"
"type": "data"
}
}
}
......@@ -78,7 +78,7 @@
},
"new file": {
"source": {
"type": "string",
"type": "data",
"value": "new_file"
}
}
......@@ -88,6 +88,6 @@
}
}
],
"links": { "1": [2], "2": []},
"links": {"1": [2], "2": []},
"metadata": {}
}
fws:
- fw_id: 1
name: Run a command and store the result
spec:
_tasks:
- _fw_name: CommandLineTask
command_spec:
command: [date]
date option:
binding: {prefix: --iso, separator: '='}
source: {type: data, value: second}
time stamp file:
source: {type: stdout}
target: {type: path, value: /tmp}
inputs: [date option]
outputs: [time stamp file]
- fw_id: 2
name: Run a command with the result of the parent firework
spec:
_tasks:
- _fw_name: CommandLineTask
command_spec:
command: [cat]
time stamp file:
source: time stamp file
target: {type: stdin}
time stamp string:
source: {type: stdout}
target: {type: data}
inputs: [time stamp file]
outputs: [time stamp string]
- _fw_name: CommandLineTask
command_spec:
command: [touch]
new file:
source: {type: data, value: new_file}
time stamp:
binding: {prefix: --date, separator: '='}
source: time stamp string
inputs: [time stamp, new file]
outputs: []
links:
'1': [2]
'2': []
metadata: {}
name: CommandLineTask demo
File moved
{
"fws": [
{
"fw_id": 1,
"name": "Mill coffee",
"spec": {
"_tasks": [
{
"_fw_name": "ForeachTask",
"task": {
"_fw_name": "PythonFunctionTask",
"function": "auxiliary.print_func",
"inputs": ["coffee beans"],
"outputs": "coffee powder"
},
"split": "coffee beans"
}
],
"coffee beans": ["arabica", "robusta", "liberica"]
}
},
{
"fw_id": 2,
"name": "Brew coffee",
"spec": {
"_tasks": [
{
"_fw_name": "ForeachTask",
"task": {
"_fw_name": "PythonFunctionTask",
"function": "auxiliary.print_func",
"inputs": ["coffee powder", "water"],
"outputs": "pure coffee"
},
"split": "coffee powder"
}
],
"water": "workflowing water"
}
},
{
"fw_id": 3,
"name": "Serve coffee",
"spec": {
"_tasks": [
{
"_fw_name": "PythonFunctionTask",
"function": "auxiliary.print_func",
"inputs": ["pure coffee"]
}
]
}
}
],
"links": {
"1": [
2
],
"2": [
3
]
},
"metadata": {},
"name": "Workflow for many sorts of coffee"
}
fws:
- fw_id: 1
name: Mill coffee
spec:
_tasks:
- _fw_name: ForeachTask
split: coffee beans
task:
_fw_name: PythonFunctionTask
function: auxiliary.print_func
inputs: [coffee beans]
outputs: coffee powder
coffee beans: [arabica, robusta, liberica]
- fw_id: 2
name: Brew coffee
spec:
_tasks:
- _fw_name: ForeachTask
split: coffee powder
task:
_fw_name: PythonFunctionTask
function: auxiliary.print_func
inputs: [coffee powder, water]
outputs: pure coffee
water: workflowing water
- fw_id: 3
name: Serve coffee
spec:
_tasks:
- _fw_name: PythonFunctionTask
function: auxiliary.print_func
inputs: [pure coffee]
links:
'1': [2]
'2': [3]
metadata: {}
name: Workflow for many sorts of coffee
File moved
fws:
- fw_id: 1
name: Foreach task demo
spec:
_tasks:
- _fw_name: ForeachTask
split: array input
task:
_fw_name: CommandLineTask
command_spec:
array input: array input
command: [echo]
file set:
source: {type: stdout}
target: {type: path, value: /tmp}
inputs: [array input]
outputs: [file set]
array input:
- source: {type: data, value: 1}
- source: {type: data, value: string}
- fw_id: 2
name: Concatenate the files into a string
spec:
_tasks:
- _fw_name: PythonFunctionTask
function: auxiliary.print_func
inputs: [file set]
- _fw_name: CommandLineTask
command_spec:
command: [cat]
file set: file set
stdout dump:
source: {type: stdout}
target: {type: data, value: stdout dump}
inputs: [file set]
outputs: [stdout dump]
- _fw_name: PythonFunctionTask
function: auxiliary.print_func
inputs: [stdout dump]
links:
'1': [2]
metadata: {}
name: A more complex workflow
{
"fws": [
{
"fw_id": 1,
"name": "Foreach task demo",
"spec": {
"_tasks": [
{
"_fw_name": "ForeachTask",
"task": {
"_fw_name": "PythonFunctionTask",
"function": "auxiliary.print_func",
"inputs": "array",
"outputs": "new array"
},
"split": "array"
}
],
"array": [
1,
"string",
{
"number": "three"
}
]
}
},
{
"fw_id": 2,
"name": "Firework with two tasks: a ScriptTask and a PythonFunctionTask",
"spec": {
"_tasks": [
{
"_fw_name": "ScriptTask",
"script": [
"echo \"The combined result of all parent fireworks:\""
]
},
{
"_fw_name": "PythonFunctionTask",
"function": "auxiliary.print_func",
"inputs": [
"new array",
"optional"
],
"output": "outputs"
}
],
"optional": "blah"
}
}
],
"links": {
"1": [
2
],
"2": []
},
"metadata": {},
"name": "A more complex workflow"
}
{
"fws": [
{
"fw_id": 1,
"name": "Mill coffee",
"spec": {
"_tasks": [
{
"_fw_name": "PythonFunctionTask",
"function": "auxiliary.print_func",
"inputs": ["coffee beans"],
"outputs": "coffee powder"
}
],
"coffee beans": "well roasted"
}
},
{
"fw_id": 2,
"name": "Brew coffee",
"spec": {
"_tasks": [
{
"_fw_name": "PythonFunctionTask",
"function": "auxiliary.print_func",
"inputs": ["coffee powder", "water"],
"outputs": "pure coffee"
}
],
"water": "workflowing water"
}
},
{
"fw_id": 3,
"name": "Add extras",
"spec": {
"_tasks": [
{
"_fw_name": "PythonFunctionTask",
"function": "auxiliary.print_func",
"inputs": ["pure coffee", "milk"],
"outputs": "cappuccino"
}
],
"milk": "milky way milk"
}
}
],
"links": {
"1": [2],
"2": [3]
},
"metadata": {},
"name": "The coffee workflow"
}
fws:
- fw_id: 1
name: Mill coffee
spec:
_tasks:
- _fw_name: PythonFunctionTask
function: auxiliary.print_func
inputs: [coffee beans]
outputs: coffee powder
coffee beans: well roasted
- fw_id: 2
name: Brew coffee
spec:
_tasks:
- _fw_name: PythonFunctionTask
function: auxiliary.print_func
inputs: [coffee powder, water]
outputs: pure coffee
water: workflowing water
- fw_id: 3
name: Add extras
spec:
_tasks:
- _fw_name: PythonFunctionTask
function: auxiliary.print_func
inputs: [pure coffee, milk]
outputs: cappuccino
milk: milky way milk
links:
'1': [2]
'2': [3]
metadata: {}
name: The coffee workflow
def print_func(array=None):
print(array)
return array
def print_func(*args):
result = []
for arg in args:
if isinstance(arg, list) and len(arg) == 1:
result.append(arg[0])
else:
result.append(arg)
if len(result) == 1:
result = result[0]
print(result)
return result
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment