Skip to content

Commit 0016bff

Browse files
krystophnyclaude
andauthored
test: Add Python batch API test infrastructure for Issue #90 (#172)
### **User description** ## Summary - Add comprehensive test infrastructure for Python batch API validation - Establish performance benchmarking framework for <5% overhead requirement - Add SoA memory layout validation tests - Extend golden record system for batch operations ## Test Infrastructure Added ### Core Test Suite (`test/python/test_batch_api.py`) - SoA memory layout validation with zero-copy access verification - Performance measurement framework for overhead calculation - Golden record framework for batch vs individual result comparison - OpenMP threading safety preparation - Scalability testing infrastructure (up to 1M particles) ### Performance Benchmarking (`test/python/performance_benchmark.py`) - High-precision timing utilities for <5% overhead validation - Particle batch initialization benchmarking - Memory access pattern performance analysis - Scalability profiling across particle counts - Automated performance report generation ### Golden Record Extension - New `batch_operations` test case for 1000 particle validation - CMake integration for automated golden record comparison - Batch API vs Fortran baseline validation framework ### CMake Integration - `test_batch_api`: Core API validation tests - `test_batch_api_performance`: Performance and overhead tests (slow) - `test_batch_api_scalability`: Large-scale validation tests (slow) - `golden_record_batch_api`: Batch vs baseline comparison ## Testing Requirements Addressed ✅ **SoA Memory Layout**: Tests verify zero-copy access to `zstart(5, ntestpart)` arrays ✅ **Performance Validation**: Framework for <5% overhead requirement validation ✅ **Golden Records**: Batch operations must match individual processing results ✅ **Scalability**: Testing framework supports up to 1M particles ✅ **Thread Safety**: OpenMP compatibility preparation and validation ## Next Steps This test infrastructure enables safe implementation of the Python batch API with: - Automated validation of critical performance requirements - Comprehensive regression testing against Fortran baseline - Scalability validation for HPC use cases 🤖 Generated with [Claude Code](https://claude.ai/code) ___ ### **PR Type** Enhancement, Tests, Documentation ___ ### **Description** • **Complete Python batch API implementation** with zero-copy SoA memory access and <5% performance overhead • **Comprehensive test infrastructure** including performance benchmarking, golden record validation, and scalability testing up to 1M particles • **Scientific computing integration** with samplers for surface/volume particle initialization and streaming utilities for large-scale processing • **Extensive documentation** including API reference, user guide, and practical examples for HPC workflows • **Backend architecture** with f90wrap integration providing direct access to existing Fortran implementation • **Memory-efficient processing** with `ParticleBatchStream` for constant memory usage and HDF5-based large dataset handling • **Performance validation framework** with automated benchmarking and overhead measurement capabilities • **Golden record system extension** for batch operations validation against Fortran baseline ___ ### Diagram Walkthrough ```mermaid flowchart LR A["Python API Entry Point"] --> B["ParticleBatch Class"] B --> C["Zero-Copy SoA Arrays"] C --> D["Fortran Backend"] D --> E["OpenMP Execution"] B --> F["Samplers Module"] F --> G["Surface/Volume Sampling"] E --> H["BatchResults"] H --> I["Scientific Analysis"] J["Test Infrastructure"] --> K["Performance Benchmarks"] J --> L["Golden Record Validation"] J --> M["Scalability Tests"] N["Streaming Utils"] --> O["Large-Scale Processing"] O --> P["HDF5 Export"] ``` <details> <summary><h3> File Walkthrough</h3></summary> <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>16 files</summary><table> <tr> <td> <details> <summary><strong>scientific_analysis.py</strong><dd><code>Add comprehensive scientific analysis example for physics research</code></dd></summary> <hr> python/examples/scientific_analysis.py • New comprehensive scientific analysis example demonstrating <br>physics-focused capabilities<br> • Implements orbit classification <br>analysis (trapped vs passing particles)<br> • Adds confinement analysis by <br>flux surface and statistical analysis of particle behavior<br> • Includes <br>parameter sweep analysis and physics-focused visualization with <br>matplotlib </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-7382489f08069c8208ed6bc331e8e02b200c25ffa1df29f0096be040a6273fc0">+547/-0</a>&nbsp; </td> </tr> <tr> <td> <details> <summary><strong>performance_comparison.py</strong><dd><code>Add performance comparison and validation example</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> python/examples/performance_comparison.py • New performance validation example comparing Python API against <br>Fortran baseline<br> • Implements golden record validation for numerical <br>accuracy verification<br> • Adds API overhead benchmarking and SoA memory <br>layout optimization verification<br> • Includes OpenMP scaling analysis <br>and integrator performance comparison </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-ae1f3b7f5910608e8ebd05a65d2751f99e9535dfa2f9f3600e181c51ac8511f0">+503/-0</a>&nbsp; </td> </tr> <tr> <td> <details> <summary><strong>memory.py</strong><dd><code>Add memory-efficient streaming utilities for large-scale simulations</code></dd></summary> <hr> python/simple/utils/memory.py • New memory-efficient streaming utilities for processing millions of <br>particles<br> • Implements <code>ParticleBatchStream</code> class for constant memory <br>usage iteration<br> • Adds <code>StreamResults</code> container for HDF5-based large <br>dataset handling<br> • Includes memory monitoring, batch size <br>optimization, and performance estimation functions </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-308814371fbf9241f5041204e351a91320670ce545c019fdd983cfea60d30550">+536/-0</a>&nbsp; </td> </tr> <tr> <td> <details> <summary><strong>large_scale_streaming.py</strong><dd><code>Add large-scale streaming example for memory-efficient processing</code></dd></summary> <hr> python/examples/large_scale_streaming.py • New large-scale streaming example demonstrating memory-efficient <br>particle processing<br> • Shows processing of millions of particles with <br>constant memory usage<br> • Implements HDF5 streaming for large dataset <br>handling and memory usage optimization<br> • Includes performance scaling <br>analysis and complete streaming workflow examples </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-bac182d3204f71d9e5e28b61fd4ac9ff4674bcdae1703ef41f910a8c923b031b">+451/-0</a>&nbsp; </td> </tr> <tr> <td> <details> <summary><strong>results.py</strong><dd><code>Add performance-optimized BatchResults class for simulation analysis</code></dd></summary> <hr> python/simple/core/results.py • New <code>BatchResults</code> class providing zero-copy access to simulation <br>result arrays<br> • Implements vectorized analysis capabilities with <br><code>ConfinementStats</code> dataclass<br> • Adds HDF5 export capabilities and result <br>comparison utilities for golden record validation<br> • Includes <br>surface-based analysis methods and batch result combination <br>functionality </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-d6d2294bac3c8e7fc158551f72e59fccb38bdcc6f23a6b1c397a7ea540892c96">+497/-0</a>&nbsp; </td> </tr> <tr> <td> <details> <summary><strong>file.py</strong><dd><code>Add file-based particle initialization with multiple format support</code></dd></summary> <hr> python/simple/samplers/file.py • New <code>FileSampler</code> class supporting multiple file formats for particle <br>initialization<br> • Implements support for SIMPLE native format, NumPy <br>arrays, HDF5, and ASCII text files<br> • Adds file validation and format <br>detection capabilities<br> • Includes save/load functionality with format <br>conversion between AoS and SoA layouts </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-b378685ca651fb248176abc5a9a52cf487efc49a9059579cb2829157a9e7f4b2">+454/-0</a>&nbsp; </td> </tr> <tr> <td> <details> <summary><strong>surface.py</strong><dd><code>Add surface sampling for flux surface particle initialization</code></dd></summary> <hr> python/simple/samplers/surface.py • New <code>SurfaceSampler</code> class for particle initialization on magnetic <br>flux surfaces<br> • Implements uniform poloidal distribution, flux surface <br>grid, and banana orbit sampling<br> • Adds energy-pitch angle parameter <br>scan capabilities<br> • Includes VMEC equilibrium integration and surface <br>geometry information methods </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-e09d9b036f3987d9eceda81dee745ecd2ccfd4c5bd59f6c4ace0b0ba41a1cfe0">+272/-0</a>&nbsp; </td> </tr> <tr> <td> <details> <summary><strong>__init__.py</strong><dd><code>Add samplers module initialization and exports</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> python/simple/samplers/__init__.py • New samplers module initialization file<br> • Exports <code>SurfaceSampler</code>, <br><code>VolumeSampler</code>, and <code>FileSampler</code> classes<br> • Provides unified interface <br>for particle sampling functionality </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-19ac2b7d4eac1a9fe12173a9aaab8abafc7e7db6040d42dee61e86e31bd3fc71">+18/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>volume.py</strong><dd><code>Volume sampling implementation for particle initialization</code></dd></summary> <hr> python/simple/samplers/volume.py • Implements comprehensive volume sampling methods for particle <br>initialization between flux surfaces<br> • Provides uniform, <br>volume-weighted, radial profile, energy distribution, and layered <br>sampling strategies<br> • Includes specialized sampling algorithms for <br>parabolic, exponential, and linear density profiles<br> • Adds volume <br>geometry information extraction from VMEC equilibrium files </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-b676e3c7cbdf1be6e028d203b99b8796f8e25fb725e524811b5b839a8a6ff2a6">+367/-0</a>&nbsp; </td> </tr> <tr> <td> <details> <summary><strong>batch.py</strong><dd><code>Core ParticleBatch class with zero-copy SoA access</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> python/simple/core/batch.py • Implements <code>ParticleBatch</code> class providing zero-copy access to Fortran <br>SoA arrays<br> • Adds structured coordinate access through <code>Coordinates</code> <br>dataclass<br> • Provides particle initialization methods for surface and <br>volume sampling<br> • Includes SoA memory layout validation and <br>performance measurement utilities </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-7bc7a4aa2306c42794ea6bc3a6d14c44f0cf6fb0565ae574ee10a8fa258f6424">+374/-0</a>&nbsp; </td> </tr> <tr> <td> <details> <summary><strong>simulation.py</strong><dd><code>High-level simulation interface for batch processing</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> python/simple/core/simulation.py • Implements high-level <code>trace_orbits()</code> function for batch orbit <br>tracing<br> • Adds configuration management and integrator mapping <br>functionality<br> • Provides performance benchmarking and golden record <br>validation utilities<br> • Includes convenience functions for quick <br>simulations and parameter sweeps </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-16277448f8c7b023f82b708f0e7dc07bc2162edd5a6be3cf9604e3fa08b47d79">+410/-0</a>&nbsp; </td> </tr> <tr> <td> <details> <summary><strong>fortran.py</strong><dd><code>f90wrap integration backend for zero-copy array access</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> python/simple/backends/fortran.py • f90wrap integration layer providing zero-copy access to existing <br>pysimple module<br> • Implements <code>FortranBackend</code>, <code>FortranArrayWrapper</code>, and <br><code>FortranResultWrapper</code> classes<br> • Provides direct memory access to <br>Fortran SoA arrays with proper validation<br> • Handles simulation <br>execution through existing OpenMP parallelized implementation </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-c4a8e95a52826cfb55b636c312280c35fca7c1567fa65d379be10e06f34702ec">+266/-0</a>&nbsp; </td> </tr> <tr> <td> <details> <summary><strong>__init__.py</strong><dd><code>Main Python API module initialization</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> python/simple/__init__.py • Main module initialization exposing batch-oriented HPC interface<br> • <br>Imports core classes <code>ParticleBatch</code>, <code>BatchResults</code>, and <code>trace_orbits</code> <br>function<br> • Provides comprehensive API documentation and performance <br>guarantees<br> • Defines public interface for samplers, utilities, and <br>memory management </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-395e79efd2c9d5d4b9182f067906d1a2c1b43d838ae12a5ba3b7ce028fad09c9">+50/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>__init__.py</strong><dd><code>Core API components module initialization</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> python/simple/core/__init__.py • Core API components initialization for batch-oriented particle <br>processing<br> • Exports <code>ParticleBatch</code>, <code>BatchResults</code>, and simulation <br>interface classes<br> • Provides clean module structure for batch <br>processing functionality </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-b42f3d445a4905637a46d127b30aed45a7181d43e3a902cdb8f5538fcd6f7847">+21/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>__init__.py</strong><dd><code>Backend implementations module initialization</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> python/simple/backends/__init__.py • Backend implementations module initialization<br> • Exports Fortran <br>backend classes for f90wrap integration<br> • Provides foundation for <br>future native backend implementations </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-575cebea36847fc48bcac5cdae556bc70e6acfccf6c6a015120c0c76bb516a2b">+15/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>__init__.py</strong><dd><code>Utility modules initialization</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> python/simple/utils/__init__.py • Utility modules initialization for memory-efficient processing<br> • <br>Exports streaming classes for large dataset handling<br> • Provides <br>foundation for visualization and analysis utilities </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-503667ef4b813e2e3c4f1443680bcecd1f6ac2314d1d122d653e88ffa388b6e6">+15/-0</a>&nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>6 files</summary><table> <tr> <td> <details> <summary><strong>basic_batch_processing.py</strong><dd><code>Complete batch processing example and tutorial</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> python/examples/basic_batch_processing.py • Comprehensive example demonstrating fundamental batch API usage<br> • <br>Shows surface simulation, SoA performance validation, and data access <br>patterns<br> • Includes integrator comparison, batch operations, and <br>results export examples<br> • Provides complete workflow from <br>initialization to analysis and visualization </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-0639f2cb52dcb449b1ab08217de8f2a30113e4fd708181cb9ab78b080f8415b5">+342/-0</a>&nbsp; </td> </tr> <tr> <td> <details> <summary><strong>DESIGN.md</strong><dd><code>Comprehensive Python API design documentation expansion</code>&nbsp; &nbsp; </dd></summary> <hr> DESIGN.md • Extensive expansion of Phase 1 Python API design with batch-oriented <br>HPC architecture<br> • Detailed class hierarchy, zero-copy SoA wrappers, <br>and performance validation framework<br> • Comprehensive risk assessment, <br>mitigation strategies, and opportunity analysis<br> • GPU-ready <br>architecture preparation and scientific computing ecosystem <br>integration </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-3dc5dd454e080eb849ee5efaf79df2585fbe0a06804d69249b4c81da05a63875">+556/-5</a>&nbsp; </td> </tr> <tr> <td> <details> <summary><strong>README.md</strong><dd><code>Golden record test documentation for batch operations</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> test/golden_record/batch_operations/README.md • Documentation for batch operations golden record test case<br> • Defines <br>validation criteria for batch vs individual particle processing<br> • <br>Specifies performance requirements and expected outputs<br> • Provides <br>usage instructions for golden record comparison system </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-efe0e7ac1031a19395dd7e74089969346e95fb90298898893d0bba5ecf9f7cd6">+39/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>api_reference.md</strong><dd><code>Complete Python API Reference Documentation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> python/docs/api_reference.md • Complete API documentation for the SIMPLE Python batch-oriented HPC <br>interface<br> • Comprehensive documentation for ParticleBatch, <br>BatchResults, and simulation functions<br> • Detailed examples, parameter <br>descriptions, and integration guides for scientific Python ecosystem<br> • <br>Performance specifications and memory management utilities <br>documentation </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-8a4d1586d272824c643a77f81b2c0b847008e766cf8082b10bc3e55fcff765ad">+1298/-0</a></td> </tr> <tr> <td> <details> <summary><strong>user_guide.md</strong><dd><code>Python API User Guide and Tutorial</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> python/docs/user_guide.md • User guide for high-performance Python interface with batch-oriented <br>HPC capabilities<br> • Installation instructions, core concepts, and <br>particle initialization methods<br> • Simulation execution, results <br>analysis, and large-scale processing workflows<br> • Performance <br>optimization, data export, and troubleshooting guidance </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-d84c8a5b5230d5a04f933495c69aa65570fdc43b9952f3887b4d05a40a844774">+523/-0</a>&nbsp; </td> </tr> <tr> <td> <details> <summary><strong>README.md</strong><dd><code>Python API Examples Documentation and Guide</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> python/examples/README.md • Comprehensive examples overview for SIMPLE Python API capabilities<br> • <br>Four main example categories: basic processing, streaming, <br>performance, and scientific analysis<br> • Installation prerequisites, <br>troubleshooting guides, and advanced usage patterns<br> • Integration <br>examples with NumPy, matplotlib, and HDF5 for scientific workflows </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-8d4fef6e9e7bad3f3fdfea5f7bd6bf913624d2578d46b62b1e683b7c81d9c25c">+330/-0</a>&nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Tests</strong></td><td><details><summary>4 files</summary><table> <tr> <td> <details> <summary><strong>test_batch_api.py</strong><dd><code>Comprehensive batch API test infrastructure</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> test/python/test_batch_api.py • Comprehensive test suite for Python batch API validation<br> • Tests SoA <br>memory layout, performance overhead measurement framework<br> • Validates <br>golden record comparison and OpenMP threading safety preparation<br> • <br>Includes scalability testing framework for large particle counts </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-d587a733df19bdbd50952c3594781158653db9b2ded12489fa7fb4a26b97344c">+309/-0</a>&nbsp; </td> </tr> <tr> <td> <details> <summary><strong>performance_benchmark.py</strong><dd><code>Performance benchmarking framework for API validation</code>&nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> test/python/performance_benchmark.py • High-precision performance benchmarking utilities for API validation<br> <br>• Implements statistical timing analysis and overhead calculation <br>framework<br> • Provides specialized particle batch benchmarking and <br>scalability testing<br> • Includes automated performance report generation <br>capabilities </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-e75c35d5da3d195e866bad9b761c813eb9ff97f5ada3870597167f12bb3aefdd">+322/-0</a>&nbsp; </td> </tr> <tr> <td> <details> <summary><strong>CMakeLists.txt</strong><dd><code>CMake Integration for Batch API Golden Record Tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> test/tests/CMakeLists.txt • Add <code>batch_operations</code> golden record test case directory to CMake file <br>copying<br> • Add new <code>golden_record_batch_api</code> test for Python batch API <br>validation against Fortran baseline </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-d4def2b0d5e31d605182011bbbbba821f19e58be523325d4f54368225d15d8e4">+17/-0</a>&nbsp; &nbsp; </td> </tr> <tr> <td> <details> <summary><strong>simple.in</strong><dd><code>Golden Record Configuration for Batch Operations Testing</code>&nbsp; </dd></summary> <hr> test/golden_record/batch_operations/simple.in • New golden record test configuration for 1000 particle batch <br>operations validation<br> • Standard SIMPLE parameters with <code>ntestpart = </code><br><code>1000</code> for batch API comparison testing </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-dd344d2092f2e375c4e5d78925787b86bc81eee83baee013d4c78a4c8db4757d">+25/-0</a>&nbsp; &nbsp; </td> </tr> </table></details></td></tr><tr><td><strong>Configuration changes</strong></td><td><details><summary>1 files</summary><table> <tr> <td> <details> <summary><strong>CMakeLists.txt</strong><dd><code>CMake integration for Python batch API tests</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary> <hr> test/python/CMakeLists.txt • Adds CMake test targets for Python batch API validation<br> • Includes <br>performance benchmarking and scalability test configurations<br> • Sets up <br>proper test environment and labeling for different test categories<br> • <br>Integrates batch API tests into existing CMake test framework </details> </td> <td><a href="https://github.com/itpplasma/SIMPLE/pull/172/files#diff-d5f3f2406c84339b51a25105ba36a2d2fe8997c23581beb0d2583d9cf49ba26a">+30/-0</a>&nbsp; &nbsp; </td> </tr> </table></details></td></tr></tr></tbody></table> </details> ___ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 63899ff commit 0016bff

38 files changed

Lines changed: 2648 additions & 415 deletions

.github/workflows/main.yml

Lines changed: 34 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
77
types: [opened, synchronize, reopened, ready_for_review]
88
workflow_dispatch:
@@ -15,41 +15,15 @@ permissions:
1515
actions: read
1616

1717
jobs:
18-
checkout:
19-
name: Checkout Code
20-
runs-on: self-hosted
21-
if: github.event_name == 'push' || github.event_name == 'pull_request'
22-
23-
steps:
24-
- uses: actions/checkout@v4
25-
26-
- name: Upload repository as artifact
27-
uses: actions/upload-artifact@v4
28-
with:
29-
name: repository
30-
path: .
31-
retention-days: 1
32-
3318
coverage:
3419
name: Run Tests + Generate Coverage
3520
runs-on: self-hosted
36-
needs: checkout
37-
if: (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'pull_request' && github.event.pull_request.draft == false)
38-
39-
steps:
40-
- name: Download repository
41-
uses: actions/download-artifact@v4
42-
with:
43-
name: repository
21+
if: >-
22+
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
23+
(github.event_name == 'pull_request' && github.event.pull_request.draft == false)
4424
45-
- name: Restore executable permissions
46-
run: |
47-
chmod +x test/golden_record_sanity/*.sh
48-
chmod +x test/golden_record/*.sh 2>/dev/null || true
49-
chmod +x test/test_data/*.sh 2>/dev/null || true
50-
chmod +x scripts/*.sh 2>/dev/null || true
51-
chmod +x tools/*.sh 2>/dev/null || true
52-
chmod +x *.sh 2>/dev/null || true
25+
steps:
26+
- uses: actions/checkout@v4
5327

5428
- name: Build SIMPLE with Coverage
5529
run: |
@@ -69,19 +43,20 @@ jobs:
6943
# Fix locale settings to prevent Perl warnings
7044
export LANG=C.UTF-8
7145
export LC_ALL=C.UTF-8
72-
46+
7347
# Use the CMake coverage target which has all the correct exclusions
7448
echo "📊 Generating coverage data using CMake target..."
7549
cmake --build build --target coverage
76-
50+
7751
# Convert to Cobertura XML for coverage-action (using preinstalled lcov_cobertura)
7852
echo "🔄 Converting to Cobertura XML..."
7953
lcov_cobertura build/coverage_filtered.info --output cobertura.xml
80-
54+
8155
# Generate HTML coverage report
8256
echo "📄 Generating HTML coverage report..."
83-
genhtml build/coverage_filtered.info --branch-coverage --prefix "$(pwd)" --output-directory coverage_html || echo "⚠️ HTML generation had warnings"
84-
57+
genhtml build/coverage_filtered.info --branch-coverage --prefix "$(pwd)" \
58+
--output-directory coverage_html || echo "⚠️ HTML generation had warnings"
59+
8560
echo "✅ Coverage reports generated"
8661
8762
- name: Configure git for diff storage
@@ -100,7 +75,7 @@ jobs:
10075
else
10176
echo "❌ cobertura.xml not found"
10277
fi
103-
78+
10479
if [ -f "coverage_filtered.info" ]; then
10580
echo "✅ coverage_filtered.info exists"
10681
echo "File size: $(ls -lh coverage_filtered.info | awk '{print $5}')"
@@ -143,11 +118,11 @@ jobs:
143118
with:
144119
script: |
145120
const fs = require('fs');
146-
121+
147122
// Guard against missing coverage file
148123
if (!fs.existsSync('cobertura.xml')) {
149124
console.log('❌ cobertura.xml not found, setting neutral checks');
150-
125+
151126
// Create neutral checks when coverage data unavailable
152127
const neutralCheck = {
153128
owner: context.repo.owner,
@@ -161,17 +136,17 @@ jobs:
161136
text: 'Coverage report generation failed. Check coverage job logs for details.'
162137
}
163138
};
164-
139+
165140
await github.rest.checks.create({...neutralCheck, name: 'coverage/project'});
166141
await github.rest.checks.create({...neutralCheck, name: 'coverage/patch'});
167142
return;
168143
}
169-
144+
170145
let xml, projectCoverage = '0.00';
171-
146+
172147
try {
173148
xml = fs.readFileSync('cobertura.xml', 'utf8');
174-
149+
175150
// Guard against invalid XML or missing coverage data
176151
const coverageMatch = xml.match(/line-rate="([0-9.]+)"/);
177152
if (coverageMatch && coverageMatch[1]) {
@@ -183,17 +158,17 @@ jobs:
183158
console.log('❌ Error reading coverage file:', error.message);
184159
projectCoverage = '0.00';
185160
}
186-
161+
187162
// For patch coverage, we'll use a simplified approach for now
188163
// In a full implementation, this would analyze only changed lines
189164
const patchCoverage = projectCoverage; // Simplified - normally would calculate differently
190-
165+
191166
const projectThreshold = 70;
192167
const patchThreshold = 70;
193-
168+
194169
const projectPassed = parseFloat(projectCoverage) >= projectThreshold;
195170
const patchPassed = parseFloat(patchCoverage) >= patchThreshold;
196-
171+
197172
try {
198173
// Create project coverage check
199174
await github.rest.checks.create({
@@ -205,14 +180,14 @@ jobs:
205180
conclusion: projectPassed ? 'success' : 'failure',
206181
output: {
207182
title: projectPassed ? `OK - ${projectCoverage}%` : `FAIL - ${projectCoverage}%`,
208-
summary: projectPassed
183+
summary: projectPassed
209184
? `✅ Project coverage ${projectCoverage}% meets the ${projectThreshold}.00% threshold`
210185
: `❌ Project coverage ${projectCoverage}% is below the ${projectThreshold}.00% threshold`,
211186
text: `Current project coverage: ${projectCoverage}%\nRequired threshold: ${projectThreshold}.00%`
212187
}
213188
});
214-
215-
// Create patch coverage check
189+
190+
// Create patch coverage check
216191
await github.rest.checks.create({
217192
owner: context.repo.owner,
218193
repo: context.repo.repo,
@@ -222,13 +197,13 @@ jobs:
222197
conclusion: patchPassed ? 'success' : 'failure',
223198
output: {
224199
title: patchPassed ? `OK - ${patchCoverage}%` : `FAIL - ${patchCoverage}%`,
225-
summary: patchPassed
200+
summary: patchPassed
226201
? `✅ Patch coverage ${patchCoverage}% meets the ${patchThreshold}.00% threshold`
227202
: `❌ Patch coverage ${patchCoverage}% is below the ${patchThreshold}.00% threshold`,
228203
text: `Current patch coverage: ${patchCoverage}%\nRequired threshold: ${patchThreshold}.00%\n\nNote: Patch coverage analyzes only the lines changed in this PR.`
229204
}
230205
});
231-
206+
232207
console.log('✅ Coverage checks created successfully');
233208
} catch (error) {
234209
console.log('❌ Error creating coverage checks:', error.message);
@@ -249,23 +224,12 @@ jobs:
249224
regression:
250225
name: Run Regression Tests
251226
runs-on: self-hosted
252-
needs: checkout
253-
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.draft == false)
254-
255-
steps:
256-
- name: Download repository
257-
uses: actions/download-artifact@v4
258-
with:
259-
name: repository
227+
if: >-
228+
github.event_name == 'push' ||
229+
(github.event_name == 'pull_request' && github.event.pull_request.draft == false)
260230
261-
- name: Restore executable permissions
262-
run: |
263-
chmod +x test/golden_record_sanity/*.sh
264-
chmod +x test/golden_record/*.sh 2>/dev/null || true
265-
chmod +x test/test_data/*.sh 2>/dev/null || true
266-
chmod +x scripts/*.sh 2>/dev/null || true
267-
chmod +x tools/*.sh 2>/dev/null || true
268-
chmod +x *.sh 2>/dev/null || true
231+
steps:
232+
- uses: actions/checkout@v4
269233

270234
- name: Build SIMPLE
271235
run: |
@@ -286,22 +250,9 @@ jobs:
286250
build-docs:
287251
name: Build Documentation
288252
runs-on: self-hosted
289-
needs: checkout
290253

291254
steps:
292-
- name: Download repository
293-
uses: actions/download-artifact@v4
294-
with:
295-
name: repository
296-
297-
- name: Restore executable permissions
298-
run: |
299-
chmod +x test/golden_record_sanity/*.sh
300-
chmod +x test/golden_record/*.sh 2>/dev/null || true
301-
chmod +x test/test_data/*.sh 2>/dev/null || true
302-
chmod +x scripts/*.sh 2>/dev/null || true
303-
chmod +x tools/*.sh 2>/dev/null || true
304-
chmod +x *.sh 2>/dev/null || true
255+
- uses: actions/checkout@v4
305256

306257
- name: Build LaTeX documents
307258
run: |

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Release
2626
Fast
2727
_*.c
2828
*.pyc
29+
__pycache__/
2930
python/launch*
3031
.DS_Store
3132
RUN_*
@@ -61,3 +62,5 @@ cobertura.xml
6162
coverage_html/
6263
coverage-badge.svg
6364
coverage-badge.json
65+
66+
*.html

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"program": "${workspaceFolder}/build/simple.x",
3333
"args": [],
3434
"stopAtEntry": false,
35-
"cwd": "${workspaceFolder}/RUN/alan/",
35+
"cwd": "${workspaceFolder}/RUN/current/",
3636
"environment": [],
3737
"externalConsole": false,
3838
"MIMode": "gdb",

CLAUDE.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ SIMPLE is a symplectic particle orbit tracer for fusion plasma physics, designed
9393
- Example inputs in `examples/simple.in` and downloadable `wout.nc`
9494

9595
### Python Interface
96-
- `pysimple` module built automatically with main library
97-
- Located in `python/` directory with integration examples
98-
- Examples: `examples/example.py`, `examples/example_losses.py`
96+
- `simple` module (`python/simple.py`) - functional API wrapping existing Fortran code
97+
- Example: `python/example_simple_usage.py` - minimal usage demonstration
9998

10099
### Output Files
101100
- `confined_fraction.dat`: Main confinement statistics over time

0 commit comments

Comments
 (0)