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

[POC] "Back to databag" (i.e. dict representation of Abstract Relation Data #143

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

juditnovak
Copy link
Contributor

@juditnovak juditnovak commented Feb 21, 2024

See how it works on ZooKeeper: canonical/zookeeper-operator#122

If the concept is welcome, I'm adding the tests

@juditnovak juditnovak changed the title [POC] Dict representation of Abstract Relation Data [POC] "Back to databag" (i.e. dict representation of Abstract Relation Data Feb 27, 2024
@juditnovak juditnovak marked this pull request as ready for review February 27, 2024 11:02
Base automatically changed from experimenting_with_design_events_split to main March 8, 2024 15:08
@juditnovak
Copy link
Contributor Author

Summary of the offline conversation with @welpaolo :

  • We evaluated what if we use direct inheritace from dict for *Data classes. i.e. no *Data.as_dict() method (as the POC has it at the time this comment is written).
    We agreed that it seems a good idea, as this allows for instantiating the object directly, instead of requiring a second object to benefit from dict access (i.e. X instance, Y = X.as_dict()).
  • However, the above means a bigger, conceptual decision.
    I.e. that Python Standard Library dict would become our confirmed interface for Abstract Relation Data.
    • @welpaolo had once concern: In case Python Standard Lib introduces a (breaking) change, we must follow -- and/or we might need to pin Python versions over the lib
      • Though the above is a valid concern, in my opinion if dict has a (breaking) change, it's likely to have a strong impact on the rest of our code anyway. So adjusting Relation Data may just be part of handling the problem overall.
      • Since no matter what dict IS a key-value mapping, it should ever correspond to the representation of Relation Data from our perspective. Thus overall it should be convenient to be used as an interface.

@juditnovak
Copy link
Contributor Author

@welpaolo
I was an idiot. (Let's hope it's past tense 🤣 )

We need two separate objects.

Data (here still called DataRelation) is bound to a relation-name.

While the dict is representing a specific relation within that "name".

So we can't do better than as_dict(relation_id) :-/

Sorry I was thinking on a wrong track :-/

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

Successfully merging this pull request may close these issues.

1 participant