Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
67f28e6
CI pipeline scratch for vlsvreader testing
lassejsc Feb 26, 2026
b42da36
Added venv making
lassejsc Feb 26, 2026
7ca2123
path change
lassejsc Feb 26, 2026
2b3a958
Removed editable since it nukes all
lassejsc Feb 26, 2026
79a36c2
typo fix
lassejsc Feb 26, 2026
4ee3c1c
Added uv source and beginning of next ci test step
lassejsc Feb 26, 2026
89ddce3
Added testpackage test
lassejsc Feb 26, 2026
ab3a210
Rudementary test
lassejsc Feb 26, 2026
00d1b90
Changed the runon to carrington
lassejsc Feb 26, 2026
2a83ebf
Changed job name
lassejsc Feb 26, 2026
9552414
Added module load of gcc and changed python version
lassejsc Feb 26, 2026
f2c0bfc
Added module load of python
lassejsc Feb 26, 2026
2c0ae06
Typo in module load
lassejsc Feb 26, 2026
f22ed5a
Pip install cmake
lassejsc Feb 26, 2026
a9da0e4
Changed to python instead of python3 in cmake to try to fix the CI issue
lassejsc Feb 26, 2026
89aa713
Added -p to get the headers, changed to module loading cmake and changed
lassejsc Feb 26, 2026
56e0cf6
Commented module load of python out in case this fixes somethign
lassejsc Feb 26, 2026
a765b22
Added pip install cmake
lassejsc Feb 26, 2026
20c8038
Merge branch 'fmihpc:master' into CI
lassejsc Feb 26, 2026
58447ab
Test with -p 3.10
lassejsc Feb 26, 2026
06a799c
Maybe this will fix all the problems
lassejsc Feb 26, 2026
5f27718
Export of compilers
lassejsc Feb 26, 2026
212d2b5
GCC load
lassejsc Feb 26, 2026
70efe12
Python3
lassejsc Feb 26, 2026
0852e8f
Python 3.11.11?
lassejsc Feb 26, 2026
dae8ef9
Exact python version and setting it with PY_VERSION env variable
lassejsc Feb 26, 2026
6750e0a
export pyversion variable and module loads etc in testpackage yml
lassejsc Feb 26, 2026
b70a11e
Merge branch 'fmihpc:master' into CI
lassejsc Feb 26, 2026
acccec8
Maybe module load fixes GLIBCXX not being fonud
lassejsc Feb 26, 2026
b9f8aeb
Fixed path
lassejsc Feb 26, 2026
4ea4ac1
Do not hastily fix typos , this will create more typoes
lassejsc Feb 26, 2026
e2871c6
Fixed path
lassejsc Feb 27, 2026
205c8a9
Removed 2D/BCQ run for now and started adding pickle and a way to dump
lassejsc Feb 27, 2026
2d60d12
Testing again with getting cid with vd
lassejsc Feb 27, 2026
c2a3fa4
Changed the path to point to analysator CI data on turso and added runs
lassejsc Feb 27, 2026
72d57de
Added the bulk file for testpackage
lassejsc Feb 27, 2026
17292a7
Added get_file_name() for vlsvrs python
lassejsc Feb 27, 2026
793ba67
Advanced CI stuff, can now do operations on the output of function call
lassejsc Feb 27, 2026
0fb3bf5
Changed paths for ref files on turso
lassejsc Feb 27, 2026
8047f31
Added missing 0 to bulkfile name for testpackage
lassejsc Feb 27, 2026
e7567df
A lot of restructuring and changes to how we store the hashes
lassejsc Mar 2, 2026
8645825
CI pipeline scratch for vlsvreader testing
lassejsc Feb 26, 2026
366c12f
Added venv making
lassejsc Feb 26, 2026
469b0e7
path change
lassejsc Feb 26, 2026
707f29f
Removed editable since it nukes all
lassejsc Feb 26, 2026
71782e3
typo fix
lassejsc Feb 26, 2026
d2e2c46
Added uv source and beginning of next ci test step
lassejsc Feb 26, 2026
7c86e12
Added testpackage test
lassejsc Feb 26, 2026
4a2b2dc
Rudementary test
lassejsc Feb 26, 2026
38e0b82
Fixed missing namespace for PyReadwriteArray1
lassejsc Mar 2, 2026
cd9a915
Merge branch 'master' into CI
lassejsc Mar 2, 2026
476608a
Update .gitlab-ci.yml file
lassejsc Mar 2, 2026
080fe1e
Uncommented cpphelpers build
lassejsc Mar 5, 2026
7b531d3
Merge branch 'master' into CI
lassejsc Mar 5, 2026
8703441
rudementary hash checking and added more variables to read variables
lassejsc Mar 5, 2026
4838ee9
Reset the vlsv_reader.rs to current master
lassejsc Mar 5, 2026
90d1723
Removed fg from the variables to test for now and removed 2D runs
lassejsc Mar 9, 2026
c7e6bce
Added fg variables for testing and made it not sort the return value
lassejsc Mar 9, 2026
a15226b
Minor fixes to the testpackage, had wrong input type that was not han…
lassejsc Mar 10, 2026
5433baa
Restructuring some parts of the hash dict handling
lassejsc Mar 10, 2026
e10f164
Removed gitlab-ci from this branch as it was added here but it already
lassejsc Mar 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/testpackage_reader.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Testpackage turso

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

env:
CARGO_TERM_COLOR: always

jobs:
testpackage:

runs-on: carrington

steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install python and uv
uses: astral-sh/setup-uv@v6
- name: Install packages
run: |
module load GCC/11.3.0
ml Python/3.10.4-GCCcore-11.3.0
export PY_VERSION="3.10.4"
uv venv -p 3.10.4 CI_env
. CI_env/bin/activate
uv pip install cmake
uv pip install ../analysator-backends
uv pip install git+https://github.com/fmihpc/analysator.git
- name: Import test
run: |
module load GCC/11.3.0
. CI_env/bin/activate
python -c "import vlsvrs"
python -c "import cpphelpers"
python -c "import analysator"
- name: Run testpackage
run: |
module load GCC/11.3.0
. CI_env/bin/activate
python ./testpackage/testpackage_vlsvread.py



2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::process::Command;
use std::{env, path::PathBuf};

fn main() {
// let _cpphelpers = cmake::Config::new("cpphelpers").build();
let _cpphelpers = cmake::Config::new("cpphelpers").build();
let zfp_dst = cmake::Config::new("rust/external/zfp")
.define("BUILD_SHARED_LIBS", "OFF")
.build();
Expand Down
2 changes: 1 addition & 1 deletion cpphelpers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.10)
project(cpphelpers)

# Find Python interpreter + development headers + extension suffix
find_package(Python3 COMPONENTS Interpreter Development.Module REQUIRED)
find_package(Python3 $ENV{PY_VERSION} EXACT COMPONENTS Interpreter Development.Module REQUIRED)

# Build the extension module
add_library(cpphelpers SHARED src/cpphelpers.cpp)
Expand Down
Binary file added testpackage/bulk_hermite_compressed.0000001.vlsv
Binary file not shown.
211 changes: 211 additions & 0 deletions testpackage/testpackage_vlsvread.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,211 @@
import analysator as pt
import numpy as np
import vlsvrs
import os
import hashlib
import pickle
import importlib

datalocation = "/turso/group/spacephysics/analysator/CI/analysator-test-data/vlasiator/"
files=["3D/FID/bulk1/bulk1.0000995.vlsv",
"3D/FHA/bulk1/bulk1.0000990.vlsv",
]
class Tester:
def __init__(self,filename=None):
self.filename=filename
self.vlsvobj=None
self.hashes_dict_rust={}
self.hashes_dict_python={}
def changeFile(self,filename):
self.filename=filename
def loadPickle(self,file):
self.pickled = pickle.load(file)
def dumpPickle(self,file):
pickle.dump(self.hashes_dict,file)

def load(self,backend=None):
if not backend or backend.lower()=="rust":
self.vlsvobj_rust=vlsvrs.VlsvFile(self.filename)
if not backend or backend.lower()=="python":
self.vlsvobj_python=pt.vlsvfile.VlsvReader(self.filename)

def setHashTarget(self,backend):
if backend=='rust':
self.vlsvobj=self.vlsvobj_rust
elif backend=='python':
self.vlsvobj=self.vlsvobj_python
else:
print("None set, give valid backend")

def hash(self,func,args,op=None,opargs=None,both=False,loop=False,flatten=True,sort=False):

def update(vlsvobj,op,opargs,args,hashdict,loop=False):
#If we want to repeat same function func with different arguments
if loop:
for arg in args:
print(arg,args)
update(vlsvobj,op,opargs,arg,hashdict)
return 0
argkey=str(args)
opsname="_"+str(op)+"_"+str(opargs)
#Get the method of the vlsvobj that matches the given func str
t=getattr(vlsvobj,func)
#Handle arguments and call the function with the given args to get return value
if type(args) is dict:
retval=t(**args)
elif type(args) is list:
retval=t(*args)
else:
raise IOError(f"Wrong args type: {type(args)} {args}")
#If we want to do operations on the retval for example reshaping, type chaning or sorting
if op and opargs:
#Make into list for handling
if type(op) is not list:
op=[op]
opargs=[opargs]

for i,f in enumerate(op):
try:
fun=getattr(retval,f)
except AttributeError:
try:
#if given function is not method of retval we make retval the argument of function
if '.' in f:
funcl=f.split('.')
#in case it is inside a module like numpy we need to get instance of the module
funcl[0]=importlib.import_module(funcl[0])

fun=getattr(funcl[0],funcl[1])
else:
fun=f
opargs[i]=[retval]
except AttributeError as e:
raise AttributeError(f"Did not find func {func} to operate with: {e}")
retval=fun(*opargs[i])

#save hash of the retval as array
retval=np.array(retval)
print(retval.shape)
if flatten:
retval.reshape((-1,))
if sort:
retval.sort()
# print(retval)
# print(retval.shape)
# print("end")
if self.filename not in hashdict.keys():
hashdict[self.filename]={}
if func not in hashdict:
hashdict[self.filename][func]={}
hashdict[self.filename][func][argkey]=[hashlib.sha256(retval.tobytes()).hexdigest(),opsname]
# if vlsvobj==self.vlsvobj_rust:
# if self.filename not in self.hashes_dict_rust.keys():
# self.hashes_dict_rust[self.filename]={}
# if func not in self.hashes_dict_rust:
# self.hashes_dict_rust[self.filename][func]={}
# self.hashes_dict_rust[self.filename][func][argkey]=[hashlib.sha256(retval.tobytes()).hexdigest(),opsname]
# elif vlsvobj==self.vlsvobj_python:
# if self.filename not in self.hashes_dict_python.keys():
# self.hashes_dict_python[self.filename]={}
# if func not in self.hashes_dict_python:
# self.hashes_dict_python[self.filename][func]={}
# self.hashes_dict_python[self.filename][func][argkey]=[hashlib.sha256(retval.tobytes()).hexdigest(),opsname]
if not both:
if self.vlsvobj==self.vlsvobj_python:
hashdict=self.hashes_dict_python
elif self.vlsvobj==self.vlsvobj_rust:
hashdict=self.hashes_dict_rust
update(self.vlsvobj,op,opargs,args,hashdict,loop)
else:
update(self.vlsvobj_rust,op,opargs,args,self.hashes_dict_rust,loop)
update(self.vlsvobj_python,op,opargs,args,self.hashes_dict_python,loop)

def compare(self,funcpy,argspy,funcrust,argsrust):
try:
py=getattr(self.vlsvobj_python,funcpy)
retval_py=py(**argspy)

rust=getattr(self.vlsvobj_rust,funcrust)
retval_rust=rust(**argsrust)

except Exception as e:
raise e

if type(retval_py) is dict and type(retval_rust) is dict :
stack=list(retval_rust.keys())
if (len(retval_py)!=len(retval_rust)) and len(list(retval_py.keys()))!=0:
raise SystemError("one or both of the dictionaries returned by the readers are empty")
for key in retval_py.keys():
if retval_rust[key] == retval_py[key]:
stack.remove(key) #maybe a some ohter way to remove it is faster?
else:
raise SystemError("returned dictionary values between vlsvreader and vlsvrs do not match")
if len(stack)!=0:
raise KeyError("returned dictionry from vlsvrs contains keys not present in dictonary returned by python.")
return True
else:
raise NotImplementedError


#read ref from file
#(Cellid as variable) reading single cellid ,reading cellid list, (input and output cellid should be same assertion).
#vector (tensor variables from datareduction), read_variable, cellid 0 is nonexistant, error check.
#some datareduction
#read_vdf() (vlsvrs)
# read_variable, compare against fsgird, vg
# read_velocitycells (vlsvreader)

# read_vdf_spares
#
ciTester = Tester()
# files=["s"]
for file in files:

#Load data
filename=os.path.join(datalocation,file)

# filename="/home/siclasse/bulk.0000110.vlsv"
#filename="/home/siclasse/Downloads/bulk_hermite_compressed.0000001.vlsv"
ciTester.changeFile(filename)
ciTester.load()

#Test compare
cid=ciTester.vlsvobj_python.get_cellid_with_vdf(np.array([0,0,0]))
ciTester.compare("read_velocity_cells",{"cellid":cid,"pop":"proton"},"read_vdf_sparse",{"cid":cid,"pop":"proton"})


#Make hash python
ciTester.setHashTarget("rust")
#ciTester.hash("read_variable",{"variable":"CellID","op":0},op=["reshape","astype","numpy.sort"],opargs=[[tuple([-1])],[int],[]],sort=False,flatten=False)
variables_to_test=["CellID","vg_rhom","vg_v","vg_rhoq","proton/vg_rho","proton/vg_v"] #fg_variable read issue with read_variable
variables_to_test_nonraw=["fg_b","fg_v"]
pylist=ciTester.vlsvobj_python.get_variables()
rustlist=ciTester.vlsvobj_rust.list_variables()
variables=[[var] for var in variables_to_test if (var in pylist and var in rustlist)]
nonraw_vars=[[var,0] for var in variables_to_test_nonraw if (var in pylist and var in rustlist)]
ciTester.hash("read_variable_raw",variables,loop=True)
ciTester.hash("read_variable",nonraw_vars,loop=True)

#Make hash python
ciTester.setHashTarget("python")
variables.extend([[var[0]] for var in nonraw_vars]) #prob some prettier way than looping through it all but it's not a big list
ciTester.hash("read_variable",variables,loop=True)


print(ciTester.hashes_dict_python)
print(ciTester.hashes_dict_rust)
key_map_rust_to_py={"read_variable_raw":"read_variable","read_variable":"read_variable"}
for file in ciTester.hashes_dict_rust.keys():
print(f"------{file}------")
for key in ciTester.hashes_dict_rust[file].keys():
py_dict=ciTester.hashes_dict_python[file][key_map_rust_to_py[key]]
rust_dict=ciTester.hashes_dict_rust[file][key]
for argcall in rust_dict.keys():
if rust_dict[argcall][0]!=py_dict[argcall][0]:
print(rust_dict[argcall][0],py_dict[argcall][0])
print("Not match")
else:
print("debug", argcall, rust_dict[argcall][0])



Loading