- Added port_mass_flows to Component trait and implements for core components. - Added System::check_mass_balance and integrated it into the solver. - Restored connect methods for ExpansionValve, Compressor, and Pipe to fix integration tests. - Updated Python and C bindings for validation errors. - Updated sprint status and story documentation.
1.8 KiB
1.8 KiB
| description |
|---|
| Update Python bindings when Rust source changes |
Update Python Bindings
This workflow automates the process of updating the PyO3 Python bindings when the underlying Rust core (crates/components, crates/solver, etc.) changes.
Since the Python bindings use local Cargo workspace dependencies, changes to the Rust core structure (like adding a new struct field to a Component, or changing a method signature) will cause the Python wrapper to fail compilation until the wrapper's #[pyclass] and #[pymethods] are updated to match.
Follow these steps to migrate and recompile the bindings:
- Identify Rust Core Changes: Review the recent Git history or modifications in the
crates/directory to identify what component structs, enums, or functions have changed their public API. - Update PyO3 Wrappers: Modify the corresponding wrapper classes in
bindings/python/src/(e.g.,components.rs,solver.rs,types.rs) to reflect the new API.- Adjust
#[pyclass]fields and#[new]constructors if struct definitions changed. - Update
#[pymethods]if function signatures or return types changed.
- Adjust
- Register New Types: If new components or types were added to the core, create new wrappers for them and register them in the
#[pymodule]definition inbindings/python/src/lib.rs.
// turbo-all 4. Recompile Bindings: Run the MATURIN build process.
cd bindings/python
source .venv/bin/activate
maturin develop --release
- Run Tests: Execute the Python test suite to ensure the bindings still work correctly and the API behavior is intact.
cd bindings/python source .venv/bin/activate pytest tests/ -v - Fix Errors: If there are any Rust compilation errors (due to mismatched types) or Python test failures, fix them iteratively.