Skip to content

Move training legend outside figure for train visualization #23

Move training legend outside figure for train visualization

Move training legend outside figure for train visualization #23

Workflow file for this run

name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test-core-dependencies:
name: Test Core Dependencies Only
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install core dependencies only
run: |
python -m pip install --upgrade pip
pip install -e . # Core installation without optional deps
pip install pytest pytest-cov pytest-xdist
- name: Test imports without optional dependencies
run: |
# Verify torch and networkx are NOT available
python -c "
try:
import torch
print('ERROR: torch should not be available')
exit(1)
except ImportError:
print('✅ torch correctly unavailable')
try:
import networkx
print('ERROR: networkx should not be available')
exit(1)
except ImportError:
print('✅ networkx correctly unavailable')
"
- name: Run core functionality tests
run: |
pytest test/test_conditional_imports.py -v --cov=spine --cov-report=xml
- name: Test CLI functionality
run: |
python -m spine.bin.cli --version
python -c "from spine.bin.cli import check_dependencies; deps = check_dependencies(); print('Dependencies:', deps)"
test-with-torch:
name: Test with PyTorch Available
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install with PyTorch
run: |
python -m pip install --upgrade pip
pip install torch --index-url https://download.pytorch.org/whl/cpu
pip install -e .
pip install pytest pytest-cov
- name: Test conditional imports with torch available
run: |
python -c "
from spine.utils.conditional import TORCH_AVAILABLE, torch
print(f'TORCH_AVAILABLE: {TORCH_AVAILABLE}')
assert TORCH_AVAILABLE == True
assert hasattr(torch, '__version__')
print('✅ PyTorch conditional imports working')
"
- name: Test torch-dependent functionality
run: |
pytest test/test_conditional_imports.py::TestConditionalUtilities -v
pytest test/test_optional_io.py -v
pytest test/test_utils/ -v -k "torch" || echo "Some torch tests may be skipped"
# NOTE: Model testing is currently disabled in CI due to complex dependency requirements
# (MinkowskiEngine, torch-scatter compilation issues in automated environments)
# Model functionality should be tested locally with: pip install spine-ml[model-full]
test-performance-benchmarks:
name: Performance Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest psutil
- name: Run performance tests
run: |
pytest test/test_conditional_imports.py::TestPerformanceRegression -v
- name: Benchmark NetworkX vs Dictionary performance
run: |
python -c "
import time
import sys
sys.path.insert(0, 'src')
# Test dictionary-based implementation performance
from collections import defaultdict
print('🚀 Performance Benchmark: Dictionary vs NetworkX')
print('=' * 60)
sizes = [1000, 5000, 10000]
for size in sizes:
print(f'Testing size: {size} nodes')
# Generate test data
parent_ids = [max(0, i // 2) for i in range(size)]
# Dictionary approach (current SPINE implementation)
start_time = time.time()
children = defaultdict(list)
for child_id, parent_id in enumerate(parent_ids):
if child_id != parent_id:
children[parent_id].append(child_id)
children_counts = {}
for node_id in range(size):
children_counts[node_id] = len(children[node_id])
dict_time = time.time() - start_time
print(f' Dictionary: {dict_time:.4f}s ({size/dict_time:.0f} nodes/sec)')
# Memory efficient and fast!
assert dict_time < 0.1, f'Too slow for {size} nodes: {dict_time:.4f}s'
print('✅ All performance benchmarks passed!')
"
test-coverage:
name: Coverage Analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest pytest-cov coverage[toml]
- name: Run comprehensive test suite with coverage
run: |
echo "ℹ️ Running comprehensive tests excluding model tests, parse tests, and IO tests (require optional deps)"
# Run specific test directories/files to avoid loading problematic conftest.py files
# Excluding test_loader.py and test_io/ because they require PyTorch, ROOT, and other optional deps
pytest \
test/test_conditional_imports.py \
test/test_driver_import.py \
test/test_optional_io.py \
test/test_ana/ \
test/test_construct/ \
test/test_data/ \
test/test_math/ \
test/test_post/ \
test/test_utils/ \
test/test_vis/ \
-v \
--cov=spine \
--cov-report=html \
--cov-report=xml \
--cov-report=term \
--maxfail=10
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
verbose: true
test-multiple-environments:
name: Test Installation Methods
runs-on: ubuntu-latest
strategy:
matrix:
install-method:
- "pip install -e ."
- "pip install ."
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install via ${{ matrix.install-method }}
run: |
python -m pip install --upgrade pip
${{ matrix.install-method }}
- name: Test basic functionality
run: |
python -c "
import spine
print(f'SPINE version: {spine.__version__}')
from spine.driver import Driver
from spine.main import run
from spine.bin.cli import main
print('✅ All critical components importable')
"
- name: Test CLI works
run: |
python -m spine.bin.cli --version || echo "CLI version check completed"
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .
pip install pytest
- name: Run integration tests
run: |
pytest test/test_conditional_imports.py::TestIntegrationWithoutDependencies -v -m integration
code-quality:
name: Code Quality Checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install pre-commit
run: |
python -m pip install --upgrade pip
pip install pre-commit
pip install -e .
- name: Run pre-commit checks
run: pre-commit run --all-files --show-diff-on-failure
- name: Run mypy on critical modules
run: |
mypy src/spine/utils/conditional.py --ignore-missing-imports || echo "mypy completed with warnings"