Skip to content

Commit

Permalink
Add backwards compat aliasing
Browse files Browse the repository at this point in the history
  • Loading branch information
milesgranger committed Feb 7, 2024
1 parent f6c6571 commit abab923
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
14 changes: 13 additions & 1 deletion distributed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,17 @@
from dask.config import config # type: ignore

from distributed._version import get_versions
from distributed.actor import Actor, ActorTask, BaseActorTask
from distributed.actor import (
Actor,
ActorFuture,
ActorTask,
BaseActorFuture,
BaseActorTask,
)
from distributed.client import (
Client,
CompatibleExecutor,
Future,
Task,
as_completed,
default_client,
Expand All @@ -32,6 +39,7 @@
get_task_metadata,
get_task_stream,
performance_report,
tasks_of,
wait,
)
from distributed.core import Status, connect, rpc
Expand Down Expand Up @@ -121,14 +129,17 @@ def _():
__all__ = [
"Actor",
"ActorTask",
"ActorFuture",
"Adaptive",
"BaseActorTask",
"BaseActorFuture",
"CancelledError",
"Client",
"CompatibleExecutor",
"CondaInstall",
"Environ",
"Event",
"Future",
"Task",
"KilledWorker",
"LocalCluster",
Expand Down Expand Up @@ -163,6 +174,7 @@ def _():
"default_client",
"fire_and_forget",
"futures_of",
"tasks_of",
"get_client",
"get_task_metadata",
"get_task_stream",
Expand Down
6 changes: 6 additions & 0 deletions distributed/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ def __repr__(self) -> Literal["<ActorTask>"]:
return "<ActorTask>"


BaseActorFuture = BaseActorTask


@dataclass(frozen=True, eq=False)
class EagerActorTask(BaseActorTask[_T]):
"""Task to an actor's method call when an actor calls another actor on the same worker"""
Expand Down Expand Up @@ -313,3 +316,6 @@ def _set_result(self, out: _Error | _OK[_T]) -> None:

def result(self, timeout: str | timedelta | float | None = None) -> _T:
return sync(self._io_loop, self._result, callback_timeout=timeout)


ActorFuture = ActorTask
20 changes: 18 additions & 2 deletions distributed/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,9 @@ def __await__(self):
return self.result().__await__()


Future = Task


class TaskState:
"""A Task's internal state.
Expand Down Expand Up @@ -4671,6 +4674,16 @@ async def _get_versions(

return result

def tasks_of(self, tasks):
"""Wrapper method of futures_of
Parameters
----------
tasks : tuple
The tasks
"""
return tasks_of(tasks, client=self)

def futures_of(self, tasks):
"""Wrapper method of futures_of
Expand All @@ -4679,7 +4692,7 @@ def futures_of(self, tasks):
tasks : tuple
The tasks
"""
return futures_of(tasks, client=self)
return tasks_of(tasks, client=self)

@classmethod
def _expand_key(cls, k):
Expand Down Expand Up @@ -5825,7 +5838,7 @@ def redict_collection(c, dsk):
return cc


def futures_of(o, client=None):
def tasks_of(o, client=None):
"""Task objects in a collection
Parameters
Expand Down Expand Up @@ -5877,6 +5890,9 @@ def futures_of(o, client=None):
return tasks[::-1]


futures_of = tasks_of


def fire_and_forget(obj):
"""Run tasks at least once, even if we release the tasks
Expand Down

0 comments on commit abab923

Please sign in to comment.