Skip to content

Commit

Permalink
modify arguments based on installed version of asdf
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyburnett committed Jul 18, 2024
1 parent ab7e4ea commit 7ba5282
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion changelog/422.trivial.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
replace usages of ``copy_arrays`` with ``memmap``
replace usages of ``copy_arrays`` with ``memmap`` for ``asdf>=3.1.0``
7 changes: 6 additions & 1 deletion dkist/dataset/loader.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import importlib.resources as importlib_resources
import importlib.metadata
from pathlib import Path
from functools import singledispatch

Expand Down Expand Up @@ -155,8 +156,12 @@ def _load_from_asdf(filepath):
base_path = filepath.parent
try:
with importlib_resources.as_file(importlib_resources.files("dkist.io") / "level_1_dataset_schema.yaml") as schema_path:
if tuple(int(part) for part in importlib.metadata.version("asdf").split(".")) >= (3, 1, 0):
kwargs = {"memmap": False}
else:
kwargs = {"copy_arrays": True}
with asdf.open(filepath, custom_schema=schema_path.as_posix(),
lazy_load=False, memmap=False) as ff:
lazy_load=False, **kwargs) as ff:
ds = ff.tree["dataset"]
if isinstance(ds, TiledDataset):
for sub in ds.flat:
Expand Down

0 comments on commit 7ba5282

Please sign in to comment.