Skip to content

Instantly share code, notes, and snippets.

@dleehr
Last active August 12, 2019 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dleehr/afdcde15aef9d727fd5226beddef126d to your computer and use it in GitHub Desktop.
Save dleehr/afdcde15aef9d727fd5226beddef126d to your computer and use it in GitHub Desktop.
sleep-echo-workflow

sleep-echo-workflow

This directory contains a tool and workflow to stress test calrissian managing lots of parallel tasks in kubernetes

The workflow takes 3 inputs:

  • loops: int, a number of loops to run inside each step
  • delay: float, a number of seconds to sleep in between each loop iteration
  • messages: string[], an array of messages to scatter to individual steps

If your messages array contains 100 items, the workflow will scatter the sleep-echo tool 100 times

{
"delay": 0.25,
"loops": 10,
"messages": [
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat",
"hello",
"world",
"foobar",
"bazbat"
]
}
cwlVersion: v1.0
class: Workflow
label: sleep-echo-scatter
doc: Sleep echo scatter
requirements:
- class: ScatterFeatureRequirement
inputs:
loops: int
delay: float
messages: string[]
outputs:
outputs:
type: File[]
outputSource: sleep_echo/output
steps:
sleep_echo:
run: sleep-echo.cwl
requirements:
- class: ResourceRequirement
coresMin: 1
ramMin: 100
scatter: message
in:
loops: loops
delay: delay
message: messages
out:
- output
cwlVersion: v1.0
class: CommandLineTool
requirements:
- class: DockerRequirement
dockerPull: 'python:3.6'
- class: InlineJavascriptRequirement
- class: InitialWorkDirRequirement
listing:
- entryname: sleep-echo.py
entry: |
import time
import sys
loops, delay, message = int(sys.argv[1]), float(sys.argv[2]), sys.argv[3]
for i in range(loops):
line = '{}: {}'.format(i, message)
print(line)
print(line, file=sys.stderr)
sys.stderr.flush()
time.sleep(delay)
print('Finished', message)
baseCommand: python
arguments: [sleep-echo.py]
inputs:
loops:
type: int
inputBinding:
position: 1
delay:
type: float
inputBinding:
position: 2
message:
type: string
inputBinding:
position: 3
stdout: $(inputs.message + '.txt')
outputs:
output:
type: File
outputBinding:
glob: $(inputs.message + '.txt')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment