Skip to content

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

Open
arimu1 wants to merge 2 commits into
common-workflow-language:mainfrom
arimu1:fix/1535-prog-name-cwltool
Open

Report program name as cwltool when invoked as cwl-runner (#1535)#2290
arimu1 wants to merge 2 commits into
common-workflow-language:mainfrom
arimu1:fix/1535-prog-name-cwltool

Conversation

@arimu1

@arimu1 arimu1 commented Jun 18, 2026

Copy link
Copy Markdown

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.

…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 <noreply@anthropic.com>
Comment thread cwltool/argparser.py Outdated
)

parser = argparse.ArgumentParser(
prog="cwltool",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How will this affect downstream users of cwltool, like Toil, Calrissian, Arvados, and others?

…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.
@arimu1

arimu1 commented Jun 20, 2026

Copy link
Copy Markdown
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-runnercwltool 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.

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