Skip to content

Commit 453f6db

Browse files
authored
Merge pull request #5 from z3rone-org/development
## Architecture & Core * Refactored C#, Rust, and Python layers to use a handle-based architecture, enabling support for simultaneous open files. * Implemented centroid streaming in C# and Rust, including logic to safely skip excessively large raw data payloads. ## Python Bindings * Propagated file handles to all objects in `classes.py` and `raw_file.py` to ensure proper routing for native `get_*` calls. * Added `gradient.py` to parse Vanquish Neo pump gradients from instrument method texts. ## Testing & CI * Added test suite covering centroid streaming, collision energy extraction, gradient parsing, and metadata. * Added compressed `.raw.gz` test data and a `conftest.py` fixture. * Patched CI scripts (`patch_fisher_py.py` and `test.yml`) to resolve `AssemblyLoadContext` loading errors during parity testing. ## Build System & Dependencies * Bundled required Thermo `.dll` files directly into the Python package for Maturin builds. * Updated `build.sh`, `pyproject.toml`, and `.gitignore` configurations.
2 parents 4541fb1 + dd2a441 commit 453f6db

24 files changed

Lines changed: 1615 additions & 849 deletions

.github/patch_fisher_py.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,25 @@ def patch_fisher_py():
2525
with open(init_file, 'r') as f:
2626
content = f.read()
2727

28-
# Add import System.Reflection if needed
29-
if "from System.Reflection import Assembly" not in content:
30-
content = content.replace("from System import Environment", "from System import Environment\nfrom System.Reflection import Assembly")
28+
# Add import sys if needed
29+
if "import sys" not in content:
30+
content = "import sys\n" + content
3131

32-
# Replace clr.AddReference(os.path.join(dll_path, '...'))
33-
# with Assembly.LoadFrom(os.path.realpath(os.path.join(dll_path, '...')))
32+
# Ensure sys.path.append(dll_path) is added
33+
if "sys.path.append(os.path.realpath(dll_path))" not in content:
34+
content = content.replace("clr.AddReference('mscorlib')", "clr.AddReference('mscorlib')\nsys.path.append(os.path.realpath(dll_path))")
35+
36+
# Replace clr.AddReference(os.path.join(dll_path, 'AssemblyName.dll'))
37+
# with clr.AddReference('AssemblyName')
38+
content = re.sub(
39+
r"clr\.AddReference\((?:os\.path\.join\()?dll_path,\s*'([^']+)\.dll'(?:\))?\)",
40+
r"clr.AddReference('\1')",
41+
content
42+
)
43+
# Also clean up any lingering Assembly.LoadFrom from previous patches just in case
3444
content = re.sub(
35-
r"clr\.AddReference\((os\.path\.join\(dll_path, '[^']+'\))\)",
36-
r"Assembly.LoadFrom(os.path.realpath(\1))",
45+
r"Assembly\.LoadFrom\(os\.path\.realpath\(os\.path\.join\(dll_path,\s*'([^']+)\.dll'\)\)\)",
46+
r"clr.AddReference('\1')",
3747
content
3848
)
3949

.github/workflows/test.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
push:
55
branches: [ main ]
66
pull_request:
7-
branches: [ main ]
7+
branches: [ main, development ]
88

99
jobs:
1010
test:
@@ -51,7 +51,7 @@ jobs:
5151
- name: Set up Python
5252
uses: actions/setup-python@v5
5353
with:
54-
python-version: '3.9'
54+
python-version: '3.11'
5555

5656
- name: Install Rust
5757
uses: dtolnay/rust-toolchain@stable
@@ -63,6 +63,9 @@ jobs:
6363
pip install maturin pytest numpy
6464
pip install fisher-py
6565
66+
- name: Decompress test data
67+
run: gunzip -d -k test_data/*.gz
68+
6669
- name: Build and test
6770
run: |
6871
source .venv/bin/activate
@@ -72,7 +75,10 @@ jobs:
7275
cp ${{ env.DYLIB_PATH }} native_fisher_py/python/native_fisher_py/
7376
7477
# Install the package
75-
pip install ./native_fisher_py
78+
cp README.md native_fisher_py/
79+
cd native_fisher_py
80+
maturin develop
81+
cd ..
7682
7783
# Parity tests will automatically fall back to ground_truth.json if fisher-py fails
7884
python -m pytest tests

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ coverage.xml
5454
venv/
5555
pip-log.txt
5656
pip-delete-this-directory.txt
57+
Pipfile
58+
Pipfile.lock
59+
.python-version
5760

5861
# Rust
5962
target/
@@ -68,3 +71,7 @@ publish_output*.txt
6871
_build/
6972
/tmp/
7073
venv3.11/pyvenv.cfg
74+
/scratch
75+
76+
# Downloadable test data
77+
test_data/*.raw

build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ cd ../..
2828
# Copy the built library into the python package directory
2929
# This allows maturin to include it in the wheel
3030
cp $DYLIB_PATH native_fisher_py/python/native_fisher_py/
31+
cp vendor/RawFileReader/Libs/NetCore/Net8/Assemblies/*.dll native_fisher_py/python/native_fisher_py/
3132

3233
# 2. Build Python Package
3334
cd native_fisher_py
3435
export THERMO_NATIVE_LIB=$(pwd)/python/native_fisher_py/$LIB_NAME
3536

3637
# Check for maturin
38+
cp ../README.md README.md
3739
if command -v maturin >/dev/null 2>&1; then
3840
maturin develop
3941
elif command -v pipenv >/dev/null 2>&1 && pipenv run maturin --version >/dev/null 2>&1; then

0 commit comments

Comments
 (0)