Skip to content

Instantly share code, notes, and snippets.

@danlooo
Created December 11, 2025 16:26
Show Gist options
  • Select an option

  • Save danlooo/56e4e04c4a27ec6649baf4e5d44d5eea to your computer and use it in GitHub Desktop.

Select an option

Save danlooo/56e4e04c4a27ec6649baf4e5d44d5eea to your computer and use it in GitHub Desktop.
CWL workflow with breakpoints for debugging
#!/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
@danlooo
Copy link
Author

danlooo commented Dec 11, 2025

Run with cwltool hello-world-with-debug.cwl --message world . Remove python cwl.py pause to remove the break point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment