fixed test suite

This commit is contained in:
2023-01-17 13:05:54 +01:00
parent 3b8cf1657f
commit 1680f5a14b
4 changed files with 17 additions and 6 deletions

3
pytest.ini Normal file
View File

@@ -0,0 +1,3 @@
[pytest]
filterwarnings =
ignore::UserWarning

View File

@@ -13,6 +13,9 @@ from joblib import Parallel, delayed, Memory
from . import utils
from .utils import ROI
# Ideally we automatically determine the cache directory tied to the p-group
# If this fails we try with a fixed path for now, and finally use the
# current temporary directory.
try:
pgroup = utils.heuristic_extract_pgroup()
location = f"/das/work/units/cristallina/p{pgroup}/cachedir"
@@ -20,7 +23,12 @@ except KeyError as e:
print(e)
location = "/das/work/units/cristallina/p19739/cachedir"
memory = Memory(location, verbose=0, compress=2)
try:
memory = Memory(location, verbose=0, compress=2)
except PermissionError as e:
location = "/tmp"
memory = Memory(location, verbose=0, compress=2)
@memory.cache(ignore=["batch_size"]) # we ignore batch_size for caching purposes

View File

@@ -8,7 +8,7 @@ from sfdata import SFDataFiles, sfdatafile, SFScanInfo, SFProcFile
from xraydb import material_mu
from joblib import Parallel, delayed, cpu_count
def scan_info(run_number,base_path=None,small_data=True):
def scan_info(run_number, base_path=None, small_data=True):
"""Returns SFScanInfo object for a given run number.
If there is are small data channels, they will be added (small_data=False to suppress their loading).
"""
@@ -45,10 +45,7 @@ def print_run_info(
Extra verbose output contains all files and pids.
"""
# if base_path == None:
# base_path = heuristic_extract_base_path()
# scan = SFScanInfo(f"{base_path}/run{run_number:04}/meta/scan.json")
scan = scan_info(run_number,base_path=base_path)
scan = scan_info(run_number, base_path=base_path)
short = {}
for key, value in scan.info.items():
if isinstance(value, list):

View File

@@ -6,7 +6,10 @@ from cristallina.utils import ROI, print_run_info, heuristic_extract_pgroup, gau
__author__ = "Alexander Steppke"
def test_print(capsys):
# this currently works only if the heuristic p-group extraction works
# TODO: fix this shortcoming and use base_path throughout
os.chdir("/sf/cristallina/data/p19739/")
print_run_info(247)
captured = capsys.readouterr()
assert "15453208940" in captured.out