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

Improve type annotations for distributed.core.Server #8239

Merged
merged 1 commit into from
Oct 9, 2023

Conversation

hendrikmakait
Copy link
Member

Closes #xxxx

  • Tests added / passed
  • Passes pre-commit run --all-files

@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2023

Unit Test Results

See test report for an extended history of previous test failures. This is useful for diagnosing flaky tests.

       21 files  ±0         21 suites  ±0   10h 35m 11s ⏱️ - 1m 20s
  3 836 tests ±0    3 726 ✔️  - 1     107 💤 ±0  3 +1 
37 083 runs  ±0  35 284 ✔️  - 1  1 796 💤 ±0  3 +1 

For more details on these failures, see this check.

Results for commit e77dd56. ± Comparison against base commit 9a8b380.

@@ -5863,7 +5863,7 @@ def worker_send(self, worker: str, msg: dict[str, Any]) -> None:
stream_comms[worker].send(msg)
except (CommClosedError, AttributeError):
self._ongoing_background_tasks.call_soon(
self.remove_worker,
self.remove_worker, # type: ignore[arg-type]
Copy link
Member Author

Choose a reason for hiding this comment

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

Type annotations on the AsyncTaskGroup are too narrow.

@@ -5909,7 +5909,7 @@ def send_all(self, client_msgs: Msgs, worker_msgs: Msgs) -> None:
pass
except (CommClosedError, AttributeError):
self._ongoing_background_tasks.call_soon(
self.remove_worker,
self.remove_worker, # type: ignore[arg-type]
Copy link
Member Author

Choose a reason for hiding this comment

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

Type annotations on the AsyncTaskGroup are too narrow.

@@ -673,13 +719,13 @@ def stop(self) -> None:
self.monitor.close()
if not (stop_listeners := self._stop_listeners()).done():
self._ongoing_background_tasks.call_soon(
asyncio.wait_for(stop_listeners, timeout=None)
asyncio.wait_for(stop_listeners, timeout=None) # type: ignore[arg-type]
Copy link
Member Author

Choose a reason for hiding this comment

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

Type annotations on the AsyncTaskGroup are too narrow. This should be addressed in a follow-up PR.

@hendrikmakait hendrikmakait marked this pull request as ready for review October 6, 2023 13:41
@hendrikmakait hendrikmakait requested a review from fjetter as a code owner October 6, 2023 13:41
@fjetter fjetter merged commit 275db75 into dask:main Oct 9, 2023
24 of 27 checks passed
Copy link
Collaborator

@crusaderky crusaderky left a comment

Choose a reason for hiding this comment

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

Good work - some minor comments below

@@ -784,7 +831,8 @@ def _to_dict(self, *, exclude: Container[str] = ()) -> dict:
Client.dump_cluster_state
distributed.utils.recursive_to_dict
"""
info = self.identity()
info: dict = {}
info.update(self.identity())
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's more correct to change the return type to dict[str, Any] instead

@@ -963,7 +1011,9 @@ async def _handle_comm(self, comm):
"Failed while closing connection to %r: %s", address, e
)

async def handle_stream(self, comm, extra=None):
async def handle_stream(
self, comm: Comm, extra: dict[str, str] | None = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
self, comm: Comm, extra: dict[str, str] | None = None
self, comm: Comm, extra: dict[str, Any] | None = None

extra are arbitrary kwargs to stream_handlers - I can't see a reason to limit them to str values?

def get_monitor_info(
self, recent: bool = False, start: int = 0
) -> dict[str, float]:
# FIXME: Improve typing
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# FIXME: Improve typing

I think that precisely specifying the possible types of the return dict values would actually do harm.
See python/typing#566

@crusaderky
Copy link
Collaborator

I was too late - my review comments are now in #8247

crusaderky added a commit to crusaderky/distributed that referenced this pull request Oct 9, 2023
hendrikmakait pushed a commit that referenced this pull request Oct 9, 2023
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.

3 participants