-
-
Notifications
You must be signed in to change notification settings - Fork 719
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
Can not get client when not on worker thread #7763
Comments
Not a huge deal here. I have a workaround for my immediate situation. Still, it's a little strange. |
That was actually an intentional change in #7580 The semantics around Can you elaborate how you were using this? I find this usage of Edit: just saw #7762 |
This is related to #7696 |
Hey @fjetter this also breaks Prefect — we provide a utility that uses from distributed import get_client
from prefect import flow, task
from prefect_dask import DaskTaskRunner
@task
def test_task():
# normally this would use our utility, but for simplicity we call directly
client = get_client()
# ValueError: No global client found and no address provided
@flow(task_runner=DaskTaskRunner())
def test_flow():
test_task.submit()
if __name__ == "__main__":
test_flow() I believe the issue here is that we submit a wrapper for tasks to Dask so we orchestrate the task in an async function on a Dask worker but actually run the task in a thread we manage. In that thread, the client cannot be retrieved. Perhaps related to #7339 as well although installing that branch does not fix the error. |
@madkinsz I just tried the latest |
Thanks @jrbourbeau! With a less minimal example, it looks like things are working for us: from prefect import flow, task
from prefect_dask import DaskTaskRunner, get_async_dask_client, get_dask_client
@task
def test_task():
with get_dask_client() as client:
client.submit(lambda x: x, 1).result()
@task
async def atest_task():
async with get_async_dask_client() as client:
await client.submit(lambda x: x, 1)
@flow(task_runner=DaskTaskRunner())
def test_flow():
test_task.submit()
atest_task.submit()
if __name__ == "__main__":
test_flow() I'm also running our CI against |
The text was updated successfully, but these errors were encountered: