floatcsep 0.2.0__tar.gz → 0.3.0__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.
Files changed (211) hide show
  1. {floatcsep-0.2.0 → floatcsep-0.3.0}/.github/workflows/build-sphinx.yml +2 -5
  2. {floatcsep-0.2.0 → floatcsep-0.3.0}/.github/workflows/build-test.yml +7 -7
  3. {floatcsep-0.2.0 → floatcsep-0.3.0}/.github/workflows/publish-pypi.yml +8 -3
  4. {floatcsep-0.2.0 → floatcsep-0.3.0}/.github/workflows/release-tutorials.yml +2 -2
  5. floatcsep-0.3.0/.readthedocs.yaml +19 -0
  6. {floatcsep-0.2.0/floatcsep.egg-info → floatcsep-0.3.0}/PKG-INFO +15 -8
  7. {floatcsep-0.2.0 → floatcsep-0.3.0}/README.md +11 -5
  8. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/intro/installation.rst +3 -3
  9. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep/__init__.py +8 -2
  10. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep/evaluation.py +3 -3
  11. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep/experiment.py +27 -23
  12. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep/infrastructure/environments.py +113 -8
  13. floatcsep-0.3.0/floatcsep/infrastructure/logger.py +133 -0
  14. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep/infrastructure/registries.py +291 -212
  15. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep/infrastructure/repositories.py +250 -223
  16. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep/model.py +71 -20
  17. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep/postprocess/plot_handler.py +12 -13
  18. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep/postprocess/reporting.py +17 -6
  19. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep/utils/accessors.py +9 -5
  20. floatcsep-0.2.0/floatcsep/utils/readers.py → floatcsep-0.3.0/floatcsep/utils/file_io.py +180 -6
  21. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep/utils/helpers.py +13 -12
  22. {floatcsep-0.2.0 → floatcsep-0.3.0/floatcsep.egg-info}/PKG-INFO +15 -8
  23. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep.egg-info/SOURCES.txt +17 -5
  24. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep.egg-info/requires.txt +1 -1
  25. {floatcsep-0.2.0 → floatcsep-0.3.0}/requirements_dev.txt +1 -1
  26. {floatcsep-0.2.0 → floatcsep-0.3.0}/setup.cfg +1 -1
  27. floatcsep-0.3.0/tests/artifacts/models/docker_test/invalid_entrypoint/Dockerfile +2 -0
  28. floatcsep-0.3.0/tests/artifacts/models/docker_test/invalid_image/Dockerfile +1 -0
  29. floatcsep-0.3.0/tests/artifacts/models/docker_test/invalid_no_entrypoint/Dockerfile +2 -0
  30. floatcsep-0.3.0/tests/artifacts/models/docker_test/invalid_permission/Dockerfile +2 -0
  31. floatcsep-0.3.0/tests/artifacts/models/docker_test/valid/Dockerfile +2 -0
  32. floatcsep-0.3.0/tests/artifacts/models/docker_test/valid_custom_uid-gid/Dockerfile +4 -0
  33. floatcsep-0.3.0/tests/artifacts/models/td_model/forecasts/mock_2020-01-01_2020-01-02.csv +2 -0
  34. floatcsep-0.3.0/tests/artifacts/models/td_model/forecasts/mock_2020-01-02_2020-01-03.csv +2 -0
  35. floatcsep-0.2.0/tests/integration/test_model_interface.py → floatcsep-0.3.0/tests/integration/test_model_accessors.py +9 -125
  36. floatcsep-0.3.0/tests/integration/test_model_docker.py +119 -0
  37. floatcsep-0.3.0/tests/integration/test_model_infrastructure.py +130 -0
  38. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/unit/test_environments.py +142 -3
  39. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/unit/test_experiment.py +2 -1
  40. floatcsep-0.2.0/tests/unit/test_readers.py → floatcsep-0.3.0/tests/unit/test_io.py +16 -16
  41. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/unit/test_model.py +18 -17
  42. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/unit/test_plot_handler.py +2 -2
  43. floatcsep-0.3.0/tests/unit/test_registry.py +179 -0
  44. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/unit/test_reporting.py +1 -1
  45. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/unit/test_repositories.py +23 -19
  46. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/unit/test_utils.py +19 -19
  47. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_a/best_model.dat +1 -1
  48. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_h/custom_report.py +3 -3
  49. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_h/models.yml +1 -1
  50. floatcsep-0.3.0/tutorials/case_i/catalog.csep +7232 -0
  51. floatcsep-0.3.0/tutorials/case_i/config.yml +25 -0
  52. floatcsep-0.3.0/tutorials/case_i/models.yml +14 -0
  53. floatcsep-0.3.0/tutorials/case_i/tests.yml +6 -0
  54. floatcsep-0.2.0/.readthedocs.yaml +0 -16
  55. floatcsep-0.2.0/floatcsep/infrastructure/logger.py +0 -62
  56. floatcsep-0.2.0/tests/artifacts/models/td_model/forecasts/mock_2020-01-01_2020-01-02.csv +0 -2
  57. floatcsep-0.2.0/tests/artifacts/models/td_model/forecasts/mock_2020-01-02_2020-01-03.csv +0 -2
  58. floatcsep-0.2.0/tests/unit/test_registry.py +0 -95
  59. {floatcsep-0.2.0 → floatcsep-0.3.0}/CODE_OF_CONDUCT.md +0 -0
  60. {floatcsep-0.2.0 → floatcsep-0.3.0}/CONTRIBUTING.md +0 -0
  61. {floatcsep-0.2.0 → floatcsep-0.3.0}/CREDITS.md +0 -0
  62. {floatcsep-0.2.0 → floatcsep-0.3.0}/LICENSE +0 -0
  63. {floatcsep-0.2.0 → floatcsep-0.3.0}/MANIFEST.in +0 -0
  64. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/Makefile +0 -0
  65. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/_static/CSEP2_Logo_CMYK.png +0 -0
  66. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/_static/custom.js +0 -0
  67. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/_static/experiment_classes.png +0 -0
  68. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/_static/floatCSEP_Logo_CMYK.png +0 -0
  69. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/_static/float_scheme.png +0 -0
  70. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/_static/floatcsep_logo.svg +0 -0
  71. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/conf.py +0 -0
  72. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/guide/evaluation_config.rst +0 -0
  73. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/guide/executing_experiment.rst +0 -0
  74. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/guide/experiment_config.rst +0 -0
  75. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/guide/model_config.rst +0 -0
  76. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/guide/postprocess_config.rst +0 -0
  77. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/index.rst +0 -0
  78. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/intro/concepts.rst +0 -0
  79. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/reference/api_reference.rst +0 -0
  80. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/reference/commands.rst +0 -0
  81. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/reference/evaluation.rst +0 -0
  82. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/reference/experiment.rst +0 -0
  83. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/reference/infrastructure.rst +0 -0
  84. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/reference/model.rst +0 -0
  85. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/reference/postprocess.rst +0 -0
  86. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/reference/utilities.rst +0 -0
  87. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/tutorials/case_a.rst +0 -0
  88. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/tutorials/case_b.rst +0 -0
  89. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/tutorials/case_c.rst +0 -0
  90. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/tutorials/case_d.rst +0 -0
  91. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/tutorials/case_e.rst +0 -0
  92. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/tutorials/case_f.rst +0 -0
  93. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/tutorials/case_g.rst +0 -0
  94. {floatcsep-0.2.0 → floatcsep-0.3.0}/docs/tutorials/case_h.rst +0 -0
  95. {floatcsep-0.2.0 → floatcsep-0.3.0}/environment.yml +0 -0
  96. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep/commands/__init__.py +0 -0
  97. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep/commands/main.py +0 -0
  98. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep/infrastructure/__init__.py +0 -0
  99. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep/infrastructure/engine.py +0 -0
  100. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep/postprocess/__init__.py +0 -0
  101. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep/utils/__init__.py +0 -0
  102. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep.egg-info/dependency_links.txt +0 -0
  103. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep.egg-info/entry_points.txt +0 -0
  104. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep.egg-info/not-zip-safe +0 -0
  105. {floatcsep-0.2.0 → floatcsep-0.3.0}/floatcsep.egg-info/top_level.txt +0 -0
  106. {floatcsep-0.2.0 → floatcsep-0.3.0}/pyproject.toml +0 -0
  107. {floatcsep-0.2.0 → floatcsep-0.3.0}/requirements.txt +0 -0
  108. {floatcsep-0.2.0 → floatcsep-0.3.0}/setup.py +0 -0
  109. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/catalog.json +0 -0
  110. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/evaluations/tests_cfg.yml +0 -0
  111. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/gcmt/vcr_search.yaml +0 -0
  112. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/gcmt/vcr_summary.yaml +0 -0
  113. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/model.csv +0 -0
  114. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/model_cfg.yml +0 -0
  115. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/model_h5.hdf5 +0 -0
  116. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/qtree/TEAM=N10L11.csv +0 -0
  117. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/qtree/TEAM=N25L11.csv +0 -0
  118. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/td_model/input/args.txt +0 -0
  119. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/td_model/setup.cfg +0 -0
  120. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/Dockerfile +0 -0
  121. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/README.md +0 -0
  122. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/docs/userguide +0 -0
  123. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/examples/case_3/case3_run +0 -0
  124. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/examples/case_3/data/case3_catalog +0 -0
  125. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/forecasts/template_2023-01-01 +0 -0
  126. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/input/catalog +0 -0
  127. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/parameters +0 -0
  128. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/requirements +0 -0
  129. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/run +0 -0
  130. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/run_tests +0 -0
  131. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/setup +0 -0
  132. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/source/lib_a +0 -0
  133. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/source/lib_b +0 -0
  134. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/source/main +0 -0
  135. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/tests/test_liba +0 -0
  136. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/tests/test_libb +0 -0
  137. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/models/template/tests/test_main +0 -0
  138. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/regions/italy_midpoints +0 -0
  139. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/artifacts/regions/mock_region +0 -0
  140. {floatcsep-0.2.0/tests/qa → floatcsep-0.3.0/tests/e2e}/test_data.py +0 -0
  141. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/integration/experiment typologies +0 -0
  142. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/unit/test_accessors.py +0 -0
  143. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/unit/test_commands.py +0 -0
  144. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/unit/test_engine.py +0 -0
  145. {floatcsep-0.2.0 → floatcsep-0.3.0}/tests/unit/test_evaluation.py +0 -0
  146. {floatcsep-0.2.0 → floatcsep-0.3.0}/tox.ini +0 -0
  147. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_a/case_a.py +0 -0
  148. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_a/catalog.csep +0 -0
  149. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_a/config.yml +0 -0
  150. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_a/region.txt +0 -0
  151. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_b/case_b.py +0 -0
  152. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_b/catalog.json +0 -0
  153. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_b/config.yml +0 -0
  154. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_b/models/model_a.csv +0 -0
  155. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_b/models/model_b.csv +0 -0
  156. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_b/models/model_c.csv +0 -0
  157. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_b/models/model_d.csv +0 -0
  158. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_b/models.yml +0 -0
  159. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_b/region.txt +0 -0
  160. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_b/tests.yml +0 -0
  161. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_c/case_c.py +0 -0
  162. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_c/catalog.json +0 -0
  163. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_c/config.yml +0 -0
  164. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_c/models/model_a.csv +0 -0
  165. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_c/models/model_b.csv +0 -0
  166. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_c/models/model_c.csv +0 -0
  167. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_c/models/model_d.csv +0 -0
  168. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_c/models.yml +0 -0
  169. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_c/region.txt +0 -0
  170. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_c/tests.yml +0 -0
  171. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_d/config.yml +0 -0
  172. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_d/models.yml +0 -0
  173. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_d/tests.yml +0 -0
  174. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_e/case_e.py +0 -0
  175. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_e/catalog.json +0 -0
  176. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_e/config.yml +0 -0
  177. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_e/models/gulia-wiemer.ALM.italy.10yr.2010-01-01.xml +0 -0
  178. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_e/models/meletti.MPS04.italy.10yr.2010-01-01.xml +0 -0
  179. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_e/models/zechar.TripleS-CPTI.italy.10yr.2010-01-01.xml +0 -0
  180. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_e/models.yml +0 -0
  181. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_e/tests.yml +0 -0
  182. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_f/catalog.json +0 -0
  183. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_f/config.yml +0 -0
  184. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_f/etas/forecasts/etas_2016-11-14_2016-11-15.csv +0 -0
  185. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_f/etas/forecasts/etas_2016-11-15_2016-11-16.csv +0 -0
  186. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_f/etas/forecasts/etas_2016-11-16_2016-11-17.csv +0 -0
  187. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_f/etas/forecasts/etas_2016-11-17_2016-11-18.csv +0 -0
  188. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_f/etas/forecasts/etas_2016-11-18_2016-11-19.csv +0 -0
  189. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_f/etas/forecasts/etas_2016-11-19_2016-11-20.csv +0 -0
  190. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_f/etas/forecasts/etas_2016-11-20_2016-11-21.csv +0 -0
  191. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_f/models.yml +0 -0
  192. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_f/tests.yml +0 -0
  193. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_g/catalog.csv +0 -0
  194. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_g/config.yml +0 -0
  195. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_g/custom_plot_script.py +0 -0
  196. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_g/models.yml +0 -0
  197. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_g/pymock/Dockerfile +0 -0
  198. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_g/pymock/README.md +0 -0
  199. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_g/pymock/input/args.txt +0 -0
  200. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_g/pymock/pymock/__init__.py +0 -0
  201. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_g/pymock/pymock/libs.py +0 -0
  202. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_g/pymock/pymock/main.py +0 -0
  203. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_g/pymock/pyproject.toml +0 -0
  204. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_g/pymock/requirements.txt +0 -0
  205. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_g/pymock/run.py +0 -0
  206. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_g/pymock/setup.cfg +0 -0
  207. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_g/pymock/setup.py +0 -0
  208. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_g/tests.yml +0 -0
  209. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_h/catalog.csv +0 -0
  210. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_h/config.yml +0 -0
  211. {floatcsep-0.2.0 → floatcsep-0.3.0}/tutorials/case_h/tests.yml +0 -0
@@ -15,18 +15,15 @@ jobs:
15
15
  shell: bash -l {0}
16
16
 
17
17
  steps:
18
- - uses: actions/checkout@v2
18
+ - uses: actions/checkout@v4.2.2
19
19
  - uses: mamba-org/setup-micromamba@v1
20
20
  with:
21
21
  generate-run-shell: true
22
22
  environment-file: environment.yml
23
- create-args: >-
24
- python=${{ matrix.python-version }}
25
23
 
26
24
  - name: Install floatCSEP
27
25
  run: |
28
- pip install -r requirements_dev.txt
29
- pip install --no-deps -e .
26
+ pip install -e .[dev]
30
27
  python -c "import floatcsep; print('Version: ', floatcsep.__version__)"
31
28
 
32
29
  - name: Build documentation
@@ -21,7 +21,7 @@ jobs:
21
21
  shell: bash -l {0}
22
22
 
23
23
  steps:
24
- - uses: actions/checkout@v2
24
+ - uses: actions/checkout@v4.2.2
25
25
  - uses: mamba-org/setup-micromamba@v1
26
26
  with:
27
27
  generate-run-shell: true
@@ -29,18 +29,18 @@ jobs:
29
29
  create-args: >-
30
30
  python=${{ matrix.python-version }}
31
31
 
32
-
33
32
  - name: Install floatCSEP
34
33
  run: |
35
- pip install pytest pytest-cov vcrpy==4.3.1
36
- pip install --no-deps -e .
34
+ pip install -e .[dev]
37
35
  python -c "import floatcsep; print('Version: ', floatcsep.__version__)"
38
36
 
39
37
  - name: Test with pytest
40
38
  run: |
41
- pytest --durations=0 --cov=./ --cov-config=.coveragerc
39
+ pytest --durations=0
42
40
 
43
41
  - name: Upload coverage
44
42
  if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
45
- run: |
46
- bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}
43
+ uses: codecov/codecov-action@v3
44
+ with:
45
+ token: ${{ secrets.CODECOV_TOKEN }}
46
+ fail_ci_if_error: false
@@ -15,7 +15,7 @@ jobs:
15
15
  shell: bash -l {0}
16
16
 
17
17
  steps:
18
- - uses: actions/checkout@v2
18
+ - uses: actions/checkout@v4.2.2
19
19
  - uses: mamba-org/setup-micromamba@v1
20
20
  with:
21
21
  generate-run-shell: true
@@ -25,14 +25,19 @@ jobs:
25
25
 
26
26
  - name: Install py-build and setuptools-scm
27
27
  run: |
28
- micromamba run -n floatcsep python3 -m pip install --upgrade build setuptools-scm
28
+ micromamba run -n floatcsep pip install --upgrade build setuptools-scm
29
29
 
30
30
  - name: Build
31
31
  run: |
32
32
  micromamba run -n floatcsep python3 -m build --sdist --wheel --outdir dist/
33
33
 
34
+ - name: Check distribution files
35
+ run: |
36
+ micromamba run -n floatcsep pip install twine
37
+ micromamba run -n floatcsep twine check dist/*
38
+
34
39
  - name: Publish Package
35
- uses: pypa/gh-action-pypi-publish@v1.9.0
40
+ uses: pypa/gh-action-pypi-publish@v1.12.4
36
41
  with:
37
42
  user: __token__
38
43
  password: ${{ secrets.PYPI_API_TOKEN }}
@@ -10,14 +10,14 @@ jobs:
10
10
 
11
11
  steps:
12
12
  - name: Check out the code
13
- uses: actions/checkout@v3
13
+ uses: actions/checkout@v4.2.2
14
14
 
15
15
  - name: Zip the tutorials folder
16
16
  run: |
17
17
  zip -r tutorials.zip tutorials/
18
18
 
19
19
  - name: Upload the tutorials.zip to the release
20
- uses: softprops/action-gh-release@v1
20
+ uses: softprops/action-gh-release@v2.2.2
21
21
  with:
22
22
  files: tutorials.zip
23
23
  env:
@@ -0,0 +1,19 @@
1
+ version: 2
2
+
3
+ build:
4
+ os: "ubuntu-22.04"
5
+ tools:
6
+ python: "mambaforge-22.9"
7
+
8
+ conda:
9
+ environment: environment.yml
10
+
11
+ python:
12
+ install:
13
+ - method: pip
14
+ path: .
15
+ extra_requirements:
16
+ - dev
17
+
18
+ sphinx:
19
+ configuration: docs/conf.py
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: floatcsep
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: CSEP Floating Experiment application
5
5
  Home-page: https://github.com/cseptesting/floatcsep.git
6
6
  Author: Pablo Iturrieta
@@ -67,8 +67,9 @@ Requires-Dist: sphinx-rtd-theme; extra == "dev"
67
67
  Requires-Dist: sphinx_copybutton; extra == "dev"
68
68
  Requires-Dist: tables; extra == "dev"
69
69
  Requires-Dist: tox; extra == "dev"
70
- Requires-Dist: vcrpy==4.3.1; extra == "dev"
70
+ Requires-Dist: vcrpy; extra == "dev"
71
71
  Requires-Dist: xmltodict; extra == "dev"
72
+ Dynamic: license-file
72
73
 
73
74
  # CSEP Floating Experiments
74
75
 
@@ -110,19 +111,25 @@ Requires-Dist: xmltodict; extra == "dev"
110
111
  The core of `floatCSEP` is built around the `pyCSEP`
111
112
  package (https://github.com/sceccode/pycsep), which itself contains the core dependencies.
112
113
 
113
- The simplest way to install `floatCSEP`, is by creating a `conda`
114
- environment (https://conda.io - checkout Anaconda or Miniconda) and install `pyCSEP`
114
+ ## Stable Release
115
+
116
+ The simplest way to install `floatCSEP` is by creating a `conda`
117
+ environment (https://conda.io - checkout Anaconda or Miniforge) and install `floatCSEP`
115
118
  from `conda-forge`
116
119
 
117
120
  ```
118
- conda env create -n $NAME
121
+ conda create -n $NAME -y
119
122
  conda activate $NAME
120
- conda install -c conda-forge pycsep
123
+ conda install -c conda-forge floatcsep -y
121
124
  ```
122
125
 
126
+ ## Latest version
127
+
123
128
  Clone and install the floatCSEP source code using `pip`
124
129
 
125
130
  ```
131
+ conda create -n $NAME -y
132
+ conda activate $NAME
126
133
  git clone https://github.com/cseptesting/floatcsep
127
134
  cd floatcsep
128
135
  pip install .
@@ -155,7 +162,7 @@ the tutorials**!
155
162
  # Roadmap and Known Issues
156
163
 
157
164
  * Create tool to check a TD model's interface with ``floatcsep``
158
- * Define a dependency strategy to ensure experiments' reproducibility.
165
+ * Define a dependency strategy to ensure experiments' reproducibility (e.g., storing docker image).
159
166
  * Implement spatial database and HDF5 experiment storage feature
160
167
  * Set up task parallelization
161
168
  * Document the process of an experiment deployment
@@ -38,19 +38,25 @@
38
38
  The core of `floatCSEP` is built around the `pyCSEP`
39
39
  package (https://github.com/sceccode/pycsep), which itself contains the core dependencies.
40
40
 
41
- The simplest way to install `floatCSEP`, is by creating a `conda`
42
- environment (https://conda.io - checkout Anaconda or Miniconda) and install `pyCSEP`
41
+ ## Stable Release
42
+
43
+ The simplest way to install `floatCSEP` is by creating a `conda`
44
+ environment (https://conda.io - checkout Anaconda or Miniforge) and install `floatCSEP`
43
45
  from `conda-forge`
44
46
 
45
47
  ```
46
- conda env create -n $NAME
48
+ conda create -n $NAME -y
47
49
  conda activate $NAME
48
- conda install -c conda-forge pycsep
50
+ conda install -c conda-forge floatcsep -y
49
51
  ```
50
52
 
53
+ ## Latest version
54
+
51
55
  Clone and install the floatCSEP source code using `pip`
52
56
 
53
57
  ```
58
+ conda create -n $NAME -y
59
+ conda activate $NAME
54
60
  git clone https://github.com/cseptesting/floatcsep
55
61
  cd floatcsep
56
62
  pip install .
@@ -83,7 +89,7 @@ the tutorials**!
83
89
  # Roadmap and Known Issues
84
90
 
85
91
  * Create tool to check a TD model's interface with ``floatcsep``
86
- * Define a dependency strategy to ensure experiments' reproducibility.
92
+ * Define a dependency strategy to ensure experiments' reproducibility (e.g., storing docker image).
87
93
  * Implement spatial database and HDF5 experiment storage feature
88
94
  * Set up task parallelization
89
95
  * Document the process of an experiment deployment
@@ -18,7 +18,7 @@ To install **floatCSEP**, first a ``conda`` manager should be installed (https:/
18
18
 
19
19
  .. code-block:: console
20
20
 
21
- $ conda env create -n csep_env
21
+ $ conda create -n csep_env
22
22
  $ conda activate csep_env
23
23
 
24
24
  Then, clone and install the floatCSEP source code using ``pip``
@@ -60,7 +60,7 @@ Having a ``conda`` manager installed (https://conda.io), type in a console:
60
60
 
61
61
  .. code-block:: console
62
62
 
63
- $ conda env create -n csep_env
63
+ $ conda create -n csep_env
64
64
  $ conda activate csep_env
65
65
  $ conda install -c conda-forge floatcsep
66
66
 
@@ -95,7 +95,7 @@ It is recommended (not obligatory) to use a ``conda`` environment to make sure y
95
95
 
96
96
  .. code-block:: console
97
97
 
98
- $ conda env create -n csep_dev
98
+ $ conda create -n csep_dev
99
99
  $ conda activate csep_dev
100
100
  $ git clone https://github.com/${your_fork}/floatcsep
101
101
  $ cd floatcsep
@@ -2,7 +2,13 @@ from floatcsep import evaluation
2
2
  from floatcsep import experiment
3
3
  from floatcsep import model
4
4
  from floatcsep.infrastructure import engine, environments, registries, repositories, logger
5
- from floatcsep.utils import readers, accessors, helpers
5
+ from floatcsep.utils import file_io, accessors, helpers
6
6
  from floatcsep.postprocess import reporting, plot_handler
7
7
 
8
- __version__ = "0.1.4"
8
+ from importlib.metadata import version, PackageNotFoundError
9
+
10
+
11
+ try:
12
+ __version__ = version("floatcsep")
13
+ except PackageNotFoundError:
14
+ __version__ = "0.0.0"
@@ -287,7 +287,7 @@ class Evaluation:
287
287
  # Regular consistency/comparative test plots (e.g., many models)
288
288
  try:
289
289
  for time_str in timewindow:
290
- fig_path = registry.get_figure(time_str, self.name)
290
+ fig_path = registry.get_figure_key(time_str, self.name)
291
291
  results = self.read_results(time_str, models)
292
292
  ax = func(results, plot_args=fargs, **fkwargs)
293
293
  if "code" in fargs:
@@ -307,7 +307,7 @@ class Evaluation:
307
307
  registry.figures[time_str][fig_name] = os.path.join(
308
308
  time_str, "figures", fig_name
309
309
  )
310
- fig_path = registry.get_figure(time_str, fig_name)
310
+ fig_path = registry.get_figure_key(time_str, fig_name)
311
311
  ax = func(result, plot_args=fargs, **fkwargs, show=False)
312
312
  if "code" in fargs:
313
313
  exec(fargs["code"])
@@ -318,7 +318,7 @@ class Evaluation:
318
318
  pyplot.show()
319
319
 
320
320
  elif self.type in ["sequential", "sequential_comparative", "batch"]:
321
- fig_path = registry.get_figure(timewindow[-1], self.name)
321
+ fig_path = registry.get_figure_key(timewindow[-1], self.name)
322
322
  results = self.read_results(timewindow[-1], models)
323
323
  ax = func(results, plot_args=fargs, **fkwargs)
324
324
 
@@ -25,6 +25,7 @@ from floatcsep.utils.helpers import (
25
25
  parse_nested_dicts,
26
26
  )
27
27
  from floatcsep.infrastructure.engine import Task, TaskGraph
28
+ from floatcsep.infrastructure.logger import log_models_tree, log_results_tree
28
29
 
29
30
  log = logging.getLogger("floatLogger")
30
31
 
@@ -52,8 +53,8 @@ class Experiment:
52
53
  - growth (:class:`str`): `incremental` or `cumulative`
53
54
  - offset (:class:`float`): recurrence of forecast creation.
54
55
 
55
- For further details, see :func:`~floatcsep.utils.timewindows_ti`
56
- and :func:`~floatcsep.utils.timewindows_td`
56
+ For further details, see :func:`~floatcsep.utils.time_windows_ti`
57
+ and :func:`~floatcsep.utils.time_windows_td`
57
58
 
58
59
  region_config (dict): Contains all the spatial and magnitude
59
60
  specifications. It must contain the following keys:
@@ -75,6 +76,7 @@ class Experiment:
75
76
 
76
77
  model_config (str): Path to the models' configuration file
77
78
  test_config (str): Path to the evaluations' configuration file
79
+ run_mode (str): 'sequential' or 'parallel'
78
80
  default_test_kwargs (dict): Default values for the testing
79
81
  (seed, number of simulations, etc.)
80
82
  postprocess (dict): Contains the instruction for postprocessing
@@ -99,6 +101,7 @@ class Experiment:
99
101
  postprocess: str = None,
100
102
  default_test_kwargs: dict = None,
101
103
  rundir: str = "results",
104
+ run_mode: str = "sequential",
102
105
  report_hook: dict = None,
103
106
  **kwargs,
104
107
  ) -> None:
@@ -118,7 +121,7 @@ class Experiment:
118
121
  os.makedirs(os.path.join(workdir, rundir), exist_ok=True)
119
122
 
120
123
  self.name = name if name else "floatingExp"
121
- self.registry = ExperimentRegistry(workdir, rundir)
124
+ self.registry = ExperimentRegistry.factory(workdir=workdir, run_dir=rundir)
122
125
  self.results_repo = ResultsRepository(self.registry)
123
126
  self.catalog_repo = CatalogRepository(self.registry)
124
127
 
@@ -126,6 +129,7 @@ class Experiment:
126
129
  self.original_config = kwargs.get("original_config", None)
127
130
  self.original_run_dir = kwargs.get("original_rundir", None)
128
131
  self.run_dir = rundir
132
+ self.run_mode = run_mode
129
133
  self.seed = kwargs.get("seed", None)
130
134
  self.time_config = read_time_cfg(time_config, **kwargs)
131
135
  self.region_config = read_region_cfg(region_config, **kwargs)
@@ -143,7 +147,7 @@ class Experiment:
143
147
  log.info(f"Setting up experiment {self.name}:")
144
148
  log.info(f"\tStart: {self.start_date}")
145
149
  log.info(f"\tEnd: {self.end_date}")
146
- log.info(f"\tTime windows: {len(self.timewindows)}")
150
+ log.info(f"\tTime windows: {len(self.time_windows)}")
147
151
  log.info(f"\tRegion: {self.region.name if self.region else None}")
148
152
  log.info(
149
153
  f"\tMagnitude range: [{numpy.min(self.magnitudes)},"
@@ -175,7 +179,7 @@ class Experiment:
175
179
  Override built-in method to return the experiment attributes by also using the command
176
180
  ``experiment.{attr}``. Adds also to the experiment scope the keys of
177
181
  :attr:`region_config` or :attr:`time_config`. These are: ``start_date``, ``end_date``,
178
- ``timewindows``, ``horizon``, ``offset``, ``region``, ``magnitudes``, ``mag_min``,
182
+ ``time_windows``, ``horizon``, ``offset``, ``region``, ``magnitudes``, ``mag_min``,
179
183
  `mag_max``, ``mag_bin``, ``depth_min`` depth_max .
180
184
  """
181
185
 
@@ -295,8 +299,8 @@ class Experiment:
295
299
  """
296
300
  log.info("Staging models")
297
301
  for i in self.models:
298
- i.stage(self.timewindows)
299
- self.registry.add_forecast_registry(i)
302
+ i.stage(self.time_windows, run_mode=self.run_mode, run_dir=self.run_dir)
303
+ self.registry.add_model_registry(i)
300
304
 
301
305
  def set_tests(self, test_config: Union[str, Dict, List]) -> list:
302
306
  """
@@ -376,17 +380,17 @@ class Experiment:
376
380
  """
377
381
 
378
382
  # Set the file path structure
379
- self.registry.build_tree(self.timewindows, self.models, self.tests)
383
+ self.registry.build_tree(self.time_windows, self.models, self.tests, self.run_mode)
380
384
 
381
385
  log.debug("Pre-run forecast summary")
382
- self.registry.log_forecast_trees(self.timewindows)
386
+ log_models_tree(log, self.registry, self.time_windows)
383
387
  log.debug("Pre-run result summary")
384
- self.registry.log_results_tree()
388
+ log_results_tree(log, self.registry)
385
389
 
386
390
  log.info("Setting up experiment's tasks")
387
391
 
388
392
  # Get the time windows strings
389
- tw_strings = timewindow2str(self.timewindows)
393
+ tw_strings = timewindow2str(self.time_windows)
390
394
 
391
395
  # Prepare the testing catalogs
392
396
  task_graph = TaskGraph()
@@ -481,7 +485,7 @@ class Experiment:
481
485
  )
482
486
  # Set up the Sequential_Comparative Scores
483
487
  elif test_k.type == "sequential_comparative":
484
- tw_strs = timewindow2str(self.timewindows)
488
+ tw_strs = timewindow2str(self.time_windows)
485
489
  for model_j in self.models:
486
490
  task_k = Task(
487
491
  instance=test_k,
@@ -504,7 +508,7 @@ class Experiment:
504
508
  )
505
509
  # Set up the Batch comparative Scores
506
510
  elif test_k.type == "batch":
507
- time_str = timewindow2str(self.timewindows[-1])
511
+ time_str = timewindow2str(self.time_windows[-1])
508
512
  for model_j in self.models:
509
513
  task_k = Task(
510
514
  instance=test_k,
@@ -540,9 +544,9 @@ class Experiment:
540
544
  self.task_graph.run()
541
545
  log.info("Calculation completed")
542
546
  log.debug("Post-run forecast registry")
543
- self.registry.log_forecast_trees(self.timewindows)
547
+ log_models_tree(log, self.registry, self.time_windows)
544
548
  log.debug("Post-run result summary")
545
- self.registry.log_results_tree()
549
+ log_results_tree(log, self.registry)
546
550
 
547
551
  def read_results(self, test: Evaluation, window: str) -> List:
548
552
  """
@@ -559,7 +563,7 @@ class Experiment:
559
563
 
560
564
  """
561
565
  log.info("Creating reproducibility config file")
562
- repr_config = self.registry.get("repr_config")
566
+ repr_config = self.registry.get_attr("repr_config")
563
567
 
564
568
  # Dropping region to results folder if it is a file
565
569
  region_path = self.region_config.get("path", False)
@@ -604,7 +608,7 @@ class Experiment:
604
608
  "time_config": {
605
609
  i: j
606
610
  for i, j in self.time_config.items()
607
- if (i not in ("timewindows",) or extended)
611
+ if (i not in ("time_windows",) or extended)
608
612
  },
609
613
  "region_config": {
610
614
  i: j
@@ -731,7 +735,7 @@ class ExperimentComparison:
731
735
 
732
736
  def get_results(self):
733
737
 
734
- win_orig = timewindow2str(self.original.timewindows)
738
+ win_orig = timewindow2str(self.original.time_windows)
735
739
 
736
740
  tests_orig = self.original.tests
737
741
 
@@ -787,7 +791,7 @@ class ExperimentComparison:
787
791
 
788
792
  def get_filecomp(self):
789
793
 
790
- win_orig = timewindow2str(self.original.timewindows)
794
+ win_orig = timewindow2str(self.original.time_windows)
791
795
 
792
796
  tests_orig = self.original.tests
793
797
 
@@ -801,8 +805,8 @@ class ExperimentComparison:
801
805
  for tw in win_orig:
802
806
  results[test.name][tw] = dict.fromkeys(models_orig)
803
807
  for model in models_orig:
804
- orig_path = self.original.registry.get_result(tw, test, model)
805
- repr_path = self.reproduced.registry.get_result(tw, test, model)
808
+ orig_path = self.original.registry.get_result_key(tw, test, model)
809
+ repr_path = self.reproduced.registry.get_result_key(tw, test, model)
806
810
 
807
811
  results[test.name][tw][model] = {
808
812
  "hash": (self.get_hash(orig_path) == self.get_hash(repr_path)),
@@ -811,8 +815,8 @@ class ExperimentComparison:
811
815
  else:
812
816
  results[test.name] = dict.fromkeys(models_orig)
813
817
  for model in models_orig:
814
- orig_path = self.original.registry.get_result(win_orig[-1], test, model)
815
- repr_path = self.reproduced.registry.get_result(win_orig[-1], test, model)
818
+ orig_path = self.original.registry.get_result_key(win_orig[-1], test, model)
819
+ repr_path = self.reproduced.registry.get_result_key(win_orig[-1], test, model)
816
820
  results[test.name][model] = {
817
821
  "hash": (self.get_hash(orig_path) == self.get_hash(repr_path)),
818
822
  "byte2byte": filecmp.cmp(orig_path, repr_path),
@@ -9,6 +9,8 @@ import venv
9
9
  from abc import ABC, abstractmethod
10
10
  from typing import Union
11
11
 
12
+ import docker
13
+ from docker.errors import ImageNotFound, NotFound, APIError
12
14
  from packaging.specifiers import SpecifierSet
13
15
 
14
16
  log = logging.getLogger("floatLogger")
@@ -387,20 +389,123 @@ class DockerManager(EnvironmentManager):
387
389
  """
388
390
 
389
391
  def __init__(self, base_name: str, model_directory: str) -> None:
390
- self.base_name = base_name
392
+ self.base_name = base_name.replace(" ", "_")
391
393
  self.model_directory = model_directory
392
394
 
393
- def create_environment(self, force=False) -> None:
394
- pass
395
+ # use a lower-case slug for tags
396
+ slug = self.base_name.lower()
397
+ self.image_tag = f"{slug}_image"
398
+ self.container_name = f"{slug}_container"
395
399
 
396
- def env_exists(self) -> None:
397
- pass
400
+ # Docker SDK client
401
+ self.client = docker.from_env()
398
402
 
399
- def run_command(self, command) -> None:
400
- pass
403
+ def create_environment(self, force: bool = False) -> None:
404
+ """
405
+ Build (or rebuild) the Docker image for this model.
406
+ """
407
+
408
+ # If forced, remove the existing image
409
+ if force and self.env_exists():
410
+ log.info(f"[{self.base_name}] Removing existing image '{self.image_tag}'")
411
+ try:
412
+ self.client.images.remove(self.image_tag, force=True)
413
+ except APIError as e:
414
+ log.warning(f"[{self.base_name}] Could not remove image: {e}")
415
+
416
+ # If image is missing or rebuild was requested, build it now
417
+ if force or not self.env_exists():
418
+ build_path = os.path.abspath(self.model_directory)
419
+ uid, gid = os.getuid(), os.getgid()
420
+ build_args = {
421
+ "USER_UID": str(uid),
422
+ "USER_GID": str(gid),
423
+ }
424
+ log.info(f"[{self.base_name}] Building image '{self.image_tag}' from {build_path}")
425
+
426
+ build_logs = self.client.api.build(
427
+ path=build_path,
428
+ tag=self.image_tag,
429
+ rm=True,
430
+ decode=True,
431
+ buildargs=build_args,
432
+ nocache=False # todo: create model arg for --no-cache
433
+ )
434
+
435
+ # Stream each chunk
436
+ for chunk in build_logs:
437
+ if "stream" in chunk:
438
+ for line in chunk["stream"].splitlines():
439
+ log.debug(f"[{self.base_name}][build] {line}")
440
+ elif "errorDetail" in chunk:
441
+ msg = chunk["errorDetail"].get("message", "").strip()
442
+ log.error(f"[{self.base_name}][build error] {msg}")
443
+ raise RuntimeError(f"Docker build error: {msg}")
444
+ log.info(f"[{self.base_name}] Successfully built '{self.image_tag}'")
445
+
446
+ def env_exists(self) -> bool:
447
+ """
448
+ Checks if the Docker image with the given tag already exists.
449
+
450
+ Returns:
451
+ bool: True if the Docker image exists, False otherwise.
452
+ """
453
+ """
454
+ Returns True if an image with our tag already exists locally.
455
+ """
456
+ try:
457
+ self.client.images.get(self.image_tag)
458
+ return True
459
+ except ImageNotFound:
460
+ return False
461
+
462
+ def run_command(self, command=None) -> None:
463
+ """
464
+ Runs the model’s Docker container with input/ and forecasts/ mounted.
465
+ Streams logs and checks for non-zero exit codes.
466
+ """
467
+ model_root = os.path.abspath(self.model_directory)
468
+ mounts = {
469
+ os.path.join(model_root, "input"): {'bind': '/app/input', 'mode': 'rw'},
470
+ os.path.join(model_root, "forecasts"): {'bind': '/app/forecasts', 'mode': 'rw'},
471
+ }
472
+
473
+ uid, gid = os.getuid(), os.getgid()
474
+
475
+ log.info(f"[{self.base_name}] Launching container {self.container_name}")
476
+
477
+ try:
478
+ container = self.client.containers.run(
479
+ self.image_tag,
480
+ remove=False,
481
+ volumes=mounts,
482
+ detach=True,
483
+ user=f"{uid}:{gid}",
484
+ )
485
+ except docker.errors.APIError as e:
486
+ raise RuntimeError(f"[{self.base_name}] Failed to start container: {e}")
487
+
488
+ # Log output live
489
+ for line in container.logs(stream=True):
490
+ log.info(f"[{self.base_name}] {line.decode().rstrip()}")
491
+
492
+ # Wait for exit
493
+ exit_code = container.wait().get("StatusCode", 1)
494
+
495
+ # Clean up
496
+ container.remove(force=True)
497
+
498
+ if exit_code != 0:
499
+ raise RuntimeError(f"[{self.base_name}] Container exited with code {exit_code}")
500
+
501
+ log.info(f"[{self.base_name}] Container finished successfully.")
401
502
 
402
503
  def install_dependencies(self) -> None:
403
- pass
504
+ """
505
+ Installs dependencies for Docker-based models. This is typically handled by the Dockerfile,
506
+ so no additional action is needed here.
507
+ """
508
+ log.info("No additional dependency installation required for Docker environments.")
404
509
 
405
510
 
406
511
  class EnvironmentFactory: