Skip to content

feat!: remove deprecated Optimization/Results API#741

Open
FBumann wants to merge 2 commits into
mainfrom
remove-deprecated-api
Open

feat!: remove deprecated Optimization/Results API#741
FBumann wants to merge 2 commits into
mainfrom
remove-deprecated-api

Conversation

@FBumann

@FBumann FBumann commented Jul 22, 2026

Copy link
Copy Markdown
Member

Summary

Removes the pre-accessor workflow API, which has outlived two promised removal deadlines (tests/deprecated/conftest.py said v6.0.0, DEPRECATION_REMOVAL_VERSION says 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_weights deprecated parameter on create_model / build_model / optimize()
  • Dead supporting code: ResultsContainer, used_in_calculation flag, orphaned create_optimization_and_solve test helper
  • tests/deprecated/ (32 files, ~9.2k lines) and the deprecated_api pytest marker (incl. the CI draft-skip expression)

Deliberately kept

  • FlowSystem.from_old_dataset() + the flixopt.io conversion helpers (PARAMETER_RENAMES, …): the file migration path for pre-v5 saves carries no deprecation warning and remains supported, with its tests.

Migration

Old New
fx.Optimization(name, fs).solve(solver) fs.optimize(solver) or fs.build_model() + fs.solve(solver)
Results / results.flow_rates() fs.solution, fs.stats, plotting accessors
FlowSystem.from_old_results(folder, name) re-run with the current API (or load configs via 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

  • Breaking Changes
    • Removed deprecated optimization APIs and reduced top-level exports (including results, Optimization, and SegmentedOptimization).
    • Simplified model-building/optimization calls by removing the legacy weight-normalization option.
    • Removed legacy results migration (from_old_results) and the related calculation flag export.
  • New Features
    • Introduced flow containers for accessing flows by full label, short label, or index.
  • Documentation
    • Updated the v5 migration guide to direct legacy loading via from_old_dataset() and re-optimizing for results.
  • Tests
    • Retired the deprecated test suite and examples; CI for draft PRs now runs deprecated_api coverage while still skipping examples and slow tests.

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>
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: be208369-d8bc-4d26-b4a5-79a74bbf9cd2

📥 Commits

Reviewing files that changed from the base of the PR and between 20240e4 and 37444bc.

📒 Files selected for processing (2)
  • docs/user-guide/migration-guide-v5.md
  • flixopt/flow_system.py
💤 Files with no reviewable changes (1)
  • flixopt/flow_system.py

📝 Walkthrough

Walkthrough

This change removes deprecated optimization and results APIs, simplifies model-construction signatures, replaces ResultsContainer with FlowContainer, and deletes deprecated tests, migration coverage, fixtures, examples, and pytest marker configuration.

Changes

Deprecated API removal and migration

Layer / File(s) Summary
Public API and migration cleanup
flixopt/__init__.py, flixopt/flow_system.py, docs/user-guide/migration-guide-v5.md
Removes deprecated optimization exports and the old results migration entry point while retaining dataset-based legacy conversion and updating migration guidance.
Model construction API simplification
flixopt/flow_system.py, flixopt/optimize_accessor.py
Removes normalize_weights parameters and their deprecation handling from model construction and optimization calls.
Flow container access contract
flixopt/structure.py
Replaces ResultsContainer with FlowContainer, supporting full-label, short-label, index, and membership access.
Deprecated test and CI cleanup
tests/deprecated/*, tests/conftest.py, tests/io/test_io_conversion.py, .github/workflows/tests.yaml, pyproject.toml, .gitignore
Removes deprecated fixtures, examples, tests, migration coverage, and marker configuration; draft CI runs no longer exclude deprecated_api, and fs.json is ignored.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description has useful content, but it does not follow the required template sections for Description, Type of Change, Related Issues, Testing, or Checklist. Restructure the PR description to match the template and add the missing sections, especially Type of Change, Related Issues, Testing, and Checklist.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: removal of the deprecated Optimization/Results API.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch remove-deprecated-api

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between cc56774 and 20240e4.

📒 Files selected for processing (44)
  • .github/workflows/tests.yaml
  • .gitignore
  • flixopt/__init__.py
  • flixopt/flow_system.py
  • flixopt/optimization.py
  • flixopt/optimize_accessor.py
  • flixopt/results.py
  • flixopt/structure.py
  • pyproject.toml
  • tests/conftest.py
  • tests/deprecated/__init__.py
  • tests/deprecated/conftest.py
  • tests/deprecated/examples/00_Minmal/minimal_example.py
  • tests/deprecated/examples/01_Simple/simple_example.py
  • tests/deprecated/examples/02_Complex/complex_example.py
  • tests/deprecated/examples/02_Complex/complex_example_results.py
  • tests/deprecated/examples/03_Optimization_modes/example_optimization_modes.py
  • tests/deprecated/examples/04_Scenarios/scenario_example.py
  • tests/deprecated/examples/05_Two-stage-optimization/two_stage_optimization.py
  • tests/deprecated/test_bus.py
  • tests/deprecated/test_component.py
  • tests/deprecated/test_config.py
  • tests/deprecated/test_cycle_detection.py
  • tests/deprecated/test_effect.py
  • tests/deprecated/test_effects_shares_summation.py
  • tests/deprecated/test_examples.py
  • tests/deprecated/test_flow.py
  • tests/deprecated/test_flow_system_resample.py
  • tests/deprecated/test_functional.py
  • tests/deprecated/test_heatmap_reshape.py
  • tests/deprecated/test_integration.py
  • tests/deprecated/test_io.py
  • tests/deprecated/test_linear_converter.py
  • tests/deprecated/test_network_app.py
  • tests/deprecated/test_on_hours_computation.py
  • tests/deprecated/test_plotting_api.py
  • tests/deprecated/test_resample_equivalence.py
  • tests/deprecated/test_results_io.py
  • tests/deprecated/test_results_overwrite.py
  • tests/deprecated/test_results_plots.py
  • tests/deprecated/test_scenarios.py
  • tests/deprecated/test_storage.py
  • tests/deprecated/test_timeseries.py
  • tests/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

Comment thread flixopt/flow_system.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>
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