|
| 1 | +# pymizer Development Roadmap |
| 2 | + |
| 3 | +This document outlines a practical plan for further development of the |
| 4 | +`pymizer` Python wrapper package. |
| 5 | + |
| 6 | +The current package already supports: |
| 7 | + |
| 8 | +- creating `MizerParams` wrappers from Python |
| 9 | +- running `project()` through the R `mizer` package |
| 10 | +- extracting common results as `pandas`, `numpy`, and `xarray` |
| 11 | +- loading built-in `mizer` datasets from Python |
| 12 | +- building a dedicated documentation website |
| 13 | + |
| 14 | +The next stages should focus on turning the current proof of concept into a |
| 15 | +more robust and maintainable bridge for real analysis workflows. |
| 16 | + |
| 17 | +## Guiding Principles |
| 18 | + |
| 19 | +- Keep the Python API close to the mental model of `mizer`, but make return |
| 20 | + types feel natural in Python. |
| 21 | +- Prefer thin, reliable wrapping of stable R functionality over partial |
| 22 | + reimplementation in Python. |
| 23 | +- Expand the public API in layers, starting with the most common scientific |
| 24 | + workflows. |
| 25 | +- Treat packaging, testing, and documentation as product features, not polish. |
| 26 | + |
| 27 | +## Phase 1: Stabilise The Core Wrapper |
| 28 | + |
| 29 | +### Goals |
| 30 | + |
| 31 | +- Make the existing wrapper reliable for day-to-day use. |
| 32 | +- Reduce avoidable environment friction. |
| 33 | +- Tighten the boundaries of the supported API. |
| 34 | + |
| 35 | +### Work Items |
| 36 | + |
| 37 | +- Add explicit version checks for compatible R, `mizer`, and `rpy2` versions. |
| 38 | +- Improve startup diagnostics when R or the `mizer` package is unavailable. |
| 39 | +- Standardise conversion helpers so all wrapped functions follow the same rules |
| 40 | + for `pandas`, `numpy`, and `xarray` outputs. |
| 41 | +- Add lightweight validation helpers for constructor inputs such as |
| 42 | + `species_params` and interaction matrices. |
| 43 | +- Improve object summaries so `MizerParams.summary()` and `MizerSim` reporting |
| 44 | + are more useful in notebooks. |
| 45 | +- Add convenience methods for common save/load workflows on `MizerSim` as well |
| 46 | + as `MizerParams`. |
| 47 | + |
| 48 | +### Exit Criteria |
| 49 | + |
| 50 | +- The current API behaves consistently across supported object types. |
| 51 | +- Error messages are actionable when bridge setup fails. |
| 52 | +- The wrapper can be installed and exercised from a clean environment with |
| 53 | + documented steps. |
| 54 | + |
| 55 | +## Phase 2: Expand High-Value Analysis Surface |
| 56 | + |
| 57 | +### Goals |
| 58 | + |
| 59 | +- Cover the most commonly used read-only `mizer` analysis functions. |
| 60 | +- Make Python notebooks viable without frequent escapes into raw R objects. |
| 61 | + |
| 62 | +### Priority Additions |
| 63 | + |
| 64 | +- `MizerSim` accessors: |
| 65 | + - `ssb()` |
| 66 | + - `yield_gear()` |
| 67 | + - `f_mort_gear()` |
| 68 | + - `pred_mort()` |
| 69 | + - `diet()` |
| 70 | + - `growth_curves()` |
| 71 | +- `MizerParams` accessors: |
| 72 | + - `initial_n()` |
| 73 | + - `initial_n_resource()` |
| 74 | + - `biomass()` |
| 75 | + - `feeding_level()` |
| 76 | + - `pred_rate()` |
| 77 | +- indicator functions: |
| 78 | + - community slope |
| 79 | + - mean weight |
| 80 | + - proportion of large fish |
| 81 | + - trophic level outputs |
| 82 | + |
| 83 | +### Conversion Targets |
| 84 | + |
| 85 | +- 2D summaries -> `pandas.DataFrame` |
| 86 | +- 3D and 4D outputs -> `xarray.DataArray` |
| 87 | +- scalar and vector indicators -> Python scalars or `pandas.Series` |
| 88 | + |
| 89 | +### Exit Criteria |
| 90 | + |
| 91 | +- A typical exploratory analysis can stay in Python for model setup, projection, |
| 92 | + and inspection of core outputs. |
| 93 | +- The reference docs cover all supported wrapped methods and return types. |
| 94 | + |
| 95 | +## Phase 3: Parameter Editing And Model Manipulation |
| 96 | + |
| 97 | +### Goals |
| 98 | + |
| 99 | +- Support the common “load, tweak, rerun” workflow from Python. |
| 100 | +- Preserve the immutability pattern used by `mizer`. |
| 101 | + |
| 102 | +### Priority Additions |
| 103 | + |
| 104 | +- `set_interaction()` |
| 105 | +- `set_resource()` |
| 106 | +- `set_reproduction()` |
| 107 | +- `set_initial_values()` |
| 108 | +- `set_metadata()` |
| 109 | +- `set_pred_kernel()` |
| 110 | +- `set_search_volume()` |
| 111 | +- `set_max_intake_rate()` |
| 112 | +- `set_metabolic_rate()` |
| 113 | +- `project_to_steady()` if feasible through the current bridge design |
| 114 | + |
| 115 | +### Design Notes |
| 116 | + |
| 117 | +- These methods should return new wrapped `MizerParams` objects. |
| 118 | +- Python names should remain snake_case while mapping clearly to the |
| 119 | + underlying R functions. |
| 120 | +- Only expose setters once input conversion and output semantics are well |
| 121 | + defined. |
| 122 | + |
| 123 | +### Exit Criteria |
| 124 | + |
| 125 | +- Users can modify realistic models from Python without directly touching R. |
| 126 | +- Setter behaviour is tested against the corresponding R functions. |
| 127 | + |
| 128 | +## Phase 4: Better Dataset And Example Support |
| 129 | + |
| 130 | +### Goals |
| 131 | + |
| 132 | +- Make the wrapper easy to learn through real models and reproducible examples. |
| 133 | + |
| 134 | +### Work Items |
| 135 | + |
| 136 | +- Add richer helpers around built-in datasets, such as loading matching North |
| 137 | + Sea inputs together. |
| 138 | +- Add example notebooks for: |
| 139 | + - community model |
| 140 | + - North Sea model |
| 141 | + - basic plotting and analysis in Python |
| 142 | +- Add a helper to expose package example file paths if needed. |
| 143 | +- Add a documented “recommended first workflow” that uses built-in example |
| 144 | + data only. |
| 145 | + |
| 146 | +### Exit Criteria |
| 147 | + |
| 148 | +- A new user can follow a single notebook to run and inspect a real `mizer` |
| 149 | + model from Python. |
| 150 | + |
| 151 | +## Phase 5: Packaging And Distribution |
| 152 | + |
| 153 | +### Goals |
| 154 | + |
| 155 | +- Make installation predictable outside this repository. |
| 156 | +- Clarify how Python and R dependencies should be managed together. |
| 157 | + |
| 158 | +### Work Items |
| 159 | + |
| 160 | +- Decide on the intended release model: |
| 161 | + - publish `pymizer` as a Python package only |
| 162 | + - or keep it as a repo-local companion package for now |
| 163 | +- Add wheel and source distribution checks. |
| 164 | +- Document installation strategies for: |
| 165 | + - local developer setup |
| 166 | + - virtualenv/venv |
| 167 | + - Conda or Mamba |
| 168 | + - CI environments |
| 169 | +- Decide whether installation should attempt any automatic R package checks or |
| 170 | + remain fully manual. |
| 171 | +- Add a minimal support matrix covering OS, Python version, and R version. |
| 172 | + |
| 173 | +### Exit Criteria |
| 174 | + |
| 175 | +- Installation instructions are clear and reproducible. |
| 176 | +- CI can build and test the package from scratch. |
| 177 | + |
| 178 | +## Phase 6: Testing And Continuous Integration |
| 179 | + |
| 180 | +### Goals |
| 181 | + |
| 182 | +- Move from smoke tests to confidence-building coverage. |
| 183 | + |
| 184 | +### Test Layers |
| 185 | + |
| 186 | +- unit tests for conversion helpers and shape handling |
| 187 | +- integration tests for live R bridge behaviour |
| 188 | +- regression tests for built-in examples |
| 189 | +- documentation build tests |
| 190 | + |
| 191 | +### Recommended Additions |
| 192 | + |
| 193 | +- add GitHub Actions for Python tests alongside the existing R workflows |
| 194 | +- run matrix builds over supported Python and R versions where practical |
| 195 | +- add tests for failure modes: |
| 196 | + - missing R |
| 197 | + - missing `mizer` |
| 198 | + - invalid dataset name |
| 199 | + - malformed constructor inputs |
| 200 | + |
| 201 | +### Exit Criteria |
| 202 | + |
| 203 | +- Core wrapper functionality is exercised automatically in CI. |
| 204 | +- Changes to conversions, docs, or object wrappers are unlikely to break |
| 205 | + silently. |
| 206 | + |
| 207 | +## Phase 7: Plotting And Python-Native Ergonomics |
| 208 | + |
| 209 | +### Goals |
| 210 | + |
| 211 | +- Make output exploration feel more natural in the Python ecosystem. |
| 212 | + |
| 213 | +### Possible Additions |
| 214 | + |
| 215 | +- convenience plotting methods backed by `matplotlib`, `seaborn`, or `plotly` |
| 216 | +- helper methods for converting outputs to tidy long-form `pandas` |
| 217 | +- utility functions for common notebook display patterns |
| 218 | +- optional integration with Jupyter-rich summaries for wrapped objects |
| 219 | + |
| 220 | +### Caution |
| 221 | + |
| 222 | +- Do not overbuild a separate plotting layer if users are already well served |
| 223 | + by `xarray` and `pandas`. |
| 224 | +- Prefer a small number of opinionated helpers over trying to mirror every R |
| 225 | + plotting function immediately. |
| 226 | + |
| 227 | +## Phase 8: Advanced And Experimental Features |
| 228 | + |
| 229 | +### Goals |
| 230 | + |
| 231 | +- Explore whether more of `mizer`’s extension surface can be exposed from |
| 232 | + Python without creating fragile abstractions. |
| 233 | + |
| 234 | +### Candidates |
| 235 | + |
| 236 | +- support for more extension hooks and metadata |
| 237 | +- controlled access to custom rate-function registration |
| 238 | +- pass-through helpers for advanced users who need raw R evaluation |
| 239 | +- helpers for serialising wrapper state in mixed Python/R workflows |
| 240 | + |
| 241 | +### Caution |
| 242 | + |
| 243 | +- Python callbacks that are expected to behave like native R rate functions |
| 244 | + are likely to be fragile and should not be treated as an early priority. |
| 245 | +- Advanced extension support should come after the core analysis workflow is |
| 246 | + stable. |
| 247 | + |
| 248 | +## Recommended Near-Term Priorities |
| 249 | + |
| 250 | +If development time is limited, the best next sequence is: |
| 251 | + |
| 252 | +1. Stabilise the bridge and input validation. |
| 253 | +2. Add the highest-value summary and indicator accessors. |
| 254 | +3. Expand tests and CI coverage. |
| 255 | +4. Publish example notebooks using the built-in datasets. |
| 256 | +5. Add selected parameter-setting methods for iterative modelling workflows. |
| 257 | + |
| 258 | +## Deferred Items |
| 259 | + |
| 260 | +These should remain explicitly out of scope until the wrapper matures: |
| 261 | + |
| 262 | +- reimplementing `mizer` logic in Python |
| 263 | +- supporting the full R API immediately |
| 264 | +- full parity for all plotting functions |
| 265 | +- broad support for arbitrary user-defined R callback registration from Python |
| 266 | + |
| 267 | +## Milestone Checklist |
| 268 | + |
| 269 | +### Milestone A: Usable Beta |
| 270 | + |
| 271 | +- clean install process documented |
| 272 | +- constructor and projection workflows stable |
| 273 | +- built-in dataset loading stable |
| 274 | +- core result accessors covered by tests |
| 275 | +- docs site published |
| 276 | + |
| 277 | +### Milestone B: Analysis-Ready |
| 278 | + |
| 279 | +- common summary and indicator functions wrapped |
| 280 | +- North Sea example notebook available |
| 281 | +- CI runs bridge tests automatically |
| 282 | +- version compatibility policy documented |
| 283 | + |
| 284 | +### Milestone C: Modelling-Ready |
| 285 | + |
| 286 | +- important setter methods wrapped |
| 287 | +- save/load workflow broadened |
| 288 | +- more realistic end-to-end examples added |
| 289 | +- error handling improved for model editing workflows |
0 commit comments