Files
WebApi/webapi/orchestration/__init__.py

41 lines
2.4 KiB
Python

"""Each domain's cycle (CaCu, CaMa): from the staging the import leaves to the silver tables, the reference tables, the
publication catalog and the views dbt compiled, which the measures are answered over. [Hamilton](https://hamilton.apache.org/)
runs it.
Each step is a function of `cycle.py`. It takes the `Context` and, as parameters, the steps that must run before it;
Hamilton builds the graph from those names. Steps pass no data: everything goes through the database, by
Persistance's repositories (`ctx.repos`), so each one can run on its own.
migrate -> catalogs, registry, definitions, score_ados2
score_ados2 -> analyze_eeg (TEA: the ADOS-2 CSS and classification, quick)
analyze_eeg -> relate_ados2, load (TEA: the EEG analysis)
relate_ados2 -> load (TEA: the ADOS-2 association)
catalogs -> load, check_silver
load -> views, event_models, observe, check_silver
registry -> observe
event_models -> cohorts (only where there are cohorts: CaCu)
cohorts -> estimate
uv run python -m webapi.orchestration cycle cacu --from 2024 --to 2026
uv run python -m webapi.orchestration cycle cama --from 2025 --to 2025 --only event_models
uv run python -m webapi.orchestration confirm-risks cacu 3 --reason "revisado por clínica"
The `indicadores` service (`webapi.recomputation`) runs the same cycle, without `migrate`, each time an import writes
data.
Module | What it does
------------------|-------------
`cycle.py` | The steps
`runner.py` | `run(ctx, only=...)`: builds Hamilton's driver and runs the steps asked, in order
`context.py` | The `Context`: project, years, cut-off, rules file and repositories
`repositories.py` | `repositories_of(project)`: Persistance's repositories, by layer
`project.py` | A project's period types and cohort definitions
`connection.py` | Points Persistance at another database in the same process (tests)
`semantic_layer.py` | dbt's views a project's measures read, and the publication catalog
"""
from webapi.orchestration.context import Context
from webapi.orchestration.runner import Step, run, steps_of
__all__ = ["Context", "Step", "run", "steps_of"]