Skip to content

Commit 5c516af

Browse files
Copilotilaflott
andauthored
Add equivalence testing CI workflow and comparison script
Create .github/workflows/equivalence_test.yml that: - Checks out both fremorizer and fre-cli with submodules - Sets up miniforge with conda-forge and noaa-gfdl channels - Creates separate conda environments for each tool - Runs comparison script against shared test fixtures - Uploads equivalence report as CI artifact Create fremorizer/tests/equivalence/compare_with_fre_cli.py that: - Runs equivalent CLI commands through both tools (fremor vs fre cmor) - Compares output directory structures - Deep-compares netCDF files (dimensions, variables, attributes, data) - Generates a markdown equivalence report - Covers basic CMORization run, varlist variants, and find subtool - Handles known acceptable differences (timestamps, UUIDs, etc.) Agent-Logs-Url: https://github.com/ilaflott/fremorizer/sessions/5d037b88-43a4-4d27-8b71-8f66a467e829 Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
1 parent c2187e2 commit 5c516af

3 files changed

Lines changed: 699 additions & 0 deletions

File tree

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: equivalence_test
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
# cancel running jobs if there is a newer push
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
compare-with-fre-cli:
19+
runs-on: ubuntu-latest
20+
defaults:
21+
run:
22+
shell: bash -l {0}
23+
steps:
24+
- name: Checkout fremorizer
25+
uses: actions/checkout@v4
26+
with:
27+
submodules: recursive
28+
path: fremorizer
29+
30+
- name: Checkout fre-cli
31+
uses: actions/checkout@v4
32+
with:
33+
repository: noaa-gfdl/fre-cli
34+
submodules: recursive
35+
path: fre-cli
36+
37+
- name: Setup Conda with miniforge
38+
uses: conda-incubator/setup-miniconda@v3
39+
with:
40+
miniforge-version: latest
41+
auto-activate-base: false
42+
43+
- name: Remove unwanted conda channels
44+
run: |
45+
conda config --remove channels defaults || true
46+
conda config --remove channels main || true
47+
conda config --remove channels r || true
48+
conda config --set channel_priority strict
49+
50+
- name: Create fremorizer environment
51+
run: |
52+
conda create -n fremorizer-test python=3.12 -y -c conda-forge -c noaa-gfdl
53+
conda run -n fremorizer-test conda install -y \
54+
conda-forge::cftime \
55+
"conda-forge::click>=8.2" \
56+
"conda-forge::cmor>=3.14" \
57+
"conda-forge::netcdf4>=1.7" \
58+
"conda-forge::numpy>=2" \
59+
conda-forge::pyyaml \
60+
conda-forge::nco
61+
conda run -n fremorizer-test pip install ./fremorizer
62+
63+
- name: Create fre-cli environment
64+
run: |
65+
conda create -n fre-cli-test python=3.12 -y -c conda-forge -c noaa-gfdl
66+
conda run -n fre-cli-test conda install -y \
67+
conda-forge::cftime \
68+
"conda-forge::click>=8.2" \
69+
"conda-forge::cmor>=3.14" \
70+
"conda-forge::netcdf4>=1.7" \
71+
"conda-forge::numpy>=2" \
72+
conda-forge::pyyaml \
73+
conda-forge::nco
74+
conda run -n fre-cli-test pip install ./fre-cli
75+
76+
- name: Verify installations
77+
run: |
78+
echo "--- fremorizer ---"
79+
conda run -n fremorizer-test fremor --version
80+
echo "--- fre-cli ---"
81+
conda run -n fre-cli-test fre --version
82+
83+
- name: Run equivalence tests
84+
run: |
85+
# Use fremorizer env (has netCDF4/numpy for comparison) and
86+
# point to both CLIs via environment variables. The comparison
87+
# script invokes each tool through subprocess so we wrap them
88+
# with conda-run helpers.
89+
export FREMORIZER_CMD="conda run -n fremorizer-test fremor"
90+
export FRE_CLI_CMD="conda run -n fre-cli-test fre cmor"
91+
export TEST_FILES_DIR="${GITHUB_WORKSPACE}/fremorizer/fremorizer/tests/test_files"
92+
export EQUIVALENCE_REPORT_PATH="${GITHUB_WORKSPACE}/equivalence_report.md"
93+
94+
conda run -n fremorizer-test \
95+
python -m fremorizer.tests.equivalence.compare_with_fre_cli
96+
97+
- name: Upload equivalence report
98+
if: always()
99+
uses: actions/upload-artifact@v4
100+
with:
101+
name: equivalence-report
102+
path: equivalence_report.md
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
''' equivalence tests for fremorizer vs fre-cli '''

0 commit comments

Comments
 (0)