-
Notifications
You must be signed in to change notification settings - Fork 133
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
async tracking #970
async tracking #970
Conversation
6a4a6b1
to
362f645
Compare
b894880
to
24bfb6d
Compare
Fixes some issues around asynchonrous hooks. This also adds an API for whether we have a synchronous *or* an asynchronous hook. Adds an async API for calling all lifecycle hooks whether they are sync or async.
24bfb6d
to
c50850f
Compare
c50850f
to
cc70f18
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should probably schedule time to walkthrough this -- e.g. how to fix not flushing properly...
Sure. Flushing does work properly. It occasionally flushes after the end of a request rather than before it, but that's expected behavior. |
1372f82
to
becae6a
Compare
|
||
|
||
@asynccontextmanager | ||
async def lifespan(app: fastapi.FastAPI): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have a second endpoint to compare latency/penalty for the tracker.
1. Adds a builder API specifically for the asynchonous driver 2. Fixes up the ASyncGraphAdapter to call hooks in a clean way This does something clever -- the graph adapter takes in the hooks, which then run async while the function is running. Synchronous hooks will work, but they won't be called at quite the right time.
This has a basic queuing system -- we laucnh a periodic task that runs and flushes out a queue -- it times out at the flush interval and flushes everything it has. This will often flush after a request is done but it will always flush.
becae6a
to
93d2432
Compare
hamilton/experimental/h_async.py
Outdated
"Please pass in a single result builder" | ||
) | ||
elif len(result_builders) == 0: | ||
result_builders = [base.DictResult()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO remove this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the next line None
if there are none
But only if the server is running
9ebd205
to
687a5f0
Compare
Its time we support this. Decisions: 1. Did not want to keep it in hamilton.driver, that's getting too bloated and there's name collision 2. Moved over docs to point to the right place (as much as I could) 3. Left it backwards compatible with a warning to update the import
58a3936
to
cdc56cf
Compare
cdc56cf
to
c969458
Compare
Async tracking client:
Changes
Async hooks + tracking client
How I tested this
Unit tests, manually (will be adding more.
Notes
New async builder -- have to call
await h_async.Builder()....build()
TODO:
init
, or make it simpler.as_async()
indriver.Builder
is current pref).ainit()
or not...Checklist