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

remap #20

Open
PietroPasotti opened this issue Mar 29, 2023 · 0 comments
Open

remap #20

PietroPasotti opened this issue Mar 29, 2023 · 0 comments
Labels
big brain issue that requires some (complex) spec/design work enhancement New feature or request

Comments

@PietroPasotti
Copy link
Collaborator

PietroPasotti commented Mar 29, 2023

add State.remap(Relation|Container) -> Relation|Container

role: given an object in the input state, get the corresponding one from the output state.
Goal: targeted comparison without the manual search

Right now if you want to check how a relation databag changes during event handling, you have to:

rel_in = Relation("foo")
state_in = State(relations=[rel_in, *<more relations>])
state_out = context.run(event, state_in)
rel_out = filter(lambda r: r.endpoint == rel_in.endpoint, state_out.relations)

That is, you're forced to manually search through all relations in order to find the corresponding one to the relation you've passed in the input state.
This is such a common use case that maybe having a uniform shortcut for 'give me the corresponding object in this state' could be a good API improvement.

This is low priority, syntactic sugar. First investigate how the users feel about it.

@PietroPasotti PietroPasotti added enhancement New feature or request big brain issue that requires some (complex) spec/design work labels Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
big brain issue that requires some (complex) spec/design work enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant