Skip to content

Add --rp-launch-uuid option to reuse existing ReportPortal launches#345

Merged
kkaarreell merged 2 commits into
mainfrom
ks_shedule_rp_uuid
Apr 14, 2026
Merged

Add --rp-launch-uuid option to reuse existing ReportPortal launches#345
kkaarreell merged 2 commits into
mainfrom
ks_shedule_rp_uuid

Conversation

@kkaarreell

@kkaarreell kkaarreell commented Apr 14, 2026

Copy link
Copy Markdown
Collaborator

Introduces a new --rp-launch-uuid option for the schedule command that allows reusing an existing ReportPortal launch instead of creating a new one. This enables consolidating test results from multiple NEWA runs into a single ReportPortal launch.

Key changes:

  • Add --rp-launch-uuid CLI option to schedule command (newa/cli/commands/schedule_cmd.py:34)
  • Implement mutual exclusivity validation between --rp-launch-uuid and --no-reportportal
  • Fetch and validate launch metadata from ReportPortal before scheduling jobs
  • Apply cached launch metadata (UUID, URL, name, description) to all generated schedule jobs
  • Update documentation with usage examples and important notes

The launch UUID is validated before scheduling begins, and all generated requests inherit the launch metadata to ensure consistent reporting to the existing launch.

🤖 Generated with Claude Code

Summary by Sourcery

Add support for reusing an existing ReportPortal launch when scheduling jobs and document the new workflow.

New Features:

  • Introduce a --rp-launch-uuid option to the schedule command to allow reusing an existing ReportPortal launch.
  • Apply shared ReportPortal launch metadata to all generated schedule jobs when an existing launch UUID is provided.

Enhancements:

  • Validate mutual exclusivity between --no-reportportal and --rp-launch-uuid in the schedule command.
  • Verify the specified ReportPortal launch exists before scheduling and fail fast if it does not.

Documentation:

  • Document the --rp-launch-uuid option, its typical use cases, constraints, and provide an example invocation in the README.

@kkaarreell kkaarreell self-assigned this Apr 14, 2026
@sourcery-ai

sourcery-ai Bot commented Apr 14, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds a new --rp-launch-uuid option to the schedule command to reuse an existing ReportPortal launch, validates its usage against --no-reportportal, fetches launch metadata once, and applies it to all generated schedule jobs, alongside updated documentation.

Sequence diagram for scheduling with --rp-launch-uuid

sequenceDiagram
    actor User
    participant CLI as newa_CLI
    participant ScheduleCmd as cmd_schedule
    participant Helper as _process_jira_job
    participant RPInit as initialize_rp_connection
    participant RPClient as ReportPortalClient
    participant RPServer as ReportPortal

    User->>CLI: run schedule --rp-launch-uuid LAUNCH_UUID
    CLI->>ScheduleCmd: invoke cmd_schedule(arch, fixtures, no_reportportal, rp_launch_uuid)

    ScheduleCmd->>ScheduleCmd: validate no_reportportal and rp_launch_uuid are not both set
    ScheduleCmd->>ScheduleCmd: initialize_state_dir(ctx)
    ScheduleCmd->>ScheduleCmd: jira_jobs = _get_jira_jobs(ctx)

    loop for each jira_job
        ScheduleCmd->>Helper: _process_jira_job(ctx, jira_job, arch, fixtures, no_reportportal, rp_launch_uuid)

        alt rp_launch_uuid is provided and first jira_job
            Helper->>RPInit: initialize_rp_connection(ctx)
            RPInit-->>Helper: rp_client

            Helper->>RPClient: get_launch_info(rp_launch_uuid)
            RPClient->>RPServer: HTTP GET launch metadata
            RPServer-->>RPClient: launch_info

            alt launch_info not found
                Helper->>Helper: log error and exit(1)
            else launch_info found
                Helper->>RPClient: get_launch_url(rp_launch_uuid)
                RPClient->>RPServer: build launch URL
                RPServer-->>RPClient: launch_url
                Helper->>Helper: cache launch_metadata (uuid, url, name, description)
            end
        end

        Helper->>Helper: determine compose and architectures
        Helper->>Helper: create RawRecipeSchedulerRequest instances

        loop for each request in jira_job
            Helper->>Helper: prepare jinja_vars and render request attributes

            alt launch_metadata exists
                Helper->>Helper: ensure request.reportportal exists
                Helper->>Helper: apply launch_uuid, launch_url, launch_name, launch_description
            end

            Helper->>Helper: create ScheduleJob from request
            Helper->>Helper: save ScheduleJob
        end
    end
Loading

File-Level Changes

Change Details Files
Support reusing an existing ReportPortal launch when scheduling jobs by wiring a new CLI option through to job processing and applying shared launch metadata to each request.
  • Extend _process_jira_job to accept an optional rp_launch_uuid parameter and initialize a ReportPortal connection when provided.
  • Fetch launch info once per jira job using rp.get_launch_info, validate that the launch exists, and build a RawRecipeReportPortalConfigDimension with UUID, URL, name, and description.
  • Log appropriate informational and error messages and exit if the launch cannot be found in the configured project.
  • For each generated request, ensure request.reportportal exists and then overlay the cached launch metadata fields so all schedule jobs target the same launch.
newa/cli/schedule_helpers.py
Expose a new --rp-launch-uuid CLI option for the schedule subcommand, enforce mutual exclusivity with --no-reportportal, and propagate the value into job processing.
  • Add a click option --rp-launch-uuid to cmd_schedule with a help description and default of None.
  • Update cmd_schedule signature to accept rp_launch_uuid and check that it is not used together with --no-reportportal, exiting with an error message if both are set.
  • Pass rp_launch_uuid through to _process_jira_job when iterating over jira jobs so that downstream logic can reuse the existing launch metadata.
newa/cli/commands/schedule_cmd.py
Document the new --rp-launch-uuid option, its typical use cases, and behavioral notes in the README.
  • Add a README section describing how --rp-launch-uuid reuses an existing ReportPortal launch and that it is mutually exclusive with --no-reportportal.
  • List typical scenarios for reusing launches and important validation behavior (existing UUID requirement, validation before scheduling, reuse by execute).
  • Provide a concrete CLI usage example invoking schedule with --rp-launch-uuid and follow-up execute/report commands.
README.md

Possibly linked issues

  • #(not provided): PR’s --rp-launch-uuid implements the issue’s idea of reusing a pre-created ReportPortal launch for reporting.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • The rp_launch_uuid parameter to cmd_schedule is annotated as str but can be None ( Click default and mutual exclusivity check), so consider updating the type to Optional[str] to better reflect actual usage and avoid type-checker confusion.
  • Instead of calling sys.exit(1) from within _process_jira_job and cmd_schedule, consider raising a click.ClickException (or another higher-level error) so that error handling and cleanup stay centralized in the CLI layer.
  • The mutual exclusivity between --no-reportportal and --rp-launch-uuid is implemented manually; you might want to use Click's option group or custom callback mechanism to enforce this at argument parsing time and provide more standard error messages.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `rp_launch_uuid` parameter to `cmd_schedule` is annotated as `str` but can be `None` ( Click default and mutual exclusivity check), so consider updating the type to `Optional[str]` to better reflect actual usage and avoid type-checker confusion.
- Instead of calling `sys.exit(1)` from within `_process_jira_job` and `cmd_schedule`, consider raising a `click.ClickException` (or another higher-level error) so that error handling and cleanup stay centralized in the CLI layer.
- The mutual exclusivity between `--no-reportportal` and `--rp-launch-uuid` is implemented manually; you might want to use Click's option group or custom callback mechanism to enforce this at argument parsing time and provide more standard error messages.

## Individual Comments

### Comment 1
<location path="newa/cli/schedule_helpers.py" line_range="195-197" />
<code_context>
+        ctx.logger.info(f'Fetching ReportPortal launch {rp_launch_uuid}')
+        launch_info = rp.get_launch_info(rp_launch_uuid)
+
+        if not launch_info:
+            ctx.logger.error(
+                f'ERROR: Could not find ReportPortal launch {rp_launch_uuid} in project {
+                    rp.project}')
+            sys.exit(1)
</code_context>
<issue_to_address>
**issue (bug_risk):** The multi-line f-string for the error log is syntactically invalid and will raise at import time.

The f-string is broken across lines inside the `{}` expression, which is invalid syntax and will raise a `SyntaxError`. Please keep the f-string on one line or join strings explicitly, for example:

```python
ctx.logger.error(
    f'ERROR: Could not find ReportPortal launch {rp_launch_uuid} in project {rp.project}'
)
```

or:

```python
ctx.logger.error(
    'ERROR: Could not find ReportPortal launch %s in project %s',
    rp_launch_uuid,
    rp.project,
)
```
</issue_to_address>

### Comment 2
<location path="newa/cli/commands/schedule_cmd.py" line_range="40-45" />
<code_context>
+    help='Reuse an existing ReportPortal launch UUID instead of creating a new one.',
+    )
 @click.pass_obj
 def cmd_schedule(
         ctx: CLIContext,
         arch: list[str],
         fixtures: list[str],
-        no_reportportal: bool) -> None:
+        no_reportportal: bool,
+        rp_launch_uuid: str) -> None:
     """
     Schedule subcommand - creates schedule jobs from jira jobs.
</code_context>
<issue_to_address>
**suggestion:** The type annotation for `rp_launch_uuid` is too strict compared to the Click option configuration.

Because the Click option uses `default=None`, `rp_launch_uuid` is actually `Optional[str]` at runtime, but the signature declares `str`. This mismatch can mislead readers and type checkers. Consider updating the parameter to:

```python
rp_launch_uuid: Optional[str] = None
```

and relying on the function default instead of `default=None` in the decorator.

Suggested implementation:

```python
@click.option(
    '--rp-launch-uuid',
    help='Reuse an existing ReportPortal launch UUID instead of creating a new one.',
    )
@click.pass_obj
def cmd_schedule(
        ctx: CLIContext,
        arch: list[str],
        fixtures: list[str],
        no_reportportal: bool,
        rp_launch_uuid: Optional[str] = None) -> None:

```

1. Ensure `Optional` is imported from `typing` at the top of `newa/cli/commands/schedule_cmd.py`, e.g.:
   - If there is an existing import: `from typing import Any, List`, extend it to `from typing import Any, List, Optional`.
   - Otherwise, add a new line: `from typing import Optional`.
2. No other code changes are required, since the existing checks (`if no_reportportal and rp_launch_uuid:`) already correctly handle `None` vs. non-`None` values.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread newa/cli/schedule_helpers.py Outdated
Comment thread newa/cli/commands/schedule_cmd.py Outdated
Introduces a new --rp-launch-uuid option for the schedule command that allows reusing an existing ReportPortal launch instead of creating a new one. This enables consolidating test results from multiple NEWA runs into a single ReportPortal launch.

Key changes:
- Add --rp-launch-uuid CLI option to schedule command (newa/cli/commands/schedule_cmd.py:34)
- Implement mutual exclusivity validation between --rp-launch-uuid and --no-reportportal
- Fetch and validate launch metadata from ReportPortal before scheduling jobs
- Apply cached launch metadata (UUID, URL, name, description) to all generated schedule jobs
- Update documentation with usage examples and important notes

The launch UUID is validated before scheduling begins, and all generated requests inherit the launch metadata to ensure consistent reporting to the existing launch.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@kkaarreell

Copy link
Copy Markdown
Collaborator Author

/packit build

The --fixture option now correctly handles values containing '=' characters
by splitting only on the first '=' instead of rejecting any value with
multiple equals signs.

This fixes commands like:
  --fixture 'testingfarm.cli_args="--environment FOO=bar"'

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@kkaarreell kkaarreell merged commit 66fa430 into main Apr 14, 2026
18 checks passed
@kkaarreell kkaarreell deleted the ks_shedule_rp_uuid branch April 14, 2026 09:06
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.

1 participant