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

[dask] Fix with asyncio. #7508

Merged
merged 1 commit into from Dec 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions python-package/xgboost/dask.py
Expand Up @@ -1622,8 +1622,9 @@ def _client_sync(self, func: Callable, **kwargs: Any) -> Any:
should use `worker_client' instead of default client.

"""
asynchronous = getattr(self, "_asynchronous", False)

if self._client is None:
asynchronous = getattr(self, "_asynchronous", False)
try:
distributed.get_worker()
in_worker = True
Expand All @@ -1636,7 +1637,7 @@ def _client_sync(self, func: Callable, **kwargs: Any) -> Any:
return ret
return ret

return self.client.sync(func, **kwargs, asynchronous=asynchronous)
return self.client.sync(func, **kwargs, asynchronous=self.client.asynchronous)


@xgboost_model_doc(
Expand Down
3 changes: 1 addition & 2 deletions tests/python/test_with_dask.py
Expand Up @@ -751,8 +751,7 @@ async def run_from_dask_array_asyncio(scheduler_address: str) -> xgb.dask.TrainR
async def run_dask_regressor_asyncio(scheduler_address: str) -> None:
async with Client(scheduler_address, asynchronous=True) as client:
X, y, _ = generate_array()
regressor = await xgb.dask.DaskXGBRegressor(verbosity=1,
n_estimators=2)
regressor = await xgb.dask.DaskXGBRegressor(verbosity=1, n_estimators=2)
regressor.set_params(tree_method='hist')
regressor.client = client
await regressor.fit(X, y, eval_set=[(X, y)])
Expand Down