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

Migrate to Regression Data Completely #2808

Merged
merged 12 commits into from
Sep 11, 2024
45 changes: 0 additions & 45 deletions .github/actions/setup_lfs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ description: "Pull LFS repositories and caches them"


inputs:
refdata-repo:
description: "tardis refdata repository"
required: false
default: "tardis-sn/tardis-refdata"
regression-data-repo:
description: "tardis regression data repository"
required: false
Expand All @@ -15,47 +11,6 @@ inputs:
runs:
using: "composite"
steps:
- name: Clone Refdata Repo
uses: actions/checkout@v4
with:
repository: ${{ inputs.refdata-repo }}
path: tardis-refdata
lfs: false

- name: Create LFS file list
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id
working-directory: tardis-refdata
shell: bash

- name: Restore LFS cache
uses: actions/cache/restore@v4
id: lfs-cache-refdata
with:
path: tardis-refdata/.git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('tardis-refdata/.lfs-assets-id') }}-v1

- name: Git LFS Pull
run: git lfs pull
working-directory: tardis-refdata
if: steps.lfs-cache-refdata.outputs.cache-hit != 'true'
shell: bash

- name: Git LFS Checkout
run: git lfs checkout
working-directory: tardis-refdata
if: steps.lfs-cache-refdata.outputs.cache-hit == 'true'
shell: bash

- name: Save LFS cache if not found
# uses fake ternary
# for reference: https://github.com/orgs/community/discussions/26738#discussioncomment-3253176
if: ${{ steps.lfs-cache-refdata.outputs.cache-hit != 'true' && !contains(github.ref, 'merge') && always() || false }}
uses: actions/cache/save@v4
id: lfs-cache-refdata-save
with:
path: tardis-refdata/.git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('tardis-refdata/.lfs-assets-id') }}-v1

- name: Clone tardis-sn/tardis-regression-data
uses: actions/checkout@v4
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ jobs:

- name: Setup LFS
uses: ./.github/actions/setup_lfs

- name: Setup environment
uses: ./.github/actions/setup_env
with:
with:
os-label: linux-64

- name: Copy atom_data
run: |
mkdir -p ~/Downloads/tardis-data && cp -a ./tardis-refdata/atom_data/. ~/Downloads/tardis-data
mkdir -p ~/Downloads/tardis-data && cp -a ./tardis-regression-data/atom_data/. ~/Downloads/tardis-data

- name: Install package
run: pip install -e .
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ jobs:
- name: Download Lock File
run: wget -q https://raw.githubusercontent.com/tardis-sn/tardis/master/conda-linux-64.lock
shell: bash

- name: Generate Cache Key
run: |
run: |
file_hash=$(cat conda-linux-64.lock | shasum -a 256 | cut -d' ' -f1)
echo "file_hash=$file_hash" >> "${GITHUB_OUTPUT}"
id: cache-environment-key
shell: bash

- uses: mamba-org/setup-micromamba@v1
with:
environment-file: conda-linux-64.lock
Expand Down Expand Up @@ -95,7 +95,7 @@ jobs:

<br>

> :warning: **WARNING:**
> :warning: **WARNING:**
>
> This pull request should be auto-merged. **Do not merge manually if any check fails**.
>
Expand Down Expand Up @@ -138,9 +138,6 @@ jobs:
merge-method: squash
if: steps.create-pr.outputs.pull-request-operation == 'created'

compare_refdata:
uses: tardis-sn/tardis-refdata/.github/workflows/compare-refdata.yml@master

pip_tests:
uses: ./.github/workflows/tests.yml
secrets: inherit
Expand Down
37 changes: 19 additions & 18 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ name: tests
on:
push:
branches:
- '*'
- '*'
pull_request:
branches:
- '*'
- '*'
types:
- opened
- reopened
- synchronize
- labeled
workflow_call: # to be called by the pre release workflow
workflow_call:
inputs:
pip_git:
description: "Whether or not to install tardis using git"
Expand All @@ -26,17 +26,17 @@ on:

env:
CACHE_NUMBER: 0 # increase to reset cache manually
PYTEST_FLAGS: --tardis-refdata=${{ github.workspace }}/tardis-refdata --tardis-regression-data=${{ github.workspace }}/tardis-regression-data --cov=tardis --cov-report=xml --cov-report=html --cov-append
PYTEST_FLAGS: --tardis-regression-data=${{ github.workspace }}/tardis-regression-data --cov=tardis --cov-report=xml --cov-report=html --cov-append
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

defaults:
run:
shell: bash -l {0}

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true


jobs:
tests:
Expand Down Expand Up @@ -65,38 +65,39 @@ jobs:

- name: Setup LFS
uses: ./.github/actions/setup_lfs

- name: Setup environment
uses: ./.github/actions/setup_env
with:
os-label: ${{ matrix.label }}

- name: Install package editable
if: ${{ !inputs.pip_git }}
run: |
pip install -e . --user

- name: Install package git
if: ${{ inputs.pip_git }}
run: |
pip install git+https://github.com/tardis-sn/tardis.git@master

- name: Run tests
run: pytest tardis ${{ env.PYTEST_FLAGS }} -m "${{ matrix.continuum }} continuum and ${{ matrix.rpacket_tracking }} rpacket_tracking"
- name: Refdata Generation tests
run: pytest tardis ${{ env.PYTEST_FLAGS }} --generate-reference -m "${{ matrix.continuum }} continuum and ${{ matrix.rpacket_tracking }} rpacket_tracking"
run: pytest tardis ${{ env.PYTEST_FLAGS }} -m "${{ matrix.continuum }} continuum and ${{ matrix.rpacket_tracking }} rpacket_tracking"

- name: Regression Data Generation tests
run: pytest tardis ${{ env.PYTEST_FLAGS }} --generate-reference -m "${{ matrix.continuum }} continuum and ${{ matrix.rpacket_tracking }} rpacket_tracking"
if: contains(github.event.pull_request.labels.*.name, 'run-generation-tests') || github.ref == 'refs/heads/master'

- run: mv .coverage .coverage.${{ strategy.job-index }}

- uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.continuum }}-continuum-${{ matrix.rpacket_tracking }}-rpacket_tracking-${{ matrix.os }}
include-hidden-files: true
path: |
.coverage*
!.coveragerc

combine_coverage_reports:
needs: [tests]
if: github.repository_owner == 'tardis-sn'
Expand All @@ -110,16 +111,16 @@ jobs:

# will download all artifacts(in this case all are coverage reports)
- uses: actions/download-artifact@v4
with:
with:
path: .
merge-multiple: true

- name: Combine coverage reports
run: |
coverage combine
coverage xml
coverage html

- name: Print report
run: coverage report

Expand Down
2 changes: 1 addition & 1 deletion asv.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"html_dir": ".asv/html",
"matrix": {
"env": {
"TARDIS_REF_PATH": "tardis-refdata/atom_data"
"TARDIS_REF_PATH": "tardis-regression-data/atom_data"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ supernova:
time_explosion: 16 day
distance: 8.32 Mpc

# standard atomic data base; get it from the tardis-refdata repository
# standard atomic data base; get it from the tardis-regression-data repository
atom_data: kurucz_cd23_chianti_H_He.h5

model:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ supernova:
time_explosion: 16 day
distance: 8.32 Mpc

# standard atomic data base; get it from the tardis-refdata repository
# standard atomic data base; get it from the tardis-regression-data repository
atom_data: kurucz_cd23_chianti_H_He.h5

model:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ supernova:
time_explosion: 13 day
#distance: 24.2 Mpc

# standard atomic data base; get it from the tardis-refdata repository
# standard atomic data base; get it from the tardis-regression-data repository
atom_data: kurucz_cd23_chianti_H_He.h5

model:
Expand Down
21 changes: 11 additions & 10 deletions tardis/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from copy import deepcopy
from pathlib import Path

import pytest
Expand Down Expand Up @@ -91,9 +92,6 @@ def pytest_configure(config):


def pytest_addoption(parser):
parser.addoption(
"--tardis-refdata", default=None, help="Path to Tardis Reference Folder"
)
parser.addoption(
"--tardis-regression-data",
default=None,
Expand Down Expand Up @@ -141,17 +139,20 @@ def generate_reference(request):
option = request.config.getoption("--generate-reference")
if option is None:
return False
else:
return option
return option


@pytest.fixture(scope="session")
def tardis_ref_path(request):
tardis_ref_path = request.config.getoption("--tardis-refdata")
if tardis_ref_path is None:
pytest.skip("--tardis-refdata was not specified")
def tardis_regression_path(request):
tardis_regression_path = request.config.getoption(
"--tardis-regression-data"
)
if tardis_regression_path is None:
pytest.skip("--tardis-regression-data was not specified")
else:
return Path(os.path.expandvars(os.path.expanduser(tardis_ref_path)))
return Path(
os.path.expandvars(os.path.expanduser(tardis_regression_path))
)


@pytest.fixture(scope="session")
Expand Down
2 changes: 1 addition & 1 deletion tardis/energy_input/docs/working_gamma_ray_test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
}
],
"source": [
"# Download the atom data file from tardis-refdata repo to run this cell.\n",
"# Download the atom data file from tardis-regression-data repo to run this cell.\n",
"atom_data_file = 'kurucz_cd23_chianti_H_He.h5'\n",
"atom_data = AtomData.from_hdf(atom_data_file)"
]
Expand Down
2 changes: 1 addition & 1 deletion tardis/io/model/parse_atom_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def parse_atom_data(config, atom_data=None):
print(
e,
"Error might be from the use of an old-format of the atomic database, \n"
"please see https://github.com/tardis-sn/tardis-refdata/tree/master/atom_data"
"please see https://github.com/tardis-sn/tardis-regression-data/tree/master/atom_data"
" for the most recent version.",
)
raise
Expand Down
2 changes: 1 addition & 1 deletion tardis/io/model/readers/tests/data/csvy_test_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ supernova:
luminosity_requested: 8.770 log_lsun
time_explosion: 16 day

# standard atomic data base; get it from the tardis-refdata repository
# standard atomic data base; get it from the tardis-regression-data repository
atom_data: kurucz_cd23_chianti_H_He.h5

csvy_model: csvy_full.csvy
Expand Down
4 changes: 2 additions & 2 deletions tardis/io/model/readers/tests/test_arepo_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@


@pytest.fixture()
def arepo_snapshot_fname(tardis_ref_path):
return Path(tardis_ref_path) / "arepo_data" / "arepo_snapshot.json"
def arepo_snapshot_fname(tardis_regression_path):
return Path(tardis_regression_path) / "arepo_data" / "arepo_snapshot.json"


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion tardis/model/tests/data/branch85_csvy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ supernova:
time_explosion: 16 day
distance: 8.32 Mpc

# standard atomic data base; get it from the tardis-refdata repository
# standard atomic data base; get it from the tardis-regression-data repository
atom_data: kurucz_cd23_chianti_H_He.h5

csvy_model: branch85_csvy.csvy
Expand Down
2 changes: 1 addition & 1 deletion tardis/model/tests/data/branch85_old_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ supernova:
time_explosion: 16 day
distance: 8.32 Mpc

# standard atomic data base; get it from the tardis-refdata repository
# standard atomic data base; get it from the tardis-regression-data repository
atom_data: kurucz_cd23_chianti_H_He.h5


Expand Down
2 changes: 1 addition & 1 deletion tardis/model/tests/data/csvy_model_to_test_abundances.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ supernova:
time_explosion: 4 day
distance: 8.32 Mpc

# standard atomic data base; get it from the tardis-refdata repository
# standard atomic data base; get it from the tardis-regression-data repository
atom_data: kurucz_cd23_chianti_H_He.h5

csvy_model: csvy_model_to_test_abundances.csvy
Expand Down
2 changes: 1 addition & 1 deletion tardis/model/tests/data/exponential_csvy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ supernova:
time_explosion: 16 day
distance: 8.32 Mpc

# standard atomic data base; get it from the tardis-refdata repository
# standard atomic data base; get it from the tardis-regression-data repository
atom_data: kurucz_cd23_chianti_H_He.h5

csvy_model: exponential_csvy.csvy
Expand Down
2 changes: 1 addition & 1 deletion tardis/model/tests/data/exponential_old_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ supernova:
time_explosion: 16 day
distance: 8.32 Mpc

# standard atomic data base; get it from the tardis-refdata repository
# standard atomic data base; get it from the tardis-regression-data repository
atom_data: kurucz_cd23_chianti_H_He.h5


Expand Down
2 changes: 1 addition & 1 deletion tardis/model/tests/data/model_full_csvy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ supernova:
time_explosion: 16 day
distance: 8.32 Mpc

# standard atomic data base; get it from the tardis-refdata repository
# standard atomic data base; get it from the tardis-regression-data repository
atom_data: kurucz_cd23_chianti_H_He.h5

csvy_model: model_full_csvy.csvy
Expand Down
Loading
Loading