diff --git a/.github/workflows/python-app.yaml b/.github/workflows/python-app.yaml index 234ad497c..8e445974c 100644 --- a/.github/workflows/python-app.yaml +++ b/.github/workflows/python-app.yaml @@ -88,7 +88,7 @@ jobs: uv pip install --system .[dev] - name: Run tests - run: pytest -v -p no:warnings --numprocesses=auto + run: pytest -v --numprocesses=auto test-examples: runs-on: ubuntu-24.04 diff --git a/CHANGELOG.md b/CHANGELOG.md index 09bd81ec1..b5de41f19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,7 +99,7 @@ This replaces `specific_share_to_other_effects_*` parameters and inverts the dir - FlowSystem manipulation: `sel()`, `isel()`, `resample()`, `copy()`, `__eq__()` methods - Direct access to FlowSystem from results without manual restoring (lazily loaded) - New `FlowResults` class and precomputed DataArrays for sizes/flow_rates/flow_hours -- `effects_per_component()` dataset for component impact evaluation, including all indirect effects through effect shares +- `effects_per_component` dataset for component impact evaluation, including all indirect effects through effect shares **Other additions:** @@ -124,7 +124,7 @@ This replaces `specific_share_to_other_effects_*` parameters and inverts the dir - Type system overhaul - added clear separation between temporal and non-temporal data throughout codebase for better clarity - Enhanced FlowSystem interface with improved `__repr__()` and `__str__()` methods - Improved Model Structure - Views and organisation is now divided into: - - Model: The main Model (linopy.Model) that is used to create and store the variables and constraints for the flow_system. + - Model: The main Model (linopy.Model) that is used to create and store the variables and constraints for the FlowSystem. - Submodel: The base class for all submodels. Each is a subset of the Model, for simpler access and clearer code. - Made docstrings in `config.py` more compact and easier to read - Improved format handling in configuration module @@ -188,7 +188,7 @@ This replaces `specific_share_to_other_effects_*` parameters and inverts the dir - **Centralized deprecation pattern**: Added `_handle_deprecated_kwarg()` helper method to `Interface` base class that provides reusable deprecation handling with consistent warnings, conflict detection, and optional value transformation. Applied across 5 classes (InvestParameters, Source, Sink, SourceAndSink, Effect) reducing deprecation boilerplate by 72%. - FlowSystem data management simplified - removed `time_series_collection` pattern in favor of direct timestep properties - Change modeling hierarchy to allow for more flexibility in future development. This leads to minimal changes in the access and creation of Submodels and their variables. -- Added new module `.modeling` that contains Modelling primitives and utilities +- Added new module `.modeling` that contains modeling primitives and utilities - Clearer separation between the main Model and "Submodels" - Improved access to the Submodels and their variables, constraints and submodels - Added `__repr__()` for Submodels to easily inspect its content @@ -218,10 +218,12 @@ This replaces `specific_share_to_other_effects_*` parameters and inverts the dir - All examples now enable console logging to demonstrate proper logging usage - Console logging now outputs to `sys.stdout` instead of `sys.stderr` for better compatibility with output redirection +### 💥 Breaking Changes +- Console logging is now disabled by default (`CONFIG.Logging.console = False`). Enable it explicitly in your scripts with `CONFIG.Logging.console = True` and `CONFIG.apply()` +- File logging is now disabled by default (`CONFIG.Logging.file = None`). Set a file path to enable file logging + ### ♻️ Changed - Logging and Configuration management changed -- **Breaking**: Console logging is now disabled by default (`CONFIG.Logging.console = False`). Enable it explicitly in your scripts with `CONFIG.Logging.console = True` and `CONFIG.apply()` -- **Breaking**: File logging is now disabled by default (`CONFIG.Logging.file = None`). Set a file path to enable file logging - Improved default logging colors: DEBUG is now gray (`\033[90m`) for de-emphasized messages, INFO uses terminal default color (`\033[0m`) for clean output ### 🗑️ Deprecated diff --git a/docs/index.md b/docs/index.md index 1aba538c7..2c6420f7f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -10,13 +10,13 @@ We believe that optimization modeling should be **approachable for beginners** y **Short-term goals:** -- **Multi-dimensional modeling**: Full support for multi-period investments and scenario-based stochastic optimization (periods and scenarios are in active development) +- **Multi-dimensional modeling**: Multi-period investments and scenario-based stochastic optimization are available (periods and scenarios are in active development for enhanced features) - **Enhanced component library**: More pre-built, domain-specific components (sector coupling, hydrogen systems, thermal networks, demand-side management) **Medium-term vision:** - **Modeling to generate alternatives (MGA)**: Built-in support for exploring near-optimal solution spaces to produce more robust, diverse solutions under uncertainty -- **Interactive tutorials**: Browser-based, reactive tutorials for learning FlixOpt without local installation (marimo) +- **Interactive tutorials**: Browser-based, reactive tutorials for learning FlixOpt without local installation ([marimo](https://marimo.io)) - **Standardized cost calculations**: Align with industry standards (VDI 2067) for CAPEX/OPEX calculations - **Advanced result analysis**: Time-series aggregation, automated reporting, and rich visualization options - **Recipe collection**: Community-driven library of common modeling patterns, data manipulation techniques, and optimization strategies (see [Recipes](user-guide/recipes/index.md) - help wanted!) diff --git a/docs/user-guide/recipes/index.md b/docs/user-guide/recipes/index.md new file mode 100644 index 000000000..8ac7d1812 --- /dev/null +++ b/docs/user-guide/recipes/index.md @@ -0,0 +1,47 @@ +# Recipes + +**Coming Soon!** 🚧 + +This section will contain quick, copy-paste ready code snippets for common FlixOpt patterns. + +--- + +## What Will Be Here? + +Short, focused code snippets showing **how to do specific things** in FlixOpt: + +- Common modeling patterns +- Integration with other tools +- Performance optimizations +- Domain-specific solutions +- Data analysis shortcuts + +Unlike full examples, recipes will be focused snippets showing a single concept. + +--- + +## Planned Topics + +- **Storage Patterns** - Batteries, thermal storage, seasonal storage +- **Multi-Criteria Optimization** - Balance multiple objectives +- **Data I/O** - Loading time series from CSV, databases, APIs +- **Data Manipulation** - Common xarray operations for parameterization and analysis +- **Investment Optimization** - Size optimization strategies +- **Renewable Integration** - Solar, wind capacity optimization +- **On/Off Constraints** - Minimum runtime, startup costs +- **Large-Scale Problems** - Segmented and aggregated calculations +- **Custom Constraints** - Extend models with linopy +- **Domain-Specific Patterns** - District heating, microgrids, industrial processes + +--- + +## Want to Contribute? + +**We need your help!** If you have recurring modeling patterns or clever solutions to share, please contribute via [GitHub issues](https://github.com/flixopt/flixopt/issues) or pull requests. + +Guidelines: +1. Keep it short (< 100 lines of code) +2. Focus on one specific technique +3. Add brief explanation and when to use it + +Check the [contribution guide](../../contribute.md) for details. diff --git a/examples/02_Complex/complex_example.py b/examples/02_Complex/complex_example.py index 2d0bad2d4..805cb08f6 100644 --- a/examples/02_Complex/complex_example.py +++ b/examples/02_Complex/complex_example.py @@ -190,7 +190,10 @@ flow_system.add_elements(bhkw_2) if use_chp_with_piecewise_conversion else flow_system.add_elements(bhkw) pprint(flow_system) # Get a string representation of the FlowSystem - flow_system.start_network_app() # Start the network app. Does only work with extra dependencies installed + try: + flow_system.start_network_app() # Start the network app + except ImportError as e: + print(f'Network app requires extra dependencies: {e}') # --- Solve FlowSystem --- calculation = fx.FullCalculation('complex example', flow_system, time_indices) diff --git a/flixopt/__init__.py b/flixopt/__init__.py index 1c4ac966a..8fc4e4851 100644 --- a/flixopt/__init__.py +++ b/flixopt/__init__.py @@ -47,9 +47,7 @@ # These filters match the test configuration in pyproject.toml for consistency. # tsam: Time series aggregation library -# - FutureWarning: Upcoming API changes in tsam (will be fixed in future tsam releases) -warnings.filterwarnings('ignore', category=FutureWarning, module='tsam') -# - UserWarning: Informational message about minimal value constraints +# - UserWarning: Informational message about minimal value constraints during clustering. warnings.filterwarnings('ignore', category=UserWarning, message='.*minimal value.*exceeds.*', module='tsam') # TODO: Might be able to fix it in flixopt? diff --git a/pyproject.toml b/pyproject.toml index b1d78261b..3bb68efb4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -202,7 +202,6 @@ filterwarnings = [ "error::UserWarning:flixopt", # === Third-party warnings (mirrored from __init__.py) === - "ignore::FutureWarning:tsam", "ignore:.*minimal value.*exceeds.*:UserWarning:tsam", "ignore:Coordinates across variables not equal:UserWarning:linopy", "ignore:.*join will change from join='outer' to join='exact'.*:FutureWarning:linopy",