Skip to content

Simplify scenario building - #45

Merged
RomanPszonka merged 25 commits into
openutm:mainfrom
atti92:simplify-scenarios
Nov 23, 2025
Merged

Simplify scenario building#45
RomanPszonka merged 25 commits into
openutm:mainfrom
atti92:simplify-scenarios

Conversation

@atti92

@atti92 atti92 commented Nov 22, 2025

Copy link
Copy Markdown
Contributor

Remove the need for partials when building scenarios.

@atti92
atti92 marked this pull request as ready for review November 22, 2025 20:19
@atti92
atti92 marked this pull request as draft November 22, 2025 20:33
@atti92
atti92 marked this pull request as ready for review November 22, 2025 20:33
@atti92
atti92 marked this pull request as draft November 22, 2025 20:56
@atti92
atti92 marked this pull request as ready for review November 22, 2025 20:56
@atti92
atti92 marked this pull request as draft November 22, 2025 20:58
@atti92
atti92 marked this pull request as ready for review November 22, 2025 20:58
@atti92
atti92 marked this pull request as draft November 22, 2025 21:05
@atti92
atti92 marked this pull request as ready for review November 22, 2025 21:05
@atti92
atti92 marked this pull request as draft November 22, 2025 21:13
@atti92
atti92 marked this pull request as ready for review November 22, 2025 21:13

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 simplifies scenario building by removing the need for functools.partial when defining test scenarios. The refactoring introduces a context-based approach where scenarios execute steps directly, and the framework automatically collects step results through the ScenarioContext and @scenario_step decorator pattern.

Key changes:

  • Introduced ScenarioContext using Python's contextvars to automatically track step results across scenario execution
  • Modified the @register_scenario decorator to wrap scenario functions and build ScenarioResult objects from collected steps
  • Refactored all scenario functions to call client methods directly instead of building lists of partial functions
  • Added a flight_declaration context manager to FlightBlenderClient to simplify setup/teardown patterns
  • Updated method signatures in FlightBlenderClient to remove operation_id parameters (now tracked internally)

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 27 comments.

Show a summary per file
File Description
src/openutm_verification/scenarios/registry.py Added _run_scenario_simple wrapper and enhanced @register_scenario decorator to automatically build ScenarioResult from collected steps
src/openutm_verification/core/execution/scenario_runner.py Implemented ScenarioContext using contextvars to track step results across scenario execution
src/openutm_verification/core/reporting/reporting_models.py Added SetupData model (though has structural issues with misplaced failed field)
src/openutm_verification/core/clients/flight_blender/flight_blender_client.py Removed operation_id parameters from methods, added flight_declaration context manager, and setup_flight_declaration method
src/openutm_verification/core/execution/dependencies.py Added data_files dependency provider for dependency injection
src/openutm_verification/scenarios/test_*.py Refactored all 10 scenario files to use direct function calls instead of partial functions
src/openutm_verification/scenarios/common.py Removed template functions (run_sdsp_scenario_template, run_air_traffic_scenario_template, run_scenario_template) and helper path functions, renamed private functions to public
src/openutm_verification/cli/__init__.py Added exit code based on failed scenario count
src/openutm_verification/core/execution/execution.py Modified to return failed scenario count
config/default.yaml Enabled several scenarios for testing
.github/workflows/main.yml Updated workflow triggers and added --wait flag to docker compose, plus if: always() for artifact upload
tests/docker-compose.fb.yml Added healthcheck for flight-blender service
Comments suppressed due to low confidence (3)

src/openutm_verification/scenarios/registry.py:16

  • Import of 'dataclass' is not used.
from dataclasses import dataclass

src/openutm_verification/scenarios/registry.py:18

  • Import of 'Any' is not used.
    Import of 'List' is not used.
    Import of 'Type' is not used.
    Import of 'cast' is not used.
from typing import Any, List, Type, TypeVar, cast

src/openutm_verification/scenarios/registry.py:22

  • Import of 'config' is not used.
from openutm_verification.core.execution.config_models import config

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

Comment thread src/openutm_verification/scenarios/test_airtraffic_data_openutm_sim.py Outdated
Comment thread src/openutm_verification/scenarios/registry.py Outdated
Comment thread src/openutm_verification/scenarios/test_sdsp_track.py
Comment thread src/openutm_verification/scenarios/registry.py Outdated
Comment thread src/openutm_verification/scenarios/test_sdsp_track.py Outdated
Comment thread src/openutm_verification/scenarios/test_opensky_live_data.py Outdated
Comment thread src/openutm_verification/scenarios/test_f5_flow.py Outdated
Comment thread src/openutm_verification/scenarios/test_f3_flow.py Outdated
Comment thread src/openutm_verification/scenarios/registry.py Outdated
atti92 and others added 5 commits November 23, 2025 13:49
…m_sim.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

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 21 out of 21 changed files in this pull request and generated 18 comments.

Comments suppressed due to low confidence (2)

src/openutm_verification/core/clients/flight_blender/flight_blender_client.py:608

  • The @scenario_step decorator already wraps the function to return a StepResult, but this function also explicitly returns a StepResult. This creates a double-wrapping issue where a StepResult containing another StepResult would be returned. Either:
  1. Remove the @scenario_step decorator and handle the step result manually, or
  2. Return the raw data and let the decorator create the StepResult

The current implementation on line 79-82 checks if isinstance(result, StepResult) to handle this, but it's confusing and inconsistent with the pattern used in other methods.

    @scenario_step("Verify SDSP Track")
    def initialize_verify_sdsp_track(
        self,
        expected_heartbeat_interval_seconds: int,
        expected_heartbeat_count: int,
        session_id: str,
    ) -> StepResult:

src/openutm_verification/core/clients/flight_blender/flight_blender_client.py:681

  • The @scenario_step decorator already wraps the function to return a StepResult, but this function also explicitly returns a StepResult. This creates a double-wrapping issue where a StepResult containing another StepResult would be returned. Either:
  1. Remove the @scenario_step decorator and handle the step result manually, or
  2. Return the raw data and let the decorator create the StepResult

The current implementation on line 79-82 checks if isinstance(result, StepResult) to handle this, but it's confusing and inconsistent with the pattern used in other methods.

    @scenario_step("Verify SDSP Heartbeat")
    def initialize_verify_sdsp_heartbeat(
        self,
        expected_heartbeat_interval_seconds: int,
        expected_heartbeat_count: int,
        session_id: str,
    ) -> StepResult:

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

Comment thread src/openutm_verification/scenarios/test_f2_flow.py
Comment thread src/openutm_verification/scenarios/test_f2_flow.py
Comment thread src/openutm_verification/core/reporting/reporting_models.py
Comment thread tests/docker-compose.fb.yml
Comment thread src/openutm_verification/core/clients/flight_blender/flight_blender_client.py Outdated
Comment thread src/openutm_verification/scenarios/test_add_flight_declaration.py Outdated
Comment thread src/openutm_verification/core/reporting/reporting_models.py
Comment thread src/openutm_verification/scenarios/test_opensky_live_data.py Outdated
Comment thread src/openutm_verification/scenarios/test_geo_fence_upload.py Outdated
Comment thread src/openutm_verification/scenarios/test_f5_flow.py Outdated
atti92 and others added 7 commits November 23, 2025 15:14
…ender_client.py

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@RomanPszonka
RomanPszonka merged commit a8882d7 into openutm:main Nov 23, 2025
1 check 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.

3 participants