Split configured cycle summary and history helpers#649
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 62cbf0f889
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| class ConfiguredCycleRunnerResult: | ||
| """All cycles run by one application invocation.""" | ||
|
|
||
| status: ConfiguredCycleRunnerStatus |
There was a problem hiding this comment.
Keep runner status resolvable at runtime
When ConfiguredCycleRunnerResult is imported from the new models module, the status annotation is stored as the string ConfiguredCycleRunnerStatus, but that name only exists under TYPE_CHECKING. Runtime consumers that introspect this public result model with typing.get_type_hints(ConfiguredCycleRunnerResult) now get NameError: name 'ConfiguredCycleRunnerStatus' is not defined; this worked before because the enum and dataclass lived in the same module. This affects serializers/schema builders or other API tooling that resolves annotations, so the enum should be moved/re-exported into a runtime-resolvable namespace instead of being only type-checking imported.
Useful? React with 👍 / 👎.
Motivation
configured_cycle_runner.pyresponsibilities by extracting summary output and run-history persistence helpers to improve modularity and avoid circular imports.Description
src/carbonfactor_parser/pipeline/configured_cycle_summary.pyand movedemit_configured_cycle_summary,_download_status_value, and_parse_status_valueinto it while preserving exact emitted lines and redaction semantics.src/carbonfactor_parser/pipeline/configured_cycle_history.pyand moved_persist_configured_cycle_historylogic aspersist_configured_cycle_historythat returns aConfiguredCycleResultand preserves non-fatal, sanitized persistence behavior.src/carbonfactor_parser/pipeline/configured_cycle_models.pyto hostConfiguredCycleResultandConfiguredCycleRunnerResultto avoid circular imports and keep dataclass APIs unchanged, and preserved backwards-compatible exports fromconfigured_cycle_runner.pyfor these symbols andemit_configured_cycle_summary.configured_cycle_runner.pyto import and useemit_configured_cycle_summaryandpersist_configured_cycle_history, keeping the runner focused on startup, cycle loop, cycle construction, and aggregation only; narrowed a type-check import iningestion_run_history_mapping.pyto the new models module.Testing
python -m pytest tests/test_configured_cycle_runner.py tests/test_run_ingestion_summary_cli.pyand they passed.python -m pytest tests/test_ingestion_run_history_mapping.py tests/test_ingestion_run_history_repository.py tests/test_ingestion_run_history_reader.pyand they passed.python -m pytestand it passed (2148 passed, 8 skipped in this environment).python -m ruff check src/carbonfactor_parser/pipeline/configured_cycle_runner.py src/carbonfactor_parser/pipeline/configured_cycle_summary.py src/carbonfactor_parser/pipeline/configured_cycle_history.py tests/test_configured_cycle_runner.pywhich passed; also validatedgit diff --checkwith no issues.Codex Task