Skip to content

Commit 9a4c946

Browse files
committed
repo: Restructured floatcsep repo layout. Registries, repos, task handlers, environments and loggers are now part of infrastructure submodule. Report and Plot_handlers (old postprocess) now placed onto postprocess submodule. accessors, readers, and helpers (old utils.pt) now places onto utils submodule. modified tests and docs accordingly
1 parent e0abfc8 commit 9a4c946

33 files changed

+374
-269
lines changed

docs/intro/concepts.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The CSEP experiments consist in the prospective evaluation of probabilistic eart
1212
A Floating Testing Experiment encapsulates each experiment into its own runnable environment, taking advantage of version control (i.e. ``git``), open-data repositories (e.g. `Zenodo <https://zenodo.org>`_) and Infrastructure as Code (e.g. `Docker <https://docker.com>`_) technologies, making it reproducible, re-usable and shareable during the time scale of the
1313
evaluations.
1414

15-
``feCSEP`` goals
15+
``floatCSEP`` goals
1616
----------------
1717

1818
This is an application to deploy reproducible and prospective experiments of earthquake forecasting, namely a Floating Eperiment, that can operate independent of a particular testing server. With this application, researchers, institutions and users can

docs/reference/api_reference.rst

Lines changed: 131 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ Commands
1010
The commands and entry-points with which to call `floatcsep` from the terminal
1111
are:
1212

13-
.. :currentmodule:: floatcsep.cmd.main
13+
.. :currentmodule:: floatcsep.commands.main
1414
15-
.. automodule:: floatcsep.cmd.main
15+
.. automodule:: floatcsep.commands.main
1616

1717
.. autosummary::
1818
:toctree: generated
@@ -104,46 +104,25 @@ A test is defined using the :class:`Evaluation` class.
104104
Accessors
105105
---------
106106

107-
.. :currentmodule:: floatcsep.accessors
107+
.. :currentmodule:: floatcsep.utils.accessors
108108
109-
.. automodule:: floatcsep.accessors
109+
.. automodule:: floatcsep.utils.accessors
110110

111111
.. autosummary::
112112
:toctree: generated
113113

114114
from_zenodo
115115
from_git
116+
download_file
117+
check_hash
116118

117119

118-
Environments
119-
------------
120+
Helper Functions
121+
----------------
120122

121-
.. :currentmodule:: floatcsep.environments
123+
.. :currentmodule:: floatcsep.utils.helpers
122124
123-
.. automodule:: floatcsep.environments
124-
125-
.. autosummary::
126-
:toctree: generated
127-
128-
CondaManager
129-
CondaManager.create_environment
130-
CondaManager.env_exists
131-
CondaManager.install_dependencies
132-
CondaManager.run_command
133-
134-
VenvManager
135-
CondaManager.create_environment
136-
CondaManager.env_exists
137-
CondaManager.install_dependencies
138-
CondaManager.run_command
139-
140-
141-
Utilities
142-
---------
143-
144-
.. :currentmodule:: floatcsep.utils
145-
146-
.. automodule:: floatcsep.utils
125+
.. automodule:: floatcsep.utils.helpers
147126

148127
.. autosummary::
149128
:toctree: generated
@@ -154,9 +133,6 @@ Utilities
154133
read_region_config
155134
timewindows_ti
156135
timewindows_td
157-
Task
158-
Task.run
159-
Task.check_exist
160136
timewindow2str
161137
plot_sequential_likelihood
162138
magnitude_vs_time
@@ -168,9 +144,9 @@ Utilities
168144
Readers
169145
-------
170146

171-
.. :currentmodule:: floatcsep.readers
147+
.. :currentmodule:: floatcsep.utils.readers
172148
173-
.. automodule:: floatcsep.readers
149+
.. automodule:: floatcsep.utils.readers
174150

175151
.. autosummary::
176152
:toctree: generated
@@ -184,3 +160,122 @@ Readers
184160
serialize
185161

186162

163+
Environments
164+
------------
165+
166+
.. :currentmodule:: floatcsep.infrastructure.environments
167+
168+
.. automodule:: floatcsep.infrastructure.environments
169+
170+
.. autosummary::
171+
:toctree: generated
172+
173+
CondaManager
174+
CondaManager.create_environment
175+
CondaManager.env_exists
176+
CondaManager.install_dependencies
177+
CondaManager.run_command
178+
179+
VenvManager
180+
CondaManager.create_environment
181+
CondaManager.env_exists
182+
CondaManager.install_dependencies
183+
CondaManager.run_command
184+
185+
186+
Registries
187+
----------
188+
189+
.. :currentmodule:: floatcsep.infrastructure.registries
190+
191+
.. automodule:: floatcsep.infrastructure.registries
192+
193+
.. autosummary::
194+
:toctree: generated
195+
196+
FileRegistry
197+
FileRegistry.abs
198+
FileRegistry.absdir
199+
FileRegistry.rel
200+
FileRegistry.rel_dir
201+
FileRegistry.file_exists
202+
203+
ForecastRegistry
204+
ForecastRegistry.get
205+
ForecastRegistry.get_forecast
206+
ForecastRegistry.dir
207+
ForecastRegistry.fmt
208+
ForecastRegistry.as_dict
209+
ForecastRegistry.forecast_exist
210+
ForecastRegistry.build_tree
211+
ForecastRegistry.log_tree
212+
213+
ExperimentRegistry
214+
ExperimentRegistry.add_forecast_registry
215+
ExperimentRegistry.get_forecast_registry
216+
ExperimentRegistry.log_forecast_trees
217+
ExperimentRegistry.get
218+
ExperimentRegistry.get_result
219+
ExperimentRegistry.get_test_catalog
220+
ExperimentRegistry.get_figure
221+
ExperimentRegistry.result_exist
222+
ExperimentRegistry.as_dict
223+
ExperimentRegistry.build_tree
224+
ExperimentRegistry.log_results_tree
225+
226+
227+
Repositories
228+
------------
229+
230+
.. :currentmodule:: floatcsep.infrastructure.repositories
231+
232+
.. automodule:: floatcsep.infrastructure.repositories
233+
234+
.. autosummary::
235+
:toctree: generated
236+
237+
ForecastRepository
238+
ForecastRepository.factory
239+
240+
CatalogForecastRepository
241+
CatalogForecastRepository.load_forecast
242+
CatalogForecastRepository._load_single_forecast
243+
244+
GriddedForecastRepository.load_forecast
245+
GriddedForecastRepository._get_or_load_forecast
246+
GriddedForecastRepository._load_single_forecast
247+
248+
ResultsRepository
249+
ResultsRepository._load_result
250+
ResultsRepository.load_results
251+
ResultsRepository.write_result
252+
253+
CatalogRepository
254+
CatalogRepository.set_main_catalog
255+
CatalogRepository.catalog
256+
CatalogRepository.get_test_cat
257+
CatalogRepository.set_test_cat
258+
CatalogRepository.set_input_cat
259+
260+
261+
Engine
262+
------
263+
264+
.. :currentmodule:: floatcsep.infrastructure.engine
265+
266+
.. automodule:: floatcsep.infrastructure.engine
267+
268+
.. autosummary::
269+
:toctree: generated
270+
271+
Task
272+
Task.sign_match
273+
Task.run
274+
Task.check_exist
275+
276+
TaskGraph
277+
TaskGraph.ntasks
278+
TaskGraph.add
279+
TaskGraph.add_dependency
280+
TaskGraph.run
281+
TaskGraph.check_exist

examples/case_h/custom_report.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from floatcsep.report import MarkdownReport
2-
from floatcsep.utils import timewindow2str
1+
from floatcsep.postprocess.reporting import MarkdownReport
2+
from floatcsep.utils.helpers import timewindow2str
33

44

55
def main(experiment):

floatcsep/__init__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
from floatcsep import logger
2-
from floatcsep import registry
3-
from floatcsep import accessors
41
from floatcsep import evaluation
52
from floatcsep import experiment
63
from floatcsep import model
7-
from floatcsep import readers
4+
from floatcsep.infrastructure import engine, environments, registries, repositories, logger
5+
from floatcsep.utils import readers, accessors, helpers
6+
from floatcsep.postprocess import reporting, plot_handler
87

98
__version__ = "0.1.4"

floatcsep/commands/__init__.py

Whitespace-only changes.

floatcsep/cmd/main.py renamed to floatcsep/commands/main.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33

44
from floatcsep import __version__
55
from floatcsep.experiment import Experiment, ExperimentComparison
6-
from floatcsep.logger import setup_logger, set_console_log_level
7-
from floatcsep.postprocess import plot_results, plot_forecasts, plot_catalogs, plot_custom
8-
from floatcsep.report import generate_report, reproducibility_report
6+
from floatcsep.infrastructure.logger import setup_logger, set_console_log_level
7+
from floatcsep.postprocess.plot_handler import (
8+
plot_results,
9+
plot_forecasts,
10+
plot_catalogs,
11+
plot_custom,
12+
)
13+
from floatcsep.postprocess.reporting import generate_report, reproducibility_report
914

1015
setup_logger()
1116
log = logging.getLogger("floatLogger")

floatcsep/evaluation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from matplotlib import pyplot
88

99
from floatcsep.model import Model
10-
from floatcsep.registry import ExperimentRegistry
11-
from floatcsep.utils import parse_csep_func
10+
from floatcsep.infrastructure.registries import ExperimentRegistry
11+
from floatcsep.utils.helpers import parse_csep_func
1212

1313

1414
class Evaluation:

floatcsep/experiment.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,18 @@
1313

1414

1515
from floatcsep.evaluation import Evaluation
16-
from floatcsep.logger import add_fhandler
16+
from floatcsep.infrastructure.logger import add_fhandler
1717
from floatcsep.model import Model, TimeDependentModel
18-
from floatcsep.registry import ExperimentRegistry
19-
from floatcsep.repository import ResultsRepository, CatalogRepository
20-
from floatcsep.utils import (
18+
from floatcsep.infrastructure.registries import ExperimentRegistry
19+
from floatcsep.infrastructure.repositories import ResultsRepository, CatalogRepository
20+
from floatcsep.utils.helpers import (
2121
NoAliasLoader,
2222
read_time_cfg,
2323
read_region_cfg,
24-
Task,
25-
TaskGraph,
2624
timewindow2str,
2725
parse_nested_dicts,
2826
)
29-
27+
from floatcsep.infrastructure.engine import Task, TaskGraph
3028

3129
log = logging.getLogger("floatLogger")
3230

@@ -150,7 +148,7 @@ def __init__(
150148
self.model_config = models if isinstance(models, str) else None
151149
self.test_config = tests if isinstance(tests, str) else None
152150

153-
logger = kwargs.get("logging", True)
151+
logger = kwargs.get("logging", False)
154152
if logger:
155153
filename = "experiment.log" if logger is True else logger
156154
self.registry.logger = os.path.join(workdir, rundir, filename)

floatcsep/infrastructure/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)