Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipelines Cleanup #254

Merged
merged 18 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pipelines/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Pipelines
File renamed without changes.
68 changes: 0 additions & 68 deletions pipelines/default_priors.py

This file was deleted.

4 changes: 3 additions & 1 deletion pipelines/fit_model.py → pipelines/fit_pyrenew_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

import jax
import numpy as np
from build_model import build_model_from_dir
from build_pyrenew_model import (

Check warning on line 7 in pipelines/fit_pyrenew_model.py

View check run for this annotation

Codecov / codecov/patch

pipelines/fit_pyrenew_model.py#L7

Added line #L7 was not covered by tests
build_model_from_dir,
)


def fit_and_save_model(
Expand Down
24 changes: 13 additions & 11 deletions pipelines/forecast_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
import tomli_w
import tomllib
from prep_data import process_and_save_state
from prep_eval_data import save_eval_data

Check warning on line 14 in pipelines/forecast_state.py

View check run for this annotation

Codecov / codecov/patch

pipelines/forecast_state.py#L14

Added line #L14 was not covered by tests
from pygit2 import Repository
from save_eval_data import save_eval_data

numpyro.set_host_device_count(4)

from fit_model import fit_and_save_model # noqa
from generate_predictive import generate_and_save_predictions # noqa
from fit_pyrenew_model import fit_and_save_model # noqa
from generate_predictive import (

Check warning on line 20 in pipelines/forecast_state.py

View check run for this annotation

Codecov / codecov/patch

pipelines/forecast_state.py#L19-L20

Added lines #L19 - L20 were not covered by tests
generate_and_save_predictions,
) # noqa


def record_git_info(model_run_dir: Path):
Expand Down Expand Up @@ -125,13 +127,13 @@
return None


def postprocess_forecast(
def plot_and_save_state_forecast(

Check warning on line 130 in pipelines/forecast_state.py

View check run for this annotation

Codecov / codecov/patch

pipelines/forecast_state.py#L130

Added line #L130 was not covered by tests
model_run_dir: Path, pyrenew_model_name: str, timeseries_model_name: str
) -> None:
result = subprocess.run(
[
"Rscript",
"pipelines/postprocess_state_forecast.R",
"pipelines/plot_and_save_state_forecast.R",
f"{model_run_dir}",
"--pyrenew-model-name",
f"{pyrenew_model_name}",
Expand All @@ -141,7 +143,7 @@
capture_output=True,
)
if result.returncode != 0:
raise RuntimeError(f"postprocess_forecast: {result.stderr}")
raise RuntimeError(f"plot_and_save_state_forecast: {result.stderr}")

Check warning on line 146 in pipelines/forecast_state.py

View check run for this annotation

Codecov / codecov/patch

pipelines/forecast_state.py#L146

Added line #L146 was not covered by tests
return None


Expand All @@ -159,17 +161,17 @@
return None


def render_webpage(model_run_dir: Path) -> None:
def render_diagnostic_report(model_run_dir: Path) -> None:

Check warning on line 164 in pipelines/forecast_state.py

View check run for this annotation

Codecov / codecov/patch

pipelines/forecast_state.py#L164

Added line #L164 was not covered by tests
result = subprocess.run(
[
"Rscript",
"pipelines/render_webpage.R",
"pipelines/diagnostic_report/render_diagnostic_report.R",
f"{model_run_dir}",
],
capture_output=True,
)
if result.returncode != 0:
raise RuntimeError(f"render_webpage: {result.stderr}")
raise RuntimeError(f"render_diagnostic_report: {result.stderr}")

Check warning on line 174 in pipelines/forecast_state.py

View check run for this annotation

Codecov / codecov/patch

pipelines/forecast_state.py#L174

Added line #L174 was not covered by tests
return None


Expand Down Expand Up @@ -363,11 +365,11 @@
logger.info("Conversion complete.")

logger.info("Postprocessing forecast...")
postprocess_forecast(model_run_dir, "pyrenew_e", "timeseries_e")
plot_and_save_state_forecast(model_run_dir, "pyrenew_e", "timeseries_e")

Check warning on line 368 in pipelines/forecast_state.py

View check run for this annotation

Codecov / codecov/patch

pipelines/forecast_state.py#L368

Added line #L368 was not covered by tests
logger.info("Postprocessing complete.")

logger.info("Rendering webpage...")
render_webpage(model_run_dir)
render_diagnostic_report(model_run_dir)

Check warning on line 372 in pipelines/forecast_state.py

View check run for this annotation

Codecov / codecov/patch

pipelines/forecast_state.py#L372

Added line #L372 was not covered by tests
logger.info("Rendering complete.")

if score:
Expand Down
4 changes: 3 additions & 1 deletion pipelines/generate_predictive.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from pathlib import Path

import arviz as az
from build_model import build_model_from_dir
from build_pyrenew_model import (

Check warning on line 6 in pipelines/generate_predictive.py

View check run for this annotation

Codecov / codecov/patch

pipelines/generate_predictive.py#L6

Added line #L6 was not covered by tests
build_model_from_dir,
)


def generate_and_save_predictions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

import epiweeks
import polars as pl
from prep_data import aggregate_facility_level_nssp_to_state, get_state_pop_df
from prep_data import (

Check warning on line 8 in pipelines/hubverse_create_observed_data_tables.py

View check run for this annotation

Codecov / codecov/patch

pipelines/hubverse_create_observed_data_tables.py#L8

Added line #L8 was not covered by tests
aggregate_facility_level_nssp_to_state,
get_state_pop_df,
)


def save_observed_data_tables(
Expand Down
File renamed without changes.
File renamed without changes.
31 changes: 0 additions & 31 deletions pipelines/plot_parameters.R

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from pathlib import Path

import polars as pl
from prep_data import get_state_pop_df, process_state_level_data
from prep_data import (

Check warning on line 6 in pipelines/prep_eval_data.py

View check run for this annotation

Codecov / codecov/patch

pipelines/prep_eval_data.py#L6

Added line #L6 was not covered by tests
get_state_pop_df,
process_state_level_data,
)


def save_eval_data(
Expand Down
Loading