Skip to content

Report program name as cwltool when invoked as cwl-runner (#1535) - #2290

Merged
mr-c merged 3 commits into
common-workflow-language:mainfrom
arimu1:fix/1535-prog-name-cwltool
Jul 16, 2026
Merged

mr-c merged 3 commits into
common-workflow-language:mainfrom
arimu1:fix/1535-prog-name-cwltool

Conversation

@arimu1

@arimu1 arimu1 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1535.

cwltool is installed with a cwl-runner console-script entry point. Because argparse defaults prog to os.path.basename(sys.argv[0]), invoking it through that alias made the help and error output identify the program as cwl-runner:

$ cwl-runner --help
usage: cwl-runner [-h] [--basedir BASEDIR] ...

Change

Set prog="cwltool" explicitly on the top-level ArgumentParser in cwltool/argparser.py, so the reference implementation is always identified consistently no matter which entry point launched it:

$ cwl-runner --help
usage: cwl-runner --help     # before
usage: cwltool [-h] ...      # after

This also applies to the usage line printed on argument errors.

Tests

Added test_argparser_prog_is_cwltool to tests/test_toolargparse.py, which patches sys.argv[0] to cwl-runner and asserts arg_parser().prog == "cwltool". Full test_toolargparse.py passes (18); black/flake8/isort clean.


This change was produced with the assistance of Claude Code (model: Claude Opus). It was reviewed by a human before submission.

Comment thread cwltool/argparser.py Resolved
@arimu1

arimu1 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

Good question — I checked the three:

  • Toil and Arvados are unaffected: Toil builds its own ArgumentParser and Arvados defines its own arg_parser(), only borrowing cwltool's default values via get_default_args(). Neither reuses cwltool's parser object, and cwltool.main() skips arg_parser() entirely when given a pre-parsed args.
  • Calrissian would be affected: it uses cwltool.argparser.arg_parser() as its base parser and never sets prog, so today it shows calrissian; an unconditional prog="cwltool" would change that to cwltool.

To avoid that, I scoped the override to the actual entry-point name: prog="cwltool" if os.path.basename(sys.argv[0]) == "cwl-runner" else None. That still fixes the cwl-runner → cwltool case from #1535 while leaving Calrissian (and any other downstream reuser) on its own program name. Added a regression test for the downstream case. Pushed.

@mr-c
mr-c marked this pull request as draft June 25, 2026 13:35
@arimu1
arimu1 force-pushed the fix/1535-prog-name-cwltool branch from 0e4e371 to f05eab4 Compare June 28, 2026 06:40
@codecov

codecov Bot commented Jun 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.18%. Comparing base (efb0f9f) to head (abaaecf).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2290   +/-   ##
=======================================
  Coverage   85.18%   85.18%           
=======================================
  Files          46       46           
  Lines        8595     8595           
  Branches     2012     2012           
=======================================
  Hits         7322     7322           
  Misses        807      807           
  Partials      466      466           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@arimu1
arimu1 marked this pull request as ready for review June 28, 2026 10:09
@arimu1

arimu1 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

Checking back in — the pushed change should address the Toil/Calrissian/Arvados question (scoped the override to cwl-runner invocations only, with a regression test covering the downstream-reuse case). Let me know if anything else is needed for review.

@arimu1
arimu1 force-pushed the fix/1535-prog-name-cwltool branch from f05eab4 to 2a748ed Compare July 11, 2026 03:18
arimu1 and others added 2 commits July 15, 2026 11:32
…kflow-language#1535)

argparse defaults prog to os.path.basename(sys.argv[0]), so running
cwltool through its cwl-runner entry point made --help and error
messages say "usage: cwl-runner ...". Set prog="cwltool" explicitly so
the reference implementation is always identified consistently,
regardless of which entry point was used.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…guage#1535)

Per review feedback: an unconditional prog="cwltool" would leak into
downstream tools that reuse cwltool.argparser.arg_parser() as their base
parser (e.g. Calrissian), changing their --help/usage program name.

Scope the override to the actual invocation name: set prog="cwltool"
only when invoked as the generic "cwl-runner" alias, otherwise leave it
None so argparse's basename default is preserved. Toil and Arvados are
unaffected either way (they build their own parsers). Added a test
asserting a downstream invocation name is preserved.
@mr-c
mr-c force-pushed the fix/1535-prog-name-cwltool branch from 2a748ed to 73baa89 Compare July 15, 2026 09:32
@mr-c
mr-c enabled auto-merge (squash) July 15, 2026 09:32
@mr-c

mr-c commented Jul 16, 2026

Copy link
Copy Markdown
Member

@arimu1
ci: retrigger CI (previous run had cancelled jobs)

Please don't do that after a maintainer has approved a PR; you should let them handle it from there.

@mr-c

mr-c commented Jul 16, 2026

Copy link
Copy Markdown
Member

@arimu1 I can re-run just the failed CI; but if you push a new commit then all of the CI has to run again, which is a waste of time and resources

@mr-c
mr-c merged commit b97d8f4 into common-workflow-language:main Jul 16, 2026
76 of 85 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

report prog as "cwltool" if invoked as "cwl-runner"

2 participants