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

Remove object.__setattr__ frozen bypasses #170

Closed
tonyandrewmeyer opened this issue Aug 12, 2024 · 3 comments
Closed

Remove object.__setattr__ frozen bypasses #170

tonyandrewmeyer opened this issue Aug 12, 2024 · 3 comments

Comments

@tonyandrewmeyer
Copy link
Collaborator

I think we're all agreed that it would be nice if we didn't have to have a bunch of object.__setattr__(self, "attribute", new_value) in the state (while still keeping the immutability that the frozen dataclasses provide).

A few of these are in __post_init__ and probably need to stay as they are. The majority are handling components of the state being changed during the event - new secret content, opening/closing ports, setting the unit/app status, etc. It would be nice to keep the immutability but avoid the object.__setattr__ for those.

@tonyandrewmeyer
Copy link
Collaborator Author

tonyandrewmeyer commented Aug 12, 2024

One thought: what if we had a (meta? sub?) class that behaved like the normal frozen dataclass, but was private, and had a freeze() method that would return the normal frozen dataclass? And instead of doing a copy.deepcopy of the state, we'd copy it into these mutable classes, let the mocking modify things as they normally would, and then when setting the output state, provide the frozen version.

@PietroPasotti
Copy link
Collaborator

yes I like the idea of having an unfrozen ('molten'?) state version for mocking to manipulate during charm execution, and then return its frozen version back to the userspace when we're done.

@tonyandrewmeyer
Copy link
Collaborator Author

Moved to canonical/operator#1423

@tonyandrewmeyer tonyandrewmeyer closed this as not planned Won't fix, can't repro, duplicate, stale Oct 10, 2024
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