py-modelrunner 0.18.0__tar.gz → 0.18.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/PKG-INFO +1 -1
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/docs/source/parse_examples.py +1 -1
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/docs/source/run_autodoc.py +2 -3
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/docs/source/sphinx_simplify_typehints.py +4 -6
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/docs/source/user_manual.rst +13 -13
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/examples/io_hdf.py +2 -3
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/examples/io_json.py +2 -3
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/examples/io_yaml.py +2 -3
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/examples/model_class.py +1 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/examples/model_decorator.py +1 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/examples/model_function.py +1 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/examples/model_storage_output.py +1 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/examples/read_many.py +2 -3
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/examples/script_custom_func.py +3 -4
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/examples/script_function.py +2 -3
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/examples/script_many_classes.py +1 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/examples/script_minimal.py +2 -3
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/examples/script_model_class.py +1 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/examples/submit_function.py +3 -4
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/examples/submit_many_func.py +3 -4
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/examples/submit_many_iter.py +3 -4
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/examples/submit_shebang.py +4 -4
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/__main__.py +2 -3
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/_version.py +2 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/config.py +11 -12
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/model/__init__.py +1 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/model/base.py +21 -18
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/model/factory.py +7 -8
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/model/parameters.py +22 -23
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/run/__init__.py +2 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/run/__main__.py +1 -1
- py_modelrunner-0.18.2/modelrunner/run/compatibility/__init__.py +4 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/run/compatibility/triage.py +7 -8
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/run/compatibility/version0.py +5 -6
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/run/compatibility/version1.py +10 -11
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/run/compatibility/version2.py +2 -3
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/run/job.py +13 -11
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/run/launch.py +3 -5
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/run/results.py +26 -24
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/storage/__init__.py +1 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/storage/access_modes.py +3 -3
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/storage/attributes.py +6 -6
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/storage/backend/hdf.py +5 -5
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/storage/backend/json.py +2 -3
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/storage/backend/memory.py +5 -6
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/storage/backend/text_base.py +7 -7
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/storage/backend/utils.py +1 -1
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/storage/backend/yaml.py +2 -3
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/storage/backend/zarr.py +4 -5
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/storage/base.py +27 -28
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/storage/group.py +24 -24
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/storage/tools.py +4 -5
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/storage/trajectory.py +8 -9
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/storage/utils.py +27 -16
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/utils.py +14 -4
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/py_modelrunner.egg-info/PKG-INFO +1 -1
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/py_modelrunner.egg-info/SOURCES.txt +3 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/scripts/create_compatibility_files.py +3 -3
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/scripts/format_code.sh +3 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/scripts/run_tests.py +20 -4
- py_modelrunner-0.18.2/scripts/tests_debug.sh +16 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/test_compatibility.py +2 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/helpers/asserts.py +2 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/helpers/storage.py +3 -4
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/model/scripts/function.py +1 -1
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/model/scripts/function_main.py +2 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/model/scripts/function_marked.py +2 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/model/scripts/make_model.py +2 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/model/scripts/make_model_class.py +2 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/model/scripts/make_model_marked.py +2 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/model/test_model.py +20 -20
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/model/test_parameters.py +9 -9
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/requirements.txt +2 -1
- py_modelrunner-0.18.2/tests/run/scripts/custom.jinja +19 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/run/scripts/fail.py +1 -1
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/run/scripts/function.py +1 -1
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/run/scripts/print.py +1 -1
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/run/test_job.py +25 -11
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/run/test_results.py +5 -5
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/run/test_run_main.py +3 -3
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/storage/test_group.py +2 -2
- py_modelrunner-0.18.2/tests/storage/test_register_action.py +155 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/storage/test_storage_generic.py +14 -98
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/storage/test_storage_special.py +5 -5
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/storage/test_trajectory.py +6 -6
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/storage/test_utils.py +2 -2
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/test_config.py +4 -4
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/test_examples.py +1 -1
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/test_main.py +2 -2
- py_modelrunner-0.18.0/modelrunner/run/compatibility/__init__.py +0 -5
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/.github/workflows/build.yml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/.github/workflows/check_docs.yml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/.github/workflows/coverage_report.yml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/.github/workflows/release_pip.yml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/.gitignore +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/.readthedocs.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/LICENSE +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/README.md +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/docs/Makefile +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/docs/build_all.sh +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/docs/requirements.txt +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/docs/source/.gitignore +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/docs/source/conf.py +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/docs/source/examples.rst +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/docs/source/index.rst +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/docs/source/installation.rst +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/.gitignore +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/__init__.py +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/py.typed +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/run/templates/background.jinja +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/run/templates/foreground.jinja +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/run/templates/qsub.jinja +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/run/templates/srun.jinja +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/modelrunner/storage/backend/__init__.py +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/py_modelrunner.egg-info/dependency_links.txt +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/py_modelrunner.egg-info/not-zip-safe +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/py_modelrunner.egg-info/requires.txt +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/py_modelrunner.egg-info/top_level.txt +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/pyproject.toml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/requirements.txt +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/requirements_full.txt +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/scripts/performance_hdf5_zarr.py +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/scripts/tests_all.sh +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/scripts/tests_codestyle.sh +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/scripts/tests_coverage.sh +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/scripts/tests_parallel.sh +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/scripts/tests_run.sh +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/scripts/tests_types.sh +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/setup.cfg +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/0/result.hdf +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/0/result.json +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/0/result.pkl +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/0/result.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/1/array.json +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/1/array.pkl +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/1/array.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/1/array.zarr +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/1/array_col.json +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/1/array_col.pkl +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/1/array_col.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/1/array_col.zarr +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/1/dict.json +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/1/dict.pkl +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/1/dict.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/1/dict.zarr +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/1/object.json +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/1/object.pkl +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/1/object.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/1/object.zarr +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/array.hdf +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/array.json +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/array.pkl +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/array.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/array.zip +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/array_col.hdf +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/array_col.json +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/array_col.pkl +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/array_col.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/array_col.zip +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/dict.hdf +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/dict.json +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/dict.pkl +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/dict.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/dict.zip +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/nested.hdf +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/nested.json +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/nested.pkl +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/nested.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/2/nested.zip +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/array.hdf +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/array.json +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/array.pkl +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/array.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/array.zip +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/array_col.hdf +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/array_col.json +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/array_col.pkl +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/array_col.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/array_col.zip +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/dict.hdf +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/dict.json +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/dict.pkl +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/dict.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/dict.zip +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_array.hdf +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_array.json +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_array.pkl +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_array.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_array.zip +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_array_col.hdf +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_array_col.json +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_array_col.pkl +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_array_col.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_array_col.zip +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_dict.hdf +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_dict.json +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_dict.pkl +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_dict.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_dict.zip +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_nested.hdf +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_nested.json +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_nested.pkl +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_nested.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/model_nested.zip +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/nested.hdf +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/nested.json +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/nested.pkl +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/nested.yaml +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/compatibility/3/nested.zip +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/conftest.py +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/helpers/__init__.py +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/model/scripts/empty.py +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/run/scripts/script.py +0 -0
- {py_modelrunner-0.18.0 → py_modelrunner-0.18.2}/tests/test_version.py +0 -0
|
@@ -12,7 +12,7 @@ OUTPUT = ROOT / "docs" / "source" / "examples"
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def main():
|
|
15
|
-
"""
|
|
15
|
+
"""Parse all examples and write them in a special example module."""
|
|
16
16
|
# create the output directory
|
|
17
17
|
OUTPUT.mkdir(parents=True, exist_ok=True)
|
|
18
18
|
|
|
@@ -11,8 +11,8 @@ OUTPUT_PATH = "packages"
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def replace_in_file(infile, replacements, outfile=None):
|
|
14
|
-
"""
|
|
15
|
-
|
|
14
|
+
"""Reads in a file, replaces the given data using python formatting and writes back
|
|
15
|
+
the result to a file.
|
|
16
16
|
|
|
17
17
|
Args:
|
|
18
18
|
infile (str):
|
|
@@ -22,7 +22,6 @@ def replace_in_file(infile, replacements, outfile=None):
|
|
|
22
22
|
outfile (str):
|
|
23
23
|
Output file to which the data is written. If it is omitted, the
|
|
24
24
|
input file will be overwritten instead
|
|
25
|
-
|
|
26
25
|
"""
|
|
27
26
|
if outfile is None:
|
|
28
27
|
outfile = infile
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Simple sphinx plug-in that simplifies type information in function signatures
|
|
3
|
-
"""
|
|
1
|
+
"""Simple sphinx plug-in that simplifies type information in function signatures."""
|
|
4
2
|
|
|
5
3
|
import collections
|
|
6
4
|
import re
|
|
@@ -32,7 +30,7 @@ REPLACEMENTS_REGEX = {
|
|
|
32
30
|
def process_signature(
|
|
33
31
|
app, what: str, name: str, obj, options, signature, return_annotation
|
|
34
32
|
):
|
|
35
|
-
"""Process signature by applying replacement rules"""
|
|
33
|
+
"""Process signature by applying replacement rules."""
|
|
36
34
|
if signature is not None:
|
|
37
35
|
for key, value in REPLACEMENTS.items():
|
|
38
36
|
signature = signature.replace(key, value)
|
|
@@ -42,7 +40,7 @@ def process_signature(
|
|
|
42
40
|
|
|
43
41
|
|
|
44
42
|
def sphinx_display_parameters(app, what, name, obj, options, lines):
|
|
45
|
-
"""
|
|
43
|
+
"""Helper function to display parameters in sphinx documentation.
|
|
46
44
|
|
|
47
45
|
Example:
|
|
48
46
|
This function should be connected to the 'autodoc-process-docstring'
|
|
@@ -69,6 +67,6 @@ def sphinx_display_parameters(app, what, name, obj, options, lines):
|
|
|
69
67
|
|
|
70
68
|
|
|
71
69
|
def setup(app):
|
|
72
|
-
"""
|
|
70
|
+
"""Set up hooks for this sphinx plugin."""
|
|
73
71
|
app.connect("autodoc-process-signature", process_signature)
|
|
74
72
|
app.connect("autodoc-process-docstring", sphinx_display_parameters)
|
|
@@ -20,33 +20,33 @@ Defining parameters using :mod:`~modelrunner.model.parameters`:
|
|
|
20
20
|
Defining models using :mod:`~modelrunner.model`:
|
|
21
21
|
Models are augmented functions, which define input, calculations, and output.
|
|
22
22
|
Models can be conveniently created by decorating a function or by subclassing
|
|
23
|
-
:class:`~modelrunner.model.ModelBase`, which is built on the parameter classes.
|
|
23
|
+
:class:`~modelrunner.model.base.ModelBase`, which is built on the parameter classes.
|
|
24
24
|
|
|
25
|
-
Model results are captured by :mod:`~modelrunner.results`:
|
|
26
|
-
Results are returned as the special :class:`~modelrunner.results.Result`, which
|
|
25
|
+
Model results are captured by :mod:`~modelrunner.run.results`:
|
|
26
|
+
Results are returned as the special :class:`~modelrunner.run.results.Result`, which
|
|
27
27
|
keeps track of the input parameters and the data calculated by the model.
|
|
28
|
-
:class:`~modelrunner.results.ResultCollection` describes a collections of the same
|
|
28
|
+
:class:`~modelrunner.run.results.ResultCollection` describes a collections of the same
|
|
29
29
|
model evoked with different parameter values.
|
|
30
30
|
|
|
31
31
|
Submitting models to HPC using :mod:`~modelrunner.run`:
|
|
32
32
|
A single model can be submitted to a compute node using :func:`~modelrunner.run.job.submit_job`,
|
|
33
33
|
e.g., to run the computation on a high performance compute cluster.
|
|
34
34
|
A parameter study using multiple jobs can be conveniently submitted using :func:`~modelrunner.run.job.submit_jobs`.
|
|
35
|
-
The results written to one directory can then be conveniently analyzed using :
|
|
35
|
+
The results written to one directory can then be conveniently analyzed using :func:`~modelrunner.run.results.ResultCollection.from_folder`.
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
Design philosophy
|
|
39
39
|
-----------------
|
|
40
40
|
|
|
41
|
-
The main requirements for the
|
|
41
|
+
The main requirements for the package can be summarized as follows:
|
|
42
42
|
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
43
|
+
- **Usability**: The user should not need to think about how data is stored in different files. The :class:`~modelrunner.run.results.Result` class should simply work.
|
|
44
|
+
- **Flexibility**: :mod:`~modelrunner.storage` should provide a unified interface to write data in multiple file formats (JSON, YAML, HDF, zarr, ...)
|
|
45
|
+
- **Stability**: Future versions of the package should be able to read older files even when the internal definitions of file formats change
|
|
46
|
+
- **Modularity**: Different parts of the package (like :mod:`~modelrunner.storage`, :mod:`~modelrunner.model.parameters`, and :mod:`~modelrunner.run`) should be rather independent of each other, so they can be used in isolation
|
|
47
|
+
- **Extensibility**: Models inherting from :class:`~modelrunner.model.base.ModelBase` should be easy to subclass to implement more complicated requirements (e.g., additional parameters)
|
|
48
|
+
- **Self-explainability**: The files should in principle contain all information to reconstruct the data, even if the :mod:`modelrunner` package is no longer available.
|
|
49
|
+
- **Efficiency**: The files should only store necessary information.
|
|
50
50
|
|
|
51
51
|
The last point results in particular constraints if we want to store temporal simulation results.
|
|
52
52
|
In most cases, there are are some data that are kept fixed for the simulation (describing physical parameters) and others that evolve with time.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
This example shows reading and writing data using HDF files.
|
|
2
|
+
"""This example shows reading and writing data using HDF files.
|
|
4
3
|
|
|
5
4
|
.. codeauthor:: David Zwicker <david.zwicker@ds.mpg.de>
|
|
6
5
|
"""
|
|
@@ -11,7 +10,7 @@ from modelrunner import Result, run_function_with_cmd_args
|
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
def number_range(start: float = 1, length: int = 3):
|
|
14
|
-
"""
|
|
13
|
+
"""Create an ascending list of numbers."""
|
|
15
14
|
return start + np.arange(length)
|
|
16
15
|
|
|
17
16
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
This example shows reading and writing data using JSON files.
|
|
2
|
+
"""This example shows reading and writing data using JSON files.
|
|
4
3
|
|
|
5
4
|
.. codeauthor:: David Zwicker <david.zwicker@ds.mpg.de>
|
|
6
5
|
"""
|
|
@@ -9,7 +8,7 @@ from modelrunner import Result, run_function_with_cmd_args
|
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
def multiply(a: float = 1, b: float = 2):
|
|
12
|
-
"""Multiply two numbers"""
|
|
11
|
+
"""Multiply two numbers."""
|
|
13
12
|
return a * b
|
|
14
13
|
|
|
15
14
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
This example shows reading and writing data using JSON files.
|
|
2
|
+
"""This example shows reading and writing data using JSON files.
|
|
4
3
|
|
|
5
4
|
.. codeauthor:: David Zwicker <david.zwicker@ds.mpg.de>
|
|
6
5
|
"""
|
|
@@ -9,7 +8,7 @@ from modelrunner import Result, run_function_with_cmd_args
|
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
def multiply(a: float = 1, b: float = 2):
|
|
12
|
-
"""Multiply two numbers"""
|
|
11
|
+
"""Multiply two numbers."""
|
|
13
12
|
return a * b
|
|
14
13
|
|
|
15
14
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
This example shows how a collection of results can be read.
|
|
2
|
+
"""This example shows how a collection of results can be read.
|
|
4
3
|
|
|
5
4
|
.. codeauthor:: David Zwicker <david.zwicker@ds.mpg.de>
|
|
6
5
|
"""
|
|
@@ -11,7 +10,7 @@ from modelrunner import ResultCollection, make_model_class
|
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
def multiply(a: float = 1, b: float = 2):
|
|
14
|
-
"""Multiply two numbers"""
|
|
13
|
+
"""Multiply two numbers."""
|
|
15
14
|
return a * b
|
|
16
15
|
|
|
17
16
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3 -m modelrunner
|
|
2
|
-
"""
|
|
3
|
-
This example shows how a function is turned into a model using decorators.
|
|
2
|
+
"""This example shows how a function is turned into a model using decorators.
|
|
4
3
|
|
|
5
4
|
.. codeauthor:: David Zwicker <david.zwicker@ds.mpg.de>
|
|
6
5
|
"""
|
|
@@ -9,11 +8,11 @@ import modelrunner
|
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
def do_not_calculate(a=1, b=2):
|
|
12
|
-
"""This function should not be run"""
|
|
11
|
+
"""This function should not be run."""
|
|
13
12
|
raise RuntimeError("This must not run")
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
@modelrunner.make_model
|
|
17
16
|
def calculate(a=1, b=2):
|
|
18
|
-
"""This function has been marked as a model"""
|
|
17
|
+
"""This function has been marked as a model."""
|
|
19
18
|
print(a * b)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
This example shows how a function is turned into a model explicitly.
|
|
2
|
+
"""This example shows how a function is turned into a model explicitly.
|
|
4
3
|
|
|
5
4
|
.. codeauthor:: David Zwicker <david.zwicker@ds.mpg.de>
|
|
6
5
|
"""
|
|
@@ -9,7 +8,7 @@ from modelrunner import run_function_with_cmd_args
|
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
def multiply(a: float = 1, b: float = 2):
|
|
12
|
-
"""Multiply two numbers"""
|
|
11
|
+
"""Multiply two numbers."""
|
|
13
12
|
return a * b
|
|
14
13
|
|
|
15
14
|
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env python3 -m modelrunner
|
|
2
|
-
"""
|
|
3
|
-
This example displays a minimal script defining a model using a `main` function.
|
|
2
|
+
"""This example displays a minimal script defining a model using a `main` function.
|
|
4
3
|
|
|
5
4
|
.. codeauthor:: David Zwicker <david.zwicker@ds.mpg.de>
|
|
6
5
|
"""
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
def main(a=1, b=2):
|
|
10
|
-
"""Multiply two numbers"""
|
|
9
|
+
"""Multiply two numbers."""
|
|
11
10
|
print(a * b)
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
This example shows how to submit a model to a queuing system.
|
|
2
|
+
"""This example shows how to submit a model to a queuing system.
|
|
4
3
|
|
|
5
4
|
Note that the method `foreground` just runs the script locally, thus not really queuing. To
|
|
6
5
|
actually queue a job on a high performance computing cluster, replace the `method`
|
|
7
|
-
argument by something more suitable; see the documentation.
|
|
6
|
+
argument by something more suitable; see the documentation.
|
|
8
7
|
|
|
9
8
|
.. codeauthor:: David Zwicker <david.zwicker@ds.mpg.de>
|
|
10
9
|
"""
|
|
@@ -14,7 +13,7 @@ from modelrunner import make_model, submit_job
|
|
|
14
13
|
|
|
15
14
|
@make_model
|
|
16
15
|
def multiply(a: float = 1, b: float = 2):
|
|
17
|
-
"""Multiply two numbers"""
|
|
16
|
+
"""Multiply two numbers."""
|
|
18
17
|
return a * b
|
|
19
18
|
|
|
20
19
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
This example shows how to submit the same model with multiple parameters.
|
|
2
|
+
"""This example shows how to submit the same model with multiple parameters.
|
|
4
3
|
|
|
5
4
|
Note that the method `foreground` just runs the script locally, thus not really queuing. To
|
|
6
5
|
actually queue a job on a high performance computing cluster, replace the `method`
|
|
7
|
-
argument by something more suitable; see the documentation.
|
|
6
|
+
argument by something more suitable; see the documentation.
|
|
8
7
|
|
|
9
8
|
.. codeauthor:: David Zwicker <david.zwicker@ds.mpg.de>
|
|
10
9
|
"""
|
|
@@ -15,7 +14,7 @@ from modelrunner import make_model, submit_jobs
|
|
|
15
14
|
|
|
16
15
|
@make_model
|
|
17
16
|
def main(a: float = 1, b: float = 2):
|
|
18
|
-
"""Multiply two numbers"""
|
|
17
|
+
"""Multiply two numbers."""
|
|
19
18
|
return a * b
|
|
20
19
|
|
|
21
20
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
This example shows how to submit the same model with multiple parameters.
|
|
2
|
+
"""This example shows how to submit the same model with multiple parameters.
|
|
4
3
|
|
|
5
4
|
Note that the method `foreground` just runs the script locally, thus not really queuing. To
|
|
6
5
|
actually queue a job on a high performance computing cluster, replace the `method`
|
|
7
|
-
argument by something more suitable; see the documentation.
|
|
6
|
+
argument by something more suitable; see the documentation.
|
|
8
7
|
|
|
9
8
|
.. codeauthor:: David Zwicker <david.zwicker@ds.mpg.de>
|
|
10
9
|
"""
|
|
@@ -15,7 +14,7 @@ from modelrunner import make_model, submit_job
|
|
|
15
14
|
|
|
16
15
|
@make_model
|
|
17
16
|
def main(a: float = 1, b: float = 2):
|
|
18
|
-
"""Multiply two numbers"""
|
|
17
|
+
"""Multiply two numbers."""
|
|
19
18
|
return a * b
|
|
20
19
|
|
|
21
20
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env python3 -m modelrunner.run --output data.hdf5 --method foreground
|
|
2
|
-
"""
|
|
3
|
-
|
|
2
|
+
"""This example shows how to submit a model to a queuing system using the magic line
|
|
3
|
+
above.
|
|
4
4
|
|
|
5
5
|
Note that the method `foreground` just runs the script locally, thus not really
|
|
6
6
|
queuing. To actually queue a job on a high performance computing cluster, replace the
|
|
7
|
-
`method` argument by something more suitable; see the documentation.
|
|
7
|
+
`method` argument by something more suitable; see the documentation.
|
|
8
8
|
|
|
9
9
|
.. codeauthor:: David Zwicker <david.zwicker@ds.mpg.de>
|
|
10
10
|
"""
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def multiply(a: float = 1, b: float = 2):
|
|
14
|
-
"""Multiply two numbers"""
|
|
14
|
+
"""Multiply two numbers."""
|
|
15
15
|
return a * b
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Main module allowing to use the package to wrap existing code
|
|
1
|
+
"""Main module allowing to use the package to wrap existing code.
|
|
3
2
|
|
|
4
3
|
.. codeauthor:: David Zwicker <david.zwicker@ds.mpg.de>
|
|
5
4
|
"""
|
|
@@ -12,7 +11,7 @@ from modelrunner import Result, run_script
|
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
def run_script_from_command_line() -> Result:
|
|
15
|
-
"""
|
|
14
|
+
"""Helper function that runs a model from flags specified at the command line.
|
|
16
15
|
|
|
17
16
|
The function detects models automatically by trying several methods until one yields
|
|
18
17
|
a unique model to run:
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Handles configuration variables
|
|
1
|
+
"""Handles configuration variables.
|
|
3
2
|
|
|
4
3
|
.. autosummary::
|
|
5
4
|
:nosignatures:
|
|
@@ -20,7 +19,7 @@ from .model.parameters import DeprecatedParameter, Parameter
|
|
|
20
19
|
|
|
21
20
|
|
|
22
21
|
class Config(collections.UserDict):
|
|
23
|
-
"""
|
|
22
|
+
"""Class handling the package configuration."""
|
|
24
23
|
|
|
25
24
|
def __init__(
|
|
26
25
|
self,
|
|
@@ -67,21 +66,21 @@ class Config(collections.UserDict):
|
|
|
67
66
|
self.mode = mode
|
|
68
67
|
|
|
69
68
|
def load(self, path: str | Path):
|
|
70
|
-
"""
|
|
69
|
+
"""Load configuration from yaml file."""
|
|
71
70
|
import yaml
|
|
72
71
|
|
|
73
72
|
with open(path) as fp:
|
|
74
73
|
self.update(yaml.safe_load(fp))
|
|
75
74
|
|
|
76
75
|
def save(self, path: str | Path):
|
|
77
|
-
"""
|
|
76
|
+
"""Save configuration to yaml file."""
|
|
78
77
|
import yaml
|
|
79
78
|
|
|
80
79
|
with open(path, "w") as fp:
|
|
81
80
|
yaml.dump(self.to_dict(), fp)
|
|
82
81
|
|
|
83
82
|
def __getitem__(self, key: str):
|
|
84
|
-
"""
|
|
83
|
+
"""Retrieve item `key`"""
|
|
85
84
|
parameter = self.data[key]
|
|
86
85
|
if isinstance(parameter, Parameter):
|
|
87
86
|
return parameter.convert()
|
|
@@ -89,7 +88,7 @@ class Config(collections.UserDict):
|
|
|
89
88
|
return parameter
|
|
90
89
|
|
|
91
90
|
def __setitem__(self, key: str, value):
|
|
92
|
-
"""
|
|
91
|
+
"""Update item `key` with `value`"""
|
|
93
92
|
if self.mode == "insert":
|
|
94
93
|
self.data[key] = value
|
|
95
94
|
|
|
@@ -107,20 +106,20 @@ class Config(collections.UserDict):
|
|
|
107
106
|
raise ValueError(f"Unsupported configuration mode `{self.mode}`")
|
|
108
107
|
|
|
109
108
|
def __delitem__(self, key: str):
|
|
110
|
-
"""
|
|
109
|
+
"""Removes item `key`"""
|
|
111
110
|
if self.mode == "insert":
|
|
112
111
|
del self.data[key]
|
|
113
112
|
else:
|
|
114
113
|
raise RuntimeError("Configuration is not in `insert` mode")
|
|
115
114
|
|
|
116
115
|
def copy(self) -> Config:
|
|
117
|
-
"""
|
|
116
|
+
"""Return a copy of the configuration."""
|
|
118
117
|
obj = self.__class__(self._default, self.mode)
|
|
119
118
|
obj.update(self)
|
|
120
119
|
return obj
|
|
121
120
|
|
|
122
121
|
def to_dict(self) -> dict[str, Any]:
|
|
123
|
-
"""
|
|
122
|
+
"""Convert the configuration to a simple dictionary.
|
|
124
123
|
|
|
125
124
|
Returns:
|
|
126
125
|
dict: A representation of the configuration in a normal :class:`dict`.
|
|
@@ -128,12 +127,12 @@ class Config(collections.UserDict):
|
|
|
128
127
|
return {k: v for k, v in self.items()}
|
|
129
128
|
|
|
130
129
|
def __repr__(self) -> str:
|
|
131
|
-
"""
|
|
130
|
+
"""Represent the configuration as a string."""
|
|
132
131
|
return f"{self.__class__.__name__}({repr(self.to_dict())})"
|
|
133
132
|
|
|
134
133
|
@contextlib.contextmanager
|
|
135
134
|
def __call__(self, values: dict[str, Any] | None = None, **kwargs):
|
|
136
|
-
"""
|
|
135
|
+
"""Context manager temporarily changing the configuration.
|
|
137
136
|
|
|
138
137
|
Args:
|
|
139
138
|
values (dict): New configuration parameters
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Base class describing a model
|
|
1
|
+
"""Base class describing a model.
|
|
3
2
|
|
|
4
3
|
.. codeauthor:: David Zwicker <david.zwicker@ds.mpg.de>
|
|
5
4
|
"""
|
|
@@ -14,6 +13,7 @@ from datetime import datetime
|
|
|
14
13
|
from typing import TYPE_CHECKING, Any, Sequence
|
|
15
14
|
|
|
16
15
|
from ..storage import ModeType, StorageGroup, open_storage
|
|
16
|
+
from ..utils import is_serial_or_mpi_root
|
|
17
17
|
from .parameters import DeprecatedParameter, HideParameter, Parameterized
|
|
18
18
|
|
|
19
19
|
if TYPE_CHECKING:
|
|
@@ -21,7 +21,7 @@ if TYPE_CHECKING:
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
class ModelBase(Parameterized, metaclass=ABCMeta):
|
|
24
|
-
"""
|
|
24
|
+
"""Base class for describing models."""
|
|
25
25
|
|
|
26
26
|
name: str | None = None
|
|
27
27
|
"""str: the name of the model"""
|
|
@@ -36,7 +36,7 @@ class ModelBase(Parameterized, metaclass=ABCMeta):
|
|
|
36
36
|
mode: ModeType = "insert",
|
|
37
37
|
strict: bool = False,
|
|
38
38
|
):
|
|
39
|
-
"""
|
|
39
|
+
"""Initialize the parameters of the object.
|
|
40
40
|
|
|
41
41
|
Args:
|
|
42
42
|
parameters (dict):
|
|
@@ -67,7 +67,7 @@ class ModelBase(Parameterized, metaclass=ABCMeta):
|
|
|
67
67
|
|
|
68
68
|
@property
|
|
69
69
|
def storage(self) -> StorageGroup:
|
|
70
|
-
""":class:`StorageGroup`: Storage to which data can be written"""
|
|
70
|
+
""":class:`StorageGroup`: Storage to which data can be written."""
|
|
71
71
|
if self._storage is None:
|
|
72
72
|
if self.output is None:
|
|
73
73
|
raise RuntimeError("Output file needs to be specified")
|
|
@@ -75,17 +75,20 @@ class ModelBase(Parameterized, metaclass=ABCMeta):
|
|
|
75
75
|
return self._storage
|
|
76
76
|
|
|
77
77
|
def close(self) -> None:
|
|
78
|
-
"""
|
|
78
|
+
"""Close any opened storages."""
|
|
79
79
|
if self._storage is not None:
|
|
80
80
|
self._storage.close()
|
|
81
81
|
self._storage = None
|
|
82
82
|
|
|
83
83
|
@abstractmethod
|
|
84
84
|
def __call__(self):
|
|
85
|
-
"""
|
|
85
|
+
"""Main method calculating the result.
|
|
86
|
+
|
|
87
|
+
Needs to be specified by sub-class
|
|
88
|
+
"""
|
|
86
89
|
|
|
87
90
|
def get_result(self, data: Any = None) -> Result:
|
|
88
|
-
"""
|
|
91
|
+
"""Get the result as a :class:`~model.Result` object.
|
|
89
92
|
|
|
90
93
|
Args:
|
|
91
94
|
data:
|
|
@@ -103,7 +106,7 @@ class ModelBase(Parameterized, metaclass=ABCMeta):
|
|
|
103
106
|
return Result(self, data, info=info)
|
|
104
107
|
|
|
105
108
|
def write_result(self, result: Result | None = None) -> None:
|
|
106
|
-
"""
|
|
109
|
+
"""Write the result to the output file.
|
|
107
110
|
|
|
108
111
|
Args:
|
|
109
112
|
result:
|
|
@@ -127,7 +130,7 @@ class ModelBase(Parameterized, metaclass=ABCMeta):
|
|
|
127
130
|
|
|
128
131
|
@classmethod
|
|
129
132
|
def _prepare_argparser(cls, name: str | None = None) -> argparse.ArgumentParser:
|
|
130
|
-
"""
|
|
133
|
+
"""Create argument parser for setting parameters of this model.
|
|
131
134
|
|
|
132
135
|
Args:
|
|
133
136
|
name (str):
|
|
@@ -167,7 +170,7 @@ class ModelBase(Parameterized, metaclass=ABCMeta):
|
|
|
167
170
|
def from_command_line(
|
|
168
171
|
cls, args: Sequence[str] | None = None, name: str | None = None
|
|
169
172
|
) -> ModelBase:
|
|
170
|
-
"""
|
|
173
|
+
"""Create model from command line parameters.
|
|
171
174
|
|
|
172
175
|
Args:
|
|
173
176
|
args (list):
|
|
@@ -207,7 +210,7 @@ class ModelBase(Parameterized, metaclass=ABCMeta):
|
|
|
207
210
|
def run_from_command_line(
|
|
208
211
|
cls, args: Sequence[str] | None = None, name: str | None = None
|
|
209
212
|
) -> Result:
|
|
210
|
-
"""
|
|
213
|
+
"""Run model using command line parameters.
|
|
211
214
|
|
|
212
215
|
Args:
|
|
213
216
|
args (list):
|
|
@@ -223,13 +226,13 @@ class ModelBase(Parameterized, metaclass=ABCMeta):
|
|
|
223
226
|
|
|
224
227
|
# run the model
|
|
225
228
|
result = mdl.get_result()
|
|
226
|
-
|
|
227
|
-
|
|
229
|
+
|
|
230
|
+
# write the results
|
|
231
|
+
if mdl.output and is_serial_or_mpi_root():
|
|
232
|
+
# Write the results to a file if `output` is specified and if we are on the
|
|
233
|
+
# root node of an MPI run (or a serial program). The second check is a
|
|
234
|
+
# safe-guard against writing data on sub-nodes during an MPI program.
|
|
228
235
|
mdl.write_result(result=result)
|
|
229
|
-
# else:
|
|
230
|
-
# # display the results on stdout
|
|
231
|
-
# storage = MemoryStorage()
|
|
232
|
-
# result.to_file(storage)
|
|
233
236
|
|
|
234
237
|
# close the output file
|
|
235
238
|
mdl.close()
|