Skip to content

Commit

Permalink
github actions test
Browse files Browse the repository at this point in the history
  • Loading branch information
ivargr committed Sep 10, 2024
1 parent 7ad3ea5 commit 12d930f
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test-external-models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ jobs:
- name: Run
run: |
chap evaluate --model-name https://github.com/sandvelab/chap_auto_ewars --dataset-name ISIMIP_dengue_harmonized --dataset-country brazil
#chap evaluate --model-name https://github.com/sandvelab/chap_auto_ewars --dataset-name ISIMIP_dengue_harmonized --dataset-country brazil
chap evaluate --model-name external_models/naive_python_model_with_mlproject_file_and_docker/ --dataset-name ISIMIP_dengue_harmonized --dataset-country brazil
7 changes: 6 additions & 1 deletion climate_health/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from cyclopts import App

from climate_health.external.external_model import get_model_maybe_yaml
from climate_health.external.mlflow import NoPredictionsError
from climate_health.spatio_temporal_data.multi_country_dataset import MultiCountryDataSet
from . import api
from climate_health.dhis2_interface.ChapProgram import ChapPullPost
Expand Down Expand Up @@ -49,7 +50,11 @@ def evaluate(model_name: ModelType | str, dataset_name: DataSetType, dataset_co

model, model_name = get_model_maybe_yaml(model_name)
model = model()
results = evaluate_model(model, dataset, prediction_length=prediction_length, n_test_sets=n_splits, report_filename=report_filename)
try:
results = evaluate_model(model, dataset, prediction_length=prediction_length, n_test_sets=n_splits, report_filename=report_filename)
except NoPredictionsError as e:
logging.error(f'No predictions were made: {e}')
return
print(results)

@app.command()
Expand Down
7 changes: 6 additions & 1 deletion climate_health/external/mlflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def predict(self, historic_data: DataSet, future_data: DataSet) -> DataSet:
except pandas.errors.EmptyDataError:
# todo: Probably deal with this in an other way, throw an exception istead
logging.warning("No data returned from model (empty file from predictions)")
raise ValueError(f"No prediction data written")
raise NoPredictionsError(f"No prediction data written")
result_class = SummaryStatistics if 'quantile_low' in df.columns else HealthData
if self._location_mapping is not None:
df['location'] = df['location'].apply(self._location_mapping.index_to_name)
Expand All @@ -220,3 +220,8 @@ def predict(self, historic_data: DataSet, future_data: DataSet) -> DataSet:
mask = [start_time <= time_period.start_timestamp for time_period in time_periods]
df = df[mask]
return DataSet.from_pandas(df, Samples)



class NoPredictionsError(Exception):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: naive_python

docker_env:
image: python:3.10

#python_env: python_env.yaml

entry_points:
train:
parameters:
train_data: str
model: str
command: "python train.py train {train_data} {model}"
predict:
parameters:
historic_data: str
future_data: str
model: str
out_file: str
command: "python predict.py predict {model} {historic_data} {future_data} {out_file}"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("predicting")
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import sys

train_data = sys.argv[1]
model_name = sys.argv[2]


with open(model_name, "w") as f:
f.write("test")



0 comments on commit 12d930f

Please sign in to comment.