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

Upload radas artifacts #19

Merged
merged 2 commits into from
Jan 22, 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
4 changes: 2 additions & 2 deletions .github/workflows/make_radas_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ git checkout b538ea3d42f0d3eea6cf28433a2390503457083d

poetry install --only main

poetry run python adas_data/fetch_adas_data.py
poetry run fetch_adas

poetry run python run_radas.py --case all
poetry run radas

popd
16 changes: 15 additions & 1 deletion .github/workflows/workflow_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ jobs:
with:
path: radas
key: radas-${{ hashFiles('.github/workflows/make_radas_data.sh')}}

- name: Make radas data
if: steps.radas.outputs.cache-hit != 'true'
run: bash .github/workflows/make_radas_data.sh

- name: Upload radas artifacts
uses: actions/upload-artifact@v3
with:
name: radas_cases
path: radas/cases

build:
needs: radas
Expand Down Expand Up @@ -94,6 +100,14 @@ jobs:
run: |
poetry run python tests/regression_results/generate_regression_results.py
MPLBACKEND=Agg poetry run pytest --no-cov tests/test_regression_against_cases.py

- name: Upload regression results
uses: actions/upload-artifact@v3
if: always()
# replace with `if: failure()` once this pipeline is stable
with:
name: regression_results
path: tests/regression_results

- name: Test package
run: |
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,6 @@ dmypy.json
# Mess
example_cases/SPARC_PRD/output/*
# avoid committing nc files
*.nc
tests/regression_results/test*.nc
cfspopcon/atomic_data/*.nc
example_cases/**/output/dataset.nc
7 changes: 4 additions & 3 deletions tests/test_regression_against_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@
)
from xarray.testing import assert_allclose

from cfspopcon.file_io import read_dataset_from_netcdf
from cfspopcon.file_io import write_dataset_to_netcdf, read_dataset_from_netcdf
from cfspopcon.input_file_handling import read_case


@pytest.mark.parametrize("case", ALL_CASE_PATHS, ids=ALL_CASE_NAMES)
@pytest.mark.filterwarnings("ignore:Not all input parameters were used")
def test_regression_against_case(case: Path):

input_parameters, algorithm, _ = read_case(case)
case_name = case.parent.stem

dataset = algorithm.run(**input_parameters)
write_dataset_to_netcdf(dataset, Path(__file__).parent / "regression_results" / f"test1_{case.parent.stem}.nc")

reference_dataset = read_dataset_from_netcdf(Path(__file__).parent / "regression_results" / f"{case_name}_result.nc").load()

Expand All @@ -29,7 +29,6 @@ def test_regression_against_case(case: Path):
@pytest.mark.parametrize("case", ALL_CASE_PATHS, ids=ALL_CASE_NAMES)
@pytest.mark.filterwarnings("ignore:Not all input parameters were used")
def test_regression_against_case_with_update(case: Path):

input_parameters, algorithm, _ = read_case(case)
case_name = case.parent.stem

Expand All @@ -38,6 +37,8 @@ def test_regression_against_case_with_update(case: Path):
for alg in algorithm.algorithms: # type: ignore
dataset = alg.update_dataset(dataset)

write_dataset_to_netcdf(dataset, Path(__file__).parent / "regression_results" / f"test2_{case.parent.stem}.nc")

reference_dataset = read_dataset_from_netcdf(Path(__file__).parent / "regression_results" / f"{case_name}_result.nc").load()

assert_allclose(dataset, reference_dataset, rtol=1e-8, atol=0)