Skip to content

Align Python profiler CLI with rc-cli conventions - #11

Open
mrunalC27 wants to merge 2 commits into
runtimeconditions:mainfrom
mrunalC27:feat/python-profiler-cli-alignment
Open

mrunalC27 wants to merge 2 commits into
runtimeconditions:mainfrom
mrunalC27:feat/python-profiler-cli-alignment

Conversation

@mrunalC27

@mrunalC27 mrunalC27 commented Dec 2, 2026 •

Copy link
Copy Markdown

Summary

This PR aligns the Python profiler CLI with the shared command conventions requested in runtimeconditions/rc-cli#16.

Changes Made

  • Added support for both generate and profile generate command formats.
  • Added support for both verify-bindings and profile verify-bindings command formats.
  • Added --version and --version --json support.
  • Made --workload-version optional.
  • Kept --name and --workload-uri as required arguments for profile generation.
  • Added --json support for structured errors during generation.
  • Standardized CLI error messages with the runtimeconditions: prefix.
  • Added support for the RC_COMMAND_PREFIX environment variable to provide invocation-aware usage messages.
  • Improved actionable diagnostics for:
    • Non-existent project directories.
    • Empty Python projects.
    • Missing generated binding imports.
  • Added tests covering structured errors, command prefix handling, and project validation diagnostics.

Testing

  • Verified --version --json output.
  • Verified standalone Python CLI commands.
  • Verified Go CLI → Python profiler command forwarding.
  • Verified generate and verify-bindings help.
  • Verified structured JSON error handling for invalid project paths.
  • Verified discovery and validation of two installed binding packages.
  • Successfully generated Runtime Conditions Profile YAML through both Go CLI and standalone Python CLI.
  • Verified generated YAML contains the expected API and cache declarations.
  • python -m pytest -q
  • All 123 tests passed.
  • git diff --check passed.

Related Issue

Aligns with runtimeconditions/rc-cli#16.

Notes

Successful profile generation continues to produce YAML output. The --json option provides structured error output.

raise RuntimeConditionsError("no installed generated binding imports found in workload")
raise RuntimeConditionsError(
"no installed generated binding imports found in workload. "
"Install the generated binding package and import it in your Python source files."

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.

I would take this extra line off. Or rephrase it. The way it’s written now it indicates that there is one specific binding package they should install when in reality it could be several

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed! I'll rephrase it to make it clear that multiple generated binding packages may be required.

Comment thread runtimeconditions_profiler/cli.py Outdated
"verify-bindings",
help="verify installed generated bindings without running application or binding code",
usage=(
f"{get_command_prefix()} [profile] "

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.

I think what you’re trying to convey here is that they may or may not have used the profile command. But this gives the impression that it’s generally optional. In the context of the RC-CLI, it’s not. I wonder if if there is cleaner logic that we could apply here.

@mrunalC27 mrunalC27 Dec 3, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I added it to support both standalone and rc-cli-style invocation, but looking at the integration more closely, profile is already part of the parent CLI command. Apologies, accidentally duplicated something the parent CLI already handles. Will simplify it to accept only its own subcommands and retain RC_COMMAND_PREFIX.

@colinjlacy

Copy link
Copy Markdown
Member

I guess I'm confused on the optional use of profile in the commands. Can you explain why you decided to support that? I don't think it's standard in any of the other profilers.

I'm also curious if this has been tested with the https://github.com/runtimeconditions/rc-cli to see how it impacts those commands, since this is meant to work both independently and as a sub-process called by the CLI. The Testing block doesn't mention that.

@mrunalC27

Copy link
Copy Markdown
Author

I guess I'm confused on the optional use of profile in the commands. Can you explain why you decided to support that? I don't think it's standard in any of the other profilers.

I'm also curious if this has been tested with the https://github.com/runtimeconditions/rc-cli to see how it impacts those commands, since this is meant to work both independently and as a sub-process called by the CLI. The Testing block doesn't mention that.

So far, I tested the profiler independently and checked the command-prefix behaviour. I'll test it through the actual rc-cli workflow and update the Testing section with the results.

This branch has not been deployed

No deployments
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.

2 participants