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

Private metadata attributes are silently lost #418

Open
braingram opened this issue Nov 8, 2024 · 1 comment
Open

Private metadata attributes are silently lost #418

braingram opened this issue Nov 8, 2024 · 1 comment
Assignees

Comments

@braingram
Copy link
Collaborator

>> from roman_datamodels import maker_utils as mk, datamodels as dm
>> m = mk.mk_datamodel(dm.ImageModel)
>> m.meta._foo = 1  # no error
>> m.meta._foo
AttributeError: No attribute _foo

I think this is in part due to _foo getting set on an ephemeral DNode instance.

>> id(m.meta)
4814979664
>> id(m.meta)
5611666880

Which leads to this fun line of code:

>> m.meta is m.meta
False

Saving a reference to and re-using the meta retains _foo:

>> mm = m.meta
>> mm._foo = 1
>> mm._foo
1

I'm not sure if this is a bug but I was surprised by it.

@WilliamJamieson
Copy link
Collaborator

This is expected behavior https://github.com/spacetelescope/roman_datamodels/blob/main/src/roman_datamodels/stnode/_node.py#L214-L215.

Really, we should not be allowing setting of private attributes, however this might break the node internally. I'll need to investigate this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants