Created
December 11, 2025 16:26
-
-
Save danlooo/56e4e04c4a27ec6649baf4e5d44d5eea to your computer and use it in GitHub Desktop.
CWL workflow with breakpoints for debugging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env cwltool | |
| cwlVersion: v1.2 | |
| class: CommandLineTool | |
| inputs: | |
| message: | |
| type: string | |
| outputs: | |
| outfile: | |
| type: File | |
| outputBinding: | |
| glob: output.txt | |
| baseCommand: [bash, run.sh] | |
| requirements: | |
| DockerRequirement: | |
| dockerImageId: hello-world | |
| dockerFile: | | |
| FROM python | |
| InitialWorkDirRequirement: | |
| listing: | |
| - entryname: inputs.json | |
| entry: $(inputs) | |
| - entryname: cwl.py | |
| entry: | | |
| #!/usr/bin/env python | |
| import os | |
| import sys | |
| import time | |
| if sys.argv[1] == "pause": | |
| # normal print will be catched by cwltool | |
| with open("state", "a") as f: | |
| f.write("PAUSED") | |
| os.system(f"echo Debug mode enabled and workflow paused.") | |
| os.system(f"echo Access container: docker exec -it {os.environ["HOSTNAME"]} bash") | |
| os.system(f"echo Unpause container: docker exec -it {os.environ["HOSTNAME"]} python cwl.py next") | |
| paused = True | |
| while paused: | |
| time.sleep(1) | |
| paused = open("state", "r").read() == "PAUSED" | |
| elif sys.argv[1] == "next": | |
| with open("state", "a") as f: | |
| f.write("RUN") | |
| - entryname: run.sh | |
| entry: | | |
| #!/usr/bin/env bash | |
| echo hi | |
| python cwl.py pause | |
| echo hello, $(inputs.message) > output.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice trick! I just mentioned it on the CWL forum: https://cwl.discourse.group/t/tool-activate/1042/3?u=mrc
I could imagine a version of this that replaced the Python script with a POSIX shell script, making it usable with even more containers.
And as mentioned by the original poster at the link above, this technique could be adapted into a feature implemented by
cwltooland other CWL implementations to generically "enter" or "activate" the environment of a CWLCommandLineToolfor learning, troubleshooting or debugging; without having to edit the CWL descriptionsl files themselves.