Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable "lazy_tree" for all Datamodels #358

Merged
merged 9 commits into from
Jul 31, 2024
Prev Previous commit
Next Next commit
allow lazy nodes during flat_dict
  • Loading branch information
braingram committed Jul 31, 2024
commit cc5b4b6a14755b11dd093faf9b7001c5cd5c55af
5 changes: 3 additions & 2 deletions src/roman_datamodels/datamodels/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import asdf
import numpy as np
from asdf.exceptions import ValidationError
from asdf.lazy_nodes import AsdfDictNode, AsdfListNode
from astropy.time import Time

from roman_datamodels import stnode, validate
Expand Down Expand Up @@ -315,10 +316,10 @@ def items(self):
"""

def recurse(tree, path=[]):
if isinstance(tree, (stnode.DNode, dict)):
if isinstance(tree, (stnode.DNode, dict, AsdfDictNode)):
for key, val in tree.items():
yield from recurse(val, path + [key])
elif isinstance(tree, (stnode.LNode, list, tuple)):
elif isinstance(tree, (stnode.LNode, list, tuple, AsdfListNode)):
for i, val in enumerate(tree):
yield from recurse(val, path + [i])
elif tree is not None:
Expand Down