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

wip Flyte loop in FlyteContext & multi-threaded loops #2759

Merged
merged 11 commits into from
Oct 1, 2024

Conversation

wild-endeavor
Copy link
Contributor

@wild-endeavor wild-endeavor commented Sep 19, 2024

This is a PR into #2752

Changes in this PR (move notes if merging)

  • Create a new loop at module load time that is stored in the FlyteContext but is

    • not started
    • asyncio.set_event_loop is intentionally not called.
      The idea here is that the loop is protected because it's stored in a contextvar and is not associated directly with the asyncio library. However I've seen already one error associated with not calling set_event_loop and others may crop up. Not sure what Jupyter is doing, but if you try to create a new loop in Jupyter, and call asyncio.set_event_loop, it doesn't actually overwrite the event loop. If you call get_running_loop before and after set, it remains the same. Been looking through their code but not sure how they achieved this, they don't seem to be doing anything special.
  • Introduce a threaded coroutine runner, along with helper functions. Basically if already in an async context, and another async function needs to be called from within a synchronous function, then a new thread will be used to run that coroutine and corresponding loop.

Signed-off-by: Yee Hing Tong <[email protected]>
Signed-off-by: Yee Hing Tong <[email protected]>
Signed-off-by: Yee Hing Tong <[email protected]>
Copy link

codecov bot commented Sep 20, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 19 lines in your changes missing coverage. Please review.

Please upload report for BASE (async/simple-te@c5a5a38). Learn more about missing BASE report.

Files with missing lines Patch % Lines
flytekit/utils/async_utils.py 84.48% 7 Missing and 2 partials ⚠️
flytekit/core/type_engine.py 77.14% 6 Missing and 2 partials ⚠️
flytekit/core/context_manager.py 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##             async/simple-te    #2759   +/-   ##
==================================================
  Coverage                   ?   72.34%           
==================================================
  Files                      ?      195           
  Lines                      ?    19946           
  Branches                   ?     3929           
==================================================
  Hits                       ?    14430           
  Misses                     ?     4813           
  Partials                   ?      703           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Yee Hing Tong <[email protected]>
Signed-off-by: Yee Hing Tong <[email protected]>
Signed-off-by: Yee Hing Tong <[email protected]>
Signed-off-by: Yee Hing Tong <[email protected]>
@wild-endeavor wild-endeavor mentioned this pull request Sep 20, 2024
3 tasks
@wild-endeavor wild-endeavor changed the title wip wip Store Flyte loop in FlyteContext Sep 20, 2024
@wild-endeavor wild-endeavor changed the title wip Store Flyte loop in FlyteContext wip Flyte loop in FlyteContext & multi-threaded loops Sep 20, 2024
Signed-off-by: Yee Hing Tong <[email protected]>
@wild-endeavor wild-endeavor marked this pull request as ready for review October 1, 2024 18:11
@wild-endeavor wild-endeavor merged commit 6a48da2 into async/simple-te Oct 1, 2024
97 of 100 checks passed
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