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

feat: Add Run.on API to directly add an event callback #516

Merged
merged 2 commits into from
Mar 7, 2025

Conversation

ajbozarth
Copy link
Member

Which issue(s) does this pull-request address?

Closes: #471

Description

This introduces the Run.on method that combines the Run.observe and Emitter.match calls into one more user friendly callback.

Included in this PR:

  • The Run.on method and rework of Run internals to support it
  • Updates to a few demos to leverage the new method
  • Address mypy errors by moving the ContextVar storage to a global, as a ContextVar is intended to be

Checklist

Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
@ajbozarth ajbozarth added enhancement New feature or request python Python related functionality labels Mar 6, 2025
@ajbozarth ajbozarth self-assigned this Mar 6, 2025
@ajbozarth ajbozarth requested a review from a team as a code owner March 6, 2025 20:28
@ajbozarth
Copy link
Member Author

There can still be discussion around the new method's name. I went with Run.on but I also considered the following options if there's strong opinion to switch to one of those: observe_on, match, observe_match, on_event, or to try and overload observe itself (not trivial)

Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
@ajbozarth ajbozarth enabled auto-merge (squash) March 7, 2025 16:57
@ajbozarth ajbozarth merged commit 65abb91 into i-am-bee:main Mar 7, 2025
2 checks passed
@ajbozarth ajbozarth deleted the run-on branch March 7, 2025 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request python Python related functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

We should add a new Run.on API endpoint
2 participants