Skip to content

Commit 3e2d1b6

Browse files
smngvlkzBenSchZA
andauthored
Updated radCAD to be compatible with latest cadCAD and Python 3.8-3.12 (#68)
* Updated cadCAD and radCAD to v0.14.0, and passed all tests with latest cadCAD v0.5.3 * Updated cadCAD and radCAD to v0.14.0, and passed all tests with latest cadCAD v0.5.3 * Updated cadCAD and radCAD to v0.14.0, and passed all tests with latest cadCAD v0.5.3 * Update pyproject.toml * Update documentation from Poetry to PDM * Migrate requirements from Poetry to PDM * Add Nox (Tox alternative) tests * Update tests to be compatible with Python 3.11+ * Update GitHub action * Update GitHub action * Update GitHub action * Update GitHub action * Update GitHub action * Update GitHub action * Update GitHub action * Update Nox file to fix recursion depth limit issue on Windows * Update Nox file to fix recursion depth limit issue on Windows * Update pytest version * Update pytest version * Remove pytest-monitor due to CI error * Increase recursion limit * Add RADCAD_BACKEND env variable to override during Windows tests * Add RADCAD_BACKEND env variable to override during Windows tests * Add RADCAD_BACKEND env variable to override during Windows tests * Resolve issue with tables and remove Windows from CI pipeline * Update CHANGELOG, README, CI to include Windows for one last attempt * Remove tables override for Python3.8 * Override deepcopy method when using Windows to avoid recurrsion errors * Override radCAD backend when using Windows to avoid recurrsion errors * Override radCAD backend when using Windows to avoid recurrsion errors * Remove deepcopy method switch for Windows * Pop Engine argument even if overridden by env variable --------- Co-authored-by: Benjamin Scholtz <[email protected]>
1 parent 1a0519e commit 3e2d1b6

18 files changed

+6593
-4632
lines changed

.github/workflows/python.yml

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,47 @@ name: Build Status
66
on:
77
push:
88
branches: [ master ]
9+
paths:
10+
- '**.py'
911
pull_request:
1012
branches: [ master ]
13+
paths:
14+
- '**.py'
1115

1216
jobs:
1317
build:
14-
15-
runs-on: ubuntu-latest
18+
runs-on: ${{ matrix.os }}-latest
1619
strategy:
20+
fail-fast: false
1721
matrix:
18-
python-version: [3.8, 3.9, '3.10']
22+
python-major-version: [3]
23+
python-minor-version: [8, 9, 10, 11, 12]
24+
os: [ubuntu, macOS, windows]
25+
env:
26+
python-version: ${{ format('{0}.{1}', matrix.python-major-version, matrix.python-minor-version) }}
1927

2028
steps:
21-
- uses: actions/checkout@v2
22-
- name: Set up Python ${{ matrix.python-version }}
29+
- uses: actions/checkout@v3
30+
- name: Set up Python ${{ env.python-version }}
2331
uses: actions/setup-python@v2
2432
with:
25-
python-version: ${{ matrix.python-version }}
26-
- name: Install dependencies
33+
python-version: ${{ env.python-version }}
34+
- name: Install build dependencies
2735
run: |
2836
python -m pip install --upgrade pip setuptools wheel
29-
python -m pip install poetry
30-
poetry install -E compat
31-
- name: Test with pytest
37+
python -m pip install pdm nox
38+
- name: Install build dependencies for MacOS
39+
if: ${{ matrix.os == 'macOS' }}
40+
run: |
41+
brew install hdf5 c-blosc
42+
- name: Install radCAD dependencies for Python 3.8
43+
if: ${{ matrix.python-minor-version == 8 }}
44+
run: |
45+
pdm sync -d -G compat --lockfile pdm-py38.lock
46+
- name: Install radCAD dependencies for Python 3.9+
47+
if: ${{ matrix.python-minor-version >= 9 }}
48+
run: |
49+
pdm sync -d -G compat --lockfile pdm.lock
50+
- name: Run tests using Nox
3251
run: |
33-
PYTHONPATH=. poetry run python3 -m pytest tests
52+
python -m nox -s tests-${{ env.python-version }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,5 @@ scratchpad**
161161
.pymon
162162
.benchmarks/
163163
.idea/
164+
*.prof
165+
.pdm-python

CHANGELOG.md

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,182 +1,273 @@
11
# Change Log
2+
23
All notable changes to this project will be documented in this file.
34

45
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
56
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
67

8+
## [0.14.0] - 2024-09-04
9+
10+
### Added
11+
12+
- Support for Python versions 3.11, 3.12
13+
- GitHub Action CI pipeline tests for Windows, MacOS
14+
15+
### Changed
16+
17+
- Migrated from using Poetry to PDM to support overriding/ignoring subdependencies and switching based on Python version (e.g. cadCAD, which has removed support for Python 3.8, but which we'd like to continue supporting)
18+
- Implemented tests and benchmarking across Python versions using Nox (equivalent of Tox that uses Python instead of yaml for configuration)
19+
- Updated cadCAD dependency to v0.5.3 to ensure compatibility with Python 3.10+ when using "compatibility mode"
20+
- Added RADCAD_BACKEND environment variable to override radCAD's backend, specifically used for Windows tests to avoid recursion depth errors
21+
722
## [0.13.0] - 2023-10-26
23+
824
### Added
25+
926
- Ability to override the method used for performing deep copies, e.g. using Pickle instead of standard library for better performance
1027
- Ability to use dataclasses instead of dictionaries to configure System Parameters, enabling much better developer experience including typing of System Parameters
1128
- Ability to use nested dataclasses to configure System Parameters to enable creating categories or namespaces of System Parameters for better management of large models, see tests for examples of how this works
1229
- Better typing of all core radCAD code, see `radcad.types`
1330

1431
### Changed
32+
1533
- End of support for Python 3.7, due to dependecies we now only support >= 3.8
1634
- Major refactor of core code to use specification for simulation execution in the form of an abstract base class named `SimulationExecutionSpecification`, enabling much better understanding, customisation, and extension of radCAD core code
1735

1836
## [0.12.0] - 2022-09-05
37+
1938
### Added
39+
2040
- Add typing
2141

2242
### Changed
43+
2344
- Enable mutation of simulation hook `Context`
2445
- Possibly breaking change for anyone using hooks: `before_simulation(simulation: Simulation)` changed to `before_simulation(context: Context)`
2546

2647
## [0.11.1] - 2022-09-03
48+
2749
### Added
50+
2851
- Add support for parameters dataclass
2952
- Add support for single value parameters (i.e. not a list)
3053

3154
## [0.11.0] - 2022-09-03
55+
3256
### Changed
57+
3358
- Adapted core deepcopy processes to be more efficient and avoid unintended mutation of state between policy and state update functions
3459

3560
## [0.10.1] - 2022-09-02
61+
3662
### Changed
63+
3764
- Updated to use "radCAD" logging instance
3865

3966
## [0.10.0] - 2022-09-01
67+
4068
### Added
69+
4170
- Add a `deepcopy_method` Engine argument to allow setting a custom deepcopy method e.g. `copy.deepcopy` instead of default Pickle methods
4271

4372
### Changed
73+
4474
- Fix edge case of unintended mutation of state passed to state update function from policy function (see issue #53)
4575

4676
## [0.9.1] - 2022-07-26
77+
4778
### Added
79+
4880
- Thanks to @vmeylan for a developer experience contribution in `radcad/core.py`: make `_update_state()` error messages more verbose for easier debugging
4981

5082
## [0.9.0] - 2022-06-14
83+
5184
### Changed
85+
5286
- `Context` passed to `before_subset(context)` hook will now correctly receive a single parameter subset and not all subsets
5387
- This could be a breaking change for anyone that relied on the `before_subset()` hook - the `before_run()` hook will still receive all subsets, as at that point of simulation the specific subset is unknown
5488
- See "NOTE" in `engine.py`: Each parameter is a list of all subsets in before_run() method and a single subset in before_subset()
5589

5690
## [0.8.4] - 2021-09-04
91+
5792
### Added
93+
5894
- Overide for `__deepcopy__` method of Executable class to enable deepcopy after a simulation/experiment has been run
5995
- Add regression test for above `__deepcopy__` method
6096

6197
## [0.8.3] - 2021-08-30
98+
6299
### Changed
63-
- Update radCAD package version in __init__.py
100+
101+
- Update radCAD package version in **init**.py
64102

65103
## [0.8.2] - 2021-08-27
104+
66105
### Changed
106+
67107
- Update cadCAD from v0.4.23 to v0.4.27, fixing breaking changes to compat module
68108

69109
## [0.8.1] - 2021-08-24
110+
70111
### Changed
112+
71113
- Minor update: Module package version & package details
72114

73115
## [0.8.0] - 2021-06-28
116+
74117
### Changed
118+
75119
- `engine.deepcopy` setting now disables deepcopy of State as well as Policy Signals
76120

77121
## [0.7.1] - 2021-06-11
122+
78123
### Added
79-
- Fix for Pathos multiprocessing issue - "NameError: Name '_' is not defined". See https://github.com/uqfoundation/multiprocess/issues/6
124+
125+
- Fix for Pathos multiprocessing issue - "NameError: Name '\_' is not defined". See https://github.com/uqfoundation/multiprocess/issues/6
80126

81127
## [0.7.0] - 2021-06-09
128+
82129
### Changed
130+
83131
- Experiment and Simulation extend the Executable class (not a breaking change, but significant improvement to API)
84132

85133
## [0.6.7] - 2021-06-08
134+
86135
### Added
136+
87137
- `generate_cartesian_product_parameter_sweep(...)` method to `radcad.utils`
88138

89139
## [0.6.6] - 2021-06-08
140+
90141
### Added
142+
91143
- Base wrapper class
92144

93145
## [0.6.5] - 2021-06-03
146+
94147
### Added
148+
95149
- Iterable Models
96150

97151
## [0.6.4] - 2021-05-31
152+
98153
### Added
154+
99155
- Support for Python 3.9 (<4.0)
100156

101157
## [0.6.3] - 2021-04-30
158+
102159
### Added
160+
103161
- Update dependencies
104162

105163
## [0.6.2] - 2021-04-30
164+
106165
### Added
166+
107167
- Removed Streamlit which requires Python <3.9
108168

109169
## [0.6.1] - 2021-04-30
170+
110171
### Added
172+
111173
- Support for Python 3.9
112174

113175
### Changed
176+
114177
- Added tests for hook functionality, fixed minor error, removed WIP tag
115178
- Updated log statement for "Starting simulation ..."
116179

117180
## [0.6.0] - 2021-02-20
181+
118182
### Changed
183+
119184
- Moved Ray and dependencies to optional extension `extension-backend-ray`
120185
- Refactored `Backend` module
121186
- Introduced idea of extensions
122187

123188
## [0.5.6] - 2021-02-10
189+
124190
### Added
191+
125192
- `drop_substeps` (default False) option to Engine
126193

127194
## [0.5.5] - 2021-02-08
195+
128196
### Changed
197+
129198
- Incorrect argument given to Pathos pool for number of processes
130199
- Update memory benchmarks to not test A/B testing
131200
- Change Python max version from <3.9 to <=3.9
132201
- Update hook API and add subset hook
133202

134203
## [0.5.4] - 2021-02-08
204+
135205
### Added
206+
136207
- Error tracebacks to exceptions data
137208

138209
## [0.5.3] - 2021-02-07
210+
139211
### Changed
212+
140213
- Close Pathos, Multiprocessing pools
141214

142215
## [0.5.2] - 2021-02-06
216+
143217
### Changed
218+
144219
- Pandas version ^1.0.0
145220

146221
## [0.5.1] - 2021-02-06
222+
147223
### Added
224+
148225
- Add hook example for saving experiment results to HDF5 file format
149226

150227
## [0.5.0] - 2021-02-05
228+
151229
### Added
230+
152231
- Predator-prey benchmark test
153232

154233
### Changed
234+
155235
- Refactor core from Rust to Python
156236

157237
## [0.4.1] - 2021-02-02
238+
158239
### Added
240+
159241
- Add engine `deepcopy` option, to disable deepcopy of state
160242

161243
### Changed
244+
162245
- Significant performance tuning of Rust core for 2x increase in speed and reduction in memory use
163246

164247
## [0.4.0] - 2021-02-01
248+
165249
### Changed
250+
166251
- Fix of critical state update bug, added regression test `test_paralell_state_update()` to `test_regression.py`
167252

168253
## [0.3.1] - 2021-01-31
254+
169255
### Changed
256+
170257
- Python version downgrade to `^3.7` for Streamlit
171258

172259
## [0.3.0] - 2021-01-30
260+
173261
### Added
262+
174263
- Error handling (default `Engine(raise_exceptions=True)`)
175264
- Partial simulation results (on run failure / exception)
176265
- Memory profiling using mprof
177266

178267
### Changed
268+
179269
- Default simulation engine (changed from MULTIPROCESSING to PATHOS)
180270

181271
### Removed
272+
182273
-

Makefile

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,41 @@
1-
test:
2-
poetry run python3 -m pytest tests
3-
4-
profile-memory-radcad:
5-
poetry run python3 -m mprof run --include-children benchmarks/benchmark_memory_radcad.py && poetry run python3 -m mprof plot
6-
7-
profile-memory-cadcad:
8-
poetry run python3 -m mprof run --include-children benchmarks/benchmark_memory_cadcad.py && poetry run python3 -m mprof plot
9-
10-
coverage:
11-
poetry run python3 -m pytest tests --cov=radcad
12-
poetry run coveralls
13-
141
start-jupyter-lab:
15-
poetry run python3 -m jupyter lab
2+
pdm run jupyter lab
163

174
plotly-jupyter-lab-support:
185
# JupyterLab renderer support
196
jupyter labextension install [email protected]
207
# OPTIONAL: Jupyter widgets extension
21-
jupyter labextension install @jupyter-widgets/jupyterlab-manager [email protected]
8+
jupyter labextension install @jupyter-widgets/jupyterlab-manager [email protected]
9+
10+
lock-py38:
11+
pdm lock \
12+
-G compat -G extension-backend-ray \
13+
--python="==3.8.*" \
14+
--lockfile pdm-py38.lock
15+
16+
lock-py39+:
17+
pdm lock \
18+
-G compat -G extension-backend-ray \
19+
--python=">=3.9" \
20+
--lockfile pdm.lock
21+
22+
lock: lock-py38 lock-py39+
23+
24+
install-py38:
25+
pdm install --lockfile pdm-py38.lock
26+
27+
install-py39+:
28+
pdm install --lockfile pdm.lock
29+
30+
test:
31+
pdm run pytest tests
32+
33+
coverage:
34+
pdm run pytest tests --cov=radcad
35+
pdm run coveralls
36+
37+
profile-memory-radcad:
38+
pdm run mprof run --include-children benchmarks/benchmark_memory_radcad.py && pdm run mprof plot
39+
40+
profile-memory-cadcad:
41+
pdm run mprof run --include-children benchmarks/benchmark_memory_cadcad.py && pdm run mprof plot

0 commit comments

Comments
 (0)