Skip to content

Added CommandWrapLauncher to easily append/prepend to launch commands.#111

Open
johannesbulin wants to merge 5 commits into
ecmwf-ifs:mainfrom
johannesbulin:johannes.bulin_compose_launcher
Open

Added CommandWrapLauncher to easily append/prepend to launch commands.#111
johannesbulin wants to merge 5 commits into
ecmwf-ifs:mainfrom
johannesbulin:johannes.bulin_compose_launcher

Conversation

@johannesbulin

@johannesbulin johannesbulin commented May 18, 2026

Copy link
Copy Markdown
Collaborator

Description

Added a CommandWrapLauncher that basically appends or prepends some additional flags/commands to the launch command.

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new ComposeLauncher wrapper to modify an existing launcher’s final command by prepending and/or appending additional command fragments, and adds tests to validate the wrapper’s behavior across supported launchers and environment setups.

Changes:

  • Added ComposeLauncher (LauncherWrapper) that rewrites LaunchData.cmd as: prepend_flags + base_cmd + flags + append_flags.
  • Exported the new launcher wrapper from ifsbench.launch.
  • Added parametrized tests covering run_dir, env, and cmd behavior for the wrapper.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
ifsbench/launch/composelauncher.py Adds the new ComposeLauncher wrapper that composes command lists around an existing prepared command.
ifsbench/launch/__init__.py Exposes ComposeLauncher as part of the ifsbench.launch public API.
ifsbench/launch/tests/test_composelauncher.py Adds sanity tests validating that wrapping preserves run_dir/env and composes cmd as intended.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ifsbench/launch/composelauncher.py Outdated
Comment thread ifsbench/launch/composelauncher.py Outdated
Comment thread ifsbench/launch/tests/test_composelauncher.py Outdated
Comment thread ifsbench/launch/tests/test_commandwraplauncher.py Outdated
Comment thread ifsbench/launch/tests/test_composelauncher.py Outdated
@codecov

codecov Bot commented May 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.72727% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.20%. Comparing base (96eddfe) to head (f9b7169).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
ifsbench/launch/commandoverride.py 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #111      +/-   ##
==========================================
+ Coverage   91.90%   92.20%   +0.29%     
==========================================
  Files          77       81       +4     
  Lines        4495     4706     +211     
==========================================
+ Hits         4131     4339     +208     
- Misses        364      367       +3     

☔ 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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread ifsbench/launch/tests/test_commandwraplauncher.py Outdated
Comment thread ifsbench/launch/__init__.py
@johannesbulin johannesbulin force-pushed the johannes.bulin_compose_launcher branch from d2d3c68 to 1e08b0a Compare May 18, 2026 13:38
@johannesbulin johannesbulin changed the title Added ComposeLauncher to easily append/prepend to launch commands. Added CommandWrapLauncher to easily append/prepend to launch commands. May 18, 2026
@johannesbulin johannesbulin marked this pull request as ready for review May 18, 2026 18:07
@johannesbulin johannesbulin marked this pull request as draft May 18, 2026 18:12
@johannesbulin

Copy link
Copy Markdown
Collaborator Author

@awnawab : This would give you a rather easy way to append/prepend flags/commands to a launch command, so

mpirun -n <automatically_set> command

would become

<prepend_flags> mpirun -n <automatically_set> command <append_flags>

Is this what you want? Or do you need something that appends/prepends to the actual command that you want to launch, for example to transform

mpirun -n <automatically_set> my_command

to

mpirun -n <automatically_set> valgrind --track-origin my_command

@awnawab

awnawab commented May 19, 2026

Copy link
Copy Markdown
Contributor

More the latter. I can't think of a use case for prepend_flags, and am mainly looking for a hook to add in debugger/profiler invocations.

@johannesbulin

Copy link
Copy Markdown
Collaborator Author

More the latter. I can't think of a use case for prepend_flags, and am mainly looking for a hook to add in debugger/profiler invocations.

Thanks! I'll try to work on a solution for this!

Copilot AI and others added 2 commits May 19, 2026 17:42
…mpositeLauncher

* Add CommandOverride, CommandWrapOverride, and command_overrides to CompositeLauncher

Agent-Logs-Url: https://github.com/johannesbulin/ifsbench/sessions/be8b4c6e-00f4-40ac-9afd-098097a2aece

Co-authored-by: johannesbulin <141238457+johannesbulin@users.noreply.github.com>

* Address review comments: use List (capitalized) in docstring, #: for attribute docs

Agent-Logs-Url: https://github.com/johannesbulin/ifsbench/sessions/6d8ba124-163b-4c1b-9dae-c4812dbda20e

Co-authored-by: johannesbulin <141238457+johannesbulin@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: johannesbulin <141238457+johannesbulin@users.noreply.github.com>
@johannesbulin johannesbulin marked this pull request as ready for review June 16, 2026 06:57
@johannesbulin

Copy link
Copy Markdown
Collaborator Author

Hi @awnawab ,

I've added a CommandWrapOverride. To use it, you can use a custom launcher YAML file like this:

cat > launcher_config.yaml << EOF

class_name: CompositeLauncher
flags: []
base_launcher:
  class_name: SrunLauncher
  flags: []
command_overrides:
- class_name: CommandWrapOverride
  prepend_cmd: ['valgrind', '--trace-children=yes']

EOF

ifsbench_run.py ... --launcher-config=launcher_config.yaml

Is this what you need?

@awnawab

awnawab commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Yes this is exactly what I was after, thanks! In fact, the BashLauncher that you showed me offline is probably an even better way of achieving the above. Both are valid solutions for my purposes, I'll let you decide whether you want to support one or both. Many thanks again for looking into this 🙏

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.

4 participants