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

Use distributed default clients even if no config is set #9808

Merged
merged 5 commits into from
Jan 12, 2023

Conversation

fjetter
Copy link
Member

@fjetter fjetter commented Jan 5, 2023

Partially addresses #9807

Will follow up with the symmetric change in distributed after merging.

Comment on lines -1400 to -1403
if getattr(thread_state, "key", False):
from distributed.worker import get_worker

return get_worker().client.get
Copy link
Member Author

@fjetter fjetter Jan 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is equivalent to the get_client call I introduced below if getattr(thread_state, "key", False) is True so there is no need to have this additional indirection.

By having only a single call, we're changing precedence slightly s.t. a class providing the __dask_scheduler__ attribute wins but I believe this "more correct" considering it is passed explicitly. I doubt this has any relevance.

dask/base.py Outdated
Comment on lines 1402 to 1407
try:
from distributed import get_client

return get_client().get
except ValueError:
pass
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. if we're not requesting anything specific but are executing the default we will always try to get a global distributed client before checking the collections default.
The precedence there is

  1. Worker client
  2. Current client

there is effectively no performance penalty in case there is no distributed worker or client other than raise+except

@fjetter fjetter marked this pull request as ready for review January 10, 2023 13:19
@fjetter fjetter mentioned this pull request Jan 10, 2023
6 tasks
Copy link
Member

@jrbourbeau jrbourbeau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fjetter

dask/base.py Show resolved Hide resolved
dask/base.py Show resolved Hide resolved
@fjetter
Copy link
Member Author

fjetter commented Jan 12, 2023

Test failure is #9793

@jrbourbeau jrbourbeau changed the title Use distributed default clients even if no config is set Use distributed default clients even if no config is set Jan 12, 2023
Copy link
Member

@jrbourbeau jrbourbeau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @fjetter

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.

None yet

2 participants