Skip to content

Update synthetic_data_processing_aurora.ipynb #20

Update synthetic_data_processing_aurora.ipynb

Update synthetic_data_processing_aurora.ipynb #20

name: Test Environment Setup
on:
push:
branches:
- '*'
pull_request:
branches:
- '*'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test-environment:
name: Test Environment (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Cache pip packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: pip-${{ runner.os }}-py${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }}
restore-keys: |
pip-${{ runner.os }}-py${{ matrix.python-version }}-
- name: Install dependencies from requirements.txt
run: |
python --version
uv pip install --system -r requirements.txt
- name: Test package imports and print versions
run: |
python -c "
import sys
print('=' * 60)
print('Python version:', sys.version)
print('=' * 60)
packages = [
('mt_metadata', 'mt_metadata'),
('mth5', 'mth5'),
('aurora', 'aurora'),
('mtpy', 'mtpy'),
('simpeg', 'simpeg'),
]
all_success = True
for display_name, import_name in packages:
try:
module = __import__(import_name)
version = getattr(module, '__version__', 'unknown')
print(f'✓ {display_name:15s} version: {version}')
except ImportError as e:
print(f'✗ {display_name:15s} FAILED: {e}')
all_success = False
print('=' * 60)
if all_success:
print('SUCCESS: All packages imported successfully!')
else:
print('FAILURE: Some packages failed to import')
sys.exit(1)
"
- name: Run basic functionality test
run: |
python -c "
import mt_metadata
import mth5
import numpy as np
print('Testing basic mth5 functionality...')
print(f'mth5 version: {mth5.__version__}')
print(f'mt_metadata version: {mt_metadata.__version__}')
# Test that we can create metadata objects
from mt_metadata.timeseries import Station
station = Station()
print(f'Created Station metadata object: {station.id}')
print('Basic functionality test passed!')
"
- name: Install notebook testing dependencies
run: |
uv pip install --system jupyter nbconvert
- name: Test running notebooks in /src
run: |
python -c "
from pathlib import Path
import subprocess
import sys
print('Testing notebooks in /src directory...')
print('=' * 60)
src_dir = 'src'
failed_notebooks = []
passed_notebooks = []
notebooks_to_run = [
'src/make_mth5/make_mth5_from_lemi.ipynb',
'src/make_mth5/make_mth5_from_metronix.ipynb',
'src/make_mth5/make_mth5_from_nims.ipynb',
'src/make_mth5/make_mth5_from_phoenix_real.ipynb',
'src/make_mth5/make_mth5_from_z3d.ipynb',
'src/mth5_objects/channel_ts_example.ipynb',
'src/mth5_objects/filters_example.ipynb',
'src/mth5_objects/remove_instrument_response_example.ipynb',
'src/mth5_objects/run_ts_example.ipynb',
'src/mth5_objects/transfer_function_example.ipynb',
'src/processing/synthetic_data_processing_example.ipynb',
]
for nb in notebooks_to_run:
notebook_path = Path(nb)
print('=' * 40)
print(f'Running: {notebook_path}')
print('=' * 40)
try:
result = subprocess.run(
[sys.executable, '-m', 'nbconvert', '--to', 'notebook',
'--execute', '--ExecutePreprocessor.timeout=600',
notebook_path],
capture_output=True,
text=True,
timeout=900
)
if result.returncode == 0:
print(f' ✓ PASSED')
passed_notebooks.append(notebook_path)
else:
print(f' ✗ FAILED')
print(f' Error: {result.stderr}')
failed_notebooks.append(notebook_path)
except subprocess.TimeoutExpired:
print(f' ✗ TIMEOUT')
failed_notebooks.append(notebook_path)
except Exception as e:
print(f' ✗ ERROR: {e}')
failed_notebooks.append(notebook_path)
print(f'Passed: {len(passed_notebooks)}/{len(passed_notebooks) + len(failed_notebooks)}')
print('=' * 60)
if failed_notebooks:
print('\\nFailed notebooks:')
for nb in failed_notebooks:
print(f' - {nb}')
sys.exit(1)
else:
print('All notebooks passed!')
"