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

Extend dict-like interface for parameters #185

Open
jl-wynen opened this issue Sep 23, 2024 · 3 comments
Open

Extend dict-like interface for parameters #185

jl-wynen opened this issue Sep 23, 2024 · 3 comments

Comments

@jl-wynen
Copy link
Member

Pipeline currently only supports __setitem__. For parameters, it seems natural to have

  • __delitem__
  • update
  • pop
  • __contains__

However, they clash with __getitem__. And it is unclear to me how most should be implemented with regard to providers.

However, at a minimum, I think we should add update.

And we should make sure that Python's default iterator behaviour raises meaningful errors. Currently, it fails because __getitem__ cannot be called with integers. E.g., list(pipeline) and x in pipeline raise KeyError: "Node '0' does not exist in the graph.".

@SimonHeybrock
Copy link
Member

SimonHeybrock commented Sep 25, 2024

I think adding these methods makes perfect sense, but they should not be specific to parameters. Instead, they should behave consistently with the graph operations provided by __getitem__, i.e., no clash?

For example, __contains__ will return True if the node is in the graph, regardless of whether a value is set.

@jl-wynen
Copy link
Member Author

And what about deletion? Would that remove the entire subgraph that leads to a given key? because that is what __getitem__ returns.

@SimonHeybrock
Copy link
Member

Exactly, it would remove the subgraph (all nodes connected to only this one). I think this is probably already implemented as part of __setitem__, since that is what it has to do internally?

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