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

Fix with the latest mypy. #11211

Merged
merged 2 commits into from
Feb 7, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions python-package/xgboost/dask/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,19 +536,16 @@ async def map_worker_partitions(
else:
args.append(ref)

@wraps(func)
def fn(
*args: _P.args, address: str = addr, **kwargs: _P.kwargs
) -> List[_MapRetT]:
# Turn result into a list for bag construction
def fn(_address: str, *args: _P.args, **kwargs: _P.kwargs) -> List[_MapRetT]:
worker = distributed.get_worker()

if worker.address != address:
if worker.address != _address:
raise ValueError(
f"Invalid worker address: {worker.address}, expecting {address}. "
f"Invalid worker address: {worker.address}, expecting {_address}. "
"This is likely caused by one of the workers died and Dask "
"re-scheduled a different one. Resilience is not yet supported."
)
# Turn result into a list for bag construction
return [func(*args, **kwargs)]

# XGBoost requires all workers running training tasks to be unique. Meaning, we
Expand All @@ -568,9 +565,8 @@ def fn(
# relax the constraint and prevent Dask from choosing an invalid worker, the
# task will simply hangs. We prefer a quick error here.
#

fut = client.submit(
fn,
update_wrapper(partial(fn, addr), fn),
*args,
pure=False,
workers=[addr],
Expand Down
2 changes: 1 addition & 1 deletion python-package/xgboost/spark/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class XGBoostTrainingSummary:

@staticmethod
def from_metrics(
metrics: Dict[str, Dict[str, List[float]]]
metrics: Dict[str, Dict[str, List[float]]],
) -> "XGBoostTrainingSummary":
"""
Create an XGBoostTrainingSummary instance from a nested dictionary of metrics.
Expand Down
Loading