Skip to content

Commit c1c2b43

Browse files
mihiarcclaude
andcommitted
Add validation infrastructure for FVS-Python
Implements comprehensive validation framework as specified in FVS_PYTHON_VALIDATION_SPEC.md with four-level validation strategy: - Component model validation (height-diameter, bark ratio, crown ratio, CCF) - Single-tree growth validation (small tree, large tree, transition zone) - Stand simulation validation (growth trajectories, mortality, yield tables) - Bakuzis Matrix verification (fundamental stand dynamics relationships) Includes: - validation/scripts/ - Test data generation, statistical comparison (TOST), and visualization functions - validation/test_cases/ - YAML test case definitions for components and stands - tests/test_validation.py - 58 pytest tests covering all species (LP, SP, SA, LL) - .github/workflows/validation.yml - CI/CD with matrix testing (Python 3.10-3.12) and monthly scheduled validation runs Co-Authored-By: Claude <[email protected]>
1 parent 982567a commit c1c2b43

File tree

12 files changed

+4126
-0
lines changed

12 files changed

+4126
-0
lines changed

.github/workflows/validation.yml

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# FVS-Python Validation Workflow
2+
# Runs validation tests on push to main and PRs, plus monthly scheduled runs
3+
4+
name: FVS Validation
5+
6+
on:
7+
push:
8+
branches: [main]
9+
paths:
10+
- 'src/**'
11+
- 'tests/**'
12+
- 'validation/**'
13+
- 'cfg/**'
14+
pull_request:
15+
branches: [main]
16+
paths:
17+
- 'src/**'
18+
- 'tests/**'
19+
- 'validation/**'
20+
- 'cfg/**'
21+
schedule:
22+
# Run monthly validation on the 1st at midnight UTC
23+
- cron: '0 0 1 * *'
24+
workflow_dispatch:
25+
# Allow manual triggering
26+
27+
jobs:
28+
validate:
29+
name: Run Validation Suite
30+
runs-on: ubuntu-latest
31+
strategy:
32+
matrix:
33+
python-version: ['3.10', '3.11', '3.12']
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v4
38+
39+
- name: Install uv
40+
uses: astral-sh/setup-uv@v4
41+
with:
42+
version: "latest"
43+
44+
- name: Set up Python ${{ matrix.python-version }}
45+
run: uv python install ${{ matrix.python-version }}
46+
47+
- name: Install dependencies
48+
run: |
49+
uv sync --all-extras --dev
50+
51+
- name: Run unit tests
52+
run: |
53+
uv run pytest tests/ -v --tb=short -x
54+
55+
- name: Run validation tests
56+
run: |
57+
uv run pytest tests/test_validation.py -v --tb=short
58+
59+
- name: Run validation suite
60+
run: |
61+
uv run python validation/run_validation.py --output validation/results
62+
63+
- name: Upload validation results
64+
uses: actions/upload-artifact@v4
65+
if: always()
66+
with:
67+
name: validation-results-py${{ matrix.python-version }}
68+
path: validation/results/
69+
retention-days: 30
70+
71+
component-validation:
72+
name: Component Model Validation
73+
runs-on: ubuntu-latest
74+
needs: validate
75+
76+
steps:
77+
- name: Checkout repository
78+
uses: actions/checkout@v4
79+
80+
- name: Install uv
81+
uses: astral-sh/setup-uv@v4
82+
with:
83+
version: "latest"
84+
85+
- name: Set up Python
86+
run: uv python install 3.11
87+
88+
- name: Install dependencies
89+
run: |
90+
uv sync --all-extras --dev
91+
92+
- name: Run component validation
93+
run: |
94+
uv run python validation/run_validation.py --level component -v
95+
96+
- name: Run single tree validation
97+
run: |
98+
uv run python validation/run_validation.py --level tree -v
99+
100+
stand-validation:
101+
name: Stand Simulation Validation
102+
runs-on: ubuntu-latest
103+
needs: validate
104+
105+
steps:
106+
- name: Checkout repository
107+
uses: actions/checkout@v4
108+
109+
- name: Install uv
110+
uses: astral-sh/setup-uv@v4
111+
with:
112+
version: "latest"
113+
114+
- name: Set up Python
115+
run: uv python install 3.11
116+
117+
- name: Install dependencies
118+
run: |
119+
uv sync --all-extras --dev
120+
121+
- name: Run stand simulation validation
122+
run: |
123+
uv run python validation/run_validation.py --level stand -v
124+
125+
- name: Verify Bakuzis relationships
126+
run: |
127+
uv run python validation/run_validation.py --level bakuzis -v
128+
129+
generate-report:
130+
name: Generate Validation Report
131+
runs-on: ubuntu-latest
132+
needs: [component-validation, stand-validation]
133+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
134+
135+
steps:
136+
- name: Checkout repository
137+
uses: actions/checkout@v4
138+
139+
- name: Install uv
140+
uses: astral-sh/setup-uv@v4
141+
with:
142+
version: "latest"
143+
144+
- name: Set up Python
145+
run: uv python install 3.11
146+
147+
- name: Install dependencies
148+
run: |
149+
uv sync --all-extras --dev
150+
151+
- name: Generate full validation report
152+
run: |
153+
uv run python validation/run_validation.py --output validation/results
154+
155+
- name: Generate test data
156+
run: |
157+
uv run python validation/scripts/generate_test_data.py
158+
159+
- name: Upload validation report
160+
uses: actions/upload-artifact@v4
161+
with:
162+
name: validation-report
163+
path: |
164+
validation/results/
165+
validation/reference_data/
166+
retention-days: 90
167+
168+
- name: Upload figures
169+
uses: actions/upload-artifact@v4
170+
with:
171+
name: validation-figures
172+
path: validation/results/figures/
173+
retention-days: 90

0 commit comments

Comments
 (0)