feat!: remove deprecated Optimization/Results API#741
Conversation
Removes the pre-accessor workflow API that has outlived two removal deadlines (conftest said v6.0.0, DEPRECATION_REMOVAL_VERSION said 7.0.0): - Optimization and SegmentedOptimization classes (flixopt/optimization.py) - Results and per-element Results classes (flixopt/results.py) - FlowSystem.from_old_results() migration helper (itself deprecated) - normalize_weights deprecated parameter on create_model/build_model/optimize - dead supporting code: ResultsContainer, used_in_calculation flag - tests/deprecated (32 files) and the deprecated_api pytest marker The file-migration path is intentionally kept: FlowSystem.from_old_dataset() and the io conversion helpers still load pre-v5 files. BREAKING CHANGE: fx.Optimization, fx.SegmentedOptimization, flixopt.results and FlowSystem.from_old_results() are removed. Use FlowSystem.optimize() / build_model() + solve() and access results via FlowSystem.solution. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughThis change removes deprecated optimization and results APIs, simplifies model-construction signatures, replaces ChangesDeprecated API removal and migration
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@flixopt/flow_system.py`:
- Around line 827-828: The from_old_dataset() migration API must remain
supported without deprecation warnings. Remove its v6 removal warning/notice,
and update related migration documentation references from the removed
from_old_results() API to from_old_dataset().
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 9c85eeea-da0a-4f15-9cf6-3d828ad55b35
📒 Files selected for processing (44)
.github/workflows/tests.yaml.gitignoreflixopt/__init__.pyflixopt/flow_system.pyflixopt/optimization.pyflixopt/optimize_accessor.pyflixopt/results.pyflixopt/structure.pypyproject.tomltests/conftest.pytests/deprecated/__init__.pytests/deprecated/conftest.pytests/deprecated/examples/00_Minmal/minimal_example.pytests/deprecated/examples/01_Simple/simple_example.pytests/deprecated/examples/02_Complex/complex_example.pytests/deprecated/examples/02_Complex/complex_example_results.pytests/deprecated/examples/03_Optimization_modes/example_optimization_modes.pytests/deprecated/examples/04_Scenarios/scenario_example.pytests/deprecated/examples/05_Two-stage-optimization/two_stage_optimization.pytests/deprecated/test_bus.pytests/deprecated/test_component.pytests/deprecated/test_config.pytests/deprecated/test_cycle_detection.pytests/deprecated/test_effect.pytests/deprecated/test_effects_shares_summation.pytests/deprecated/test_examples.pytests/deprecated/test_flow.pytests/deprecated/test_flow_system_resample.pytests/deprecated/test_functional.pytests/deprecated/test_heatmap_reshape.pytests/deprecated/test_integration.pytests/deprecated/test_io.pytests/deprecated/test_linear_converter.pytests/deprecated/test_network_app.pytests/deprecated/test_on_hours_computation.pytests/deprecated/test_plotting_api.pytests/deprecated/test_resample_equivalence.pytests/deprecated/test_results_io.pytests/deprecated/test_results_overwrite.pytests/deprecated/test_results_plots.pytests/deprecated/test_scenarios.pytests/deprecated/test_storage.pytests/deprecated/test_timeseries.pytests/io/test_io_conversion.py
💤 Files with no reviewable changes (37)
- tests/deprecated/init.py
- tests/deprecated/examples/01_Simple/simple_example.py
- tests/deprecated/examples/00_Minmal/minimal_example.py
- tests/deprecated/test_plotting_api.py
- tests/deprecated/test_functional.py
- tests/deprecated/test_scenarios.py
- tests/deprecated/test_results_overwrite.py
- tests/deprecated/test_io.py
- tests/deprecated/examples/02_Complex/complex_example_results.py
- pyproject.toml
- tests/deprecated/test_network_app.py
- tests/deprecated/test_examples.py
- tests/deprecated/examples/05_Two-stage-optimization/two_stage_optimization.py
- tests/deprecated/test_config.py
- tests/deprecated/test_cycle_detection.py
- tests/deprecated/test_effect.py
- tests/deprecated/test_bus.py
- tests/deprecated/examples/04_Scenarios/scenario_example.py
- tests/deprecated/test_on_hours_computation.py
- tests/deprecated/test_results_plots.py
- tests/deprecated/test_heatmap_reshape.py
- tests/deprecated/test_results_io.py
- tests/deprecated/examples/03_Optimization_modes/example_optimization_modes.py
- tests/conftest.py
- tests/deprecated/examples/02_Complex/complex_example.py
- tests/deprecated/test_resample_equivalence.py
- flixopt/optimize_accessor.py
- tests/deprecated/test_effects_shares_summation.py
- tests/deprecated/test_storage.py
- tests/deprecated/test_linear_converter.py
- tests/deprecated/test_flow_system_resample.py
- tests/deprecated/test_component.py
- tests/deprecated/test_flow.py
- tests/deprecated/conftest.py
- tests/deprecated/test_integration.py
- flixopt/optimization.py
- tests/io/test_io_conversion.py
It is the only remaining loader for pre-v5 files, so drop its deprecation warning and docstring notice, and point the v5 migration guide at it now that from_old_results() is gone. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Summary
Removes the pre-accessor workflow API, which has outlived two promised removal deadlines (
tests/deprecated/conftest.pysaid v6.0.0,DEPRECATION_REMOVAL_VERSIONsays 7.0.0 — main is on 7.2.1).Net: −13,396 lines.
Removed
Optimization/SegmentedOptimization(flixopt/optimization.py)Results+ per-element results classes (flixopt/results.py)FlowSystem.from_old_results()(itself deprecation-warned)normalize_weightsdeprecated parameter oncreate_model/build_model/optimize()ResultsContainer,used_in_calculationflag, orphanedcreate_optimization_and_solvetest helpertests/deprecated/(32 files, ~9.2k lines) and thedeprecated_apipytest marker (incl. the CI draft-skip expression)Deliberately kept
FlowSystem.from_old_dataset()+ theflixopt.ioconversion helpers (PARAMETER_RENAMES, …): the file migration path for pre-v5 saves carries no deprecation warning and remains supported, with its tests.Migration
fx.Optimization(name, fs).solve(solver)fs.optimize(solver)orfs.build_model()+fs.solve(solver)Results/results.flow_rates()fs.solution,fs.stats, plotting accessorsFlowSystem.from_old_results(folder, name)from_old_dataset)Context
Peeled out of the element-data-classes stack (#602) so the overdue cleanup lands on its own timeline — this shrinks #602's diff by roughly a third once rebased.
Full suite locally: 1192 passed, 0 failed.
🤖 Generated with Claude Code
Summary by CodeRabbit
results,Optimization, andSegmentedOptimization).from_old_results) and the related calculation flag export.from_old_dataset()and re-optimizing for results.deprecated_apicoverage while still skippingexamplesandslowtests.