Skip to content

Conversation

@pkienzle
Copy link
Member

@pkienzle pkienzle commented May 2, 2025

Redo #219 using the generic function serialization in bumps.

Requires bumps serialize-functions branch for the tests to pass.

Copy link
Member

@bmaranville bmaranville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine to me - I tried it out on a couple models that use FunctionalProfile, and it seems to work. Maybe @acaruana2009 and @hoogerheide might try it to make sure it still does what it is supposed to with those models?

I don't feel as comfortable with the **kwargs interface for setting parameters, or the __setattr__ trap (too many magical and unexpected interfaces), but that is a matter of taste and there is definitely convenience added for those that are willing to learn the mental model.

else:
super().__setattr__(key, value)

def __getattr__(self, key):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait... won't this block access to all the attributes that aren't in pars?

Copy link
Member

@bmaranville bmaranville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am worried about the __getattr__ override in FunctionalProfile... I don't see how you can access the regular attributes of the class with this in place.

@bmaranville
Copy link
Member

note that serialize-functions branch has been merged in bumps, so only remaining blocker is the concern about __getattr__ above.

Copy link
Member

@bmaranville bmaranville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had forgotten the subtlety of when __getattr__ is called... and the attribute-based access to pars is preserving the existing API - I have no further objections to this.

@bmaranville bmaranville merged commit 80a5224 into master Jul 10, 2025
14 checks passed
@bmaranville bmaranville deleted the serialize-functions branch July 10, 2025 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants