Skip to content

Commit 3040922

Browse files
committed
Update
1 parent 67d2198 commit 3040922

File tree

1 file changed

+25
-38
lines changed

1 file changed

+25
-38
lines changed

distributed/client.py

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -358,22 +358,13 @@ def executor(self):
358358
return self.client
359359

360360
@property
361-
def status(
362-
self,
363-
) -> Literal["pending", "cancelled", "finished", "lost", "error"] | None:
361+
def status(self):
364362
"""Returns the status
365363
366364
Returns
367365
-------
368366
str
369367
The status
370-
The status of the future. Possible values:
371-
- "pending": The future is waiting to be computed
372-
- "finished": The future has completed successfully
373-
- "error": The future encountered an error during computation
374-
- "cancelled": The future was cancelled
375-
- "lost": The future's data was lost from memory
376-
- None: The future is not yet bound to a client
377368
"""
378369
if self._state:
379370
return self._state.status
@@ -654,9 +645,7 @@ def __init__(self, key: str):
654645
self._event = None
655646
self.key = key
656647
self.exception = None
657-
self.status: Literal["pending", "cancelled", "finished", "lost", "error"] = (
658-
"pending"
659-
)
648+
self.status = "pending"
660649
self.traceback = None
661650
self.type = None
662651

@@ -810,7 +799,8 @@ def _handle_warn(event):
810799
# TypeError makes sense here because it's analogous to calling a
811800
# function without a required positional argument
812801
raise TypeError(
813-
'_handle_warn: client received a warn event missing the required "message" argument.'
802+
"_handle_warn: client received a warn event missing the required "
803+
'"message" argument.'
814804
)
815805
if "category" in msg:
816806
category = pickle.loads(msg["category"])
@@ -1530,7 +1520,8 @@ async def _reconnect(self):
15301520
st.cancel(
15311521
reason="scheduler-connection-lost",
15321522
msg=(
1533-
"Client lost the connection to the scheduler. Please check your connection and re-run your work."
1523+
"Client lost the connection to the scheduler. "
1524+
"Please check your connection and re-run your work."
15341525
),
15351526
)
15361527
self.futures.clear()
@@ -1551,7 +1542,8 @@ async def _reconnect(self):
15511542

15521543
else:
15531544
logger.error(
1554-
"Failed to reconnect to scheduler after %.2f seconds, closing client",
1545+
"Failed to reconnect to scheduler after %.2f "
1546+
"seconds, closing client",
15551547
self._timeout,
15561548
)
15571549
await self._close()
@@ -1706,7 +1698,8 @@ async def __aexit__(self, exc_type, exc_value, traceback):
17061698
if not e.args[0].endswith(" was created in a different Context"):
17071699
raise # pragma: nocover
17081700
warnings.warn(
1709-
"It is deprecated to enter and exit the Client context manager from different tasks",
1701+
"It is deprecated to enter and exit the Client context "
1702+
"manager from different tasks",
17101703
DeprecationWarning,
17111704
stacklevel=2,
17121705
)
@@ -1724,7 +1717,8 @@ def __exit__(self, exc_type, exc_value, traceback):
17241717
if not e.args[0].endswith(" was created in a different Context"):
17251718
raise # pragma: nocover
17261719
warnings.warn(
1727-
"It is deprecated to enter and exit the Client context manager from different threads",
1720+
"It is deprecated to enter and exit the Client context "
1721+
"manager from different threads",
17281722
DeprecationWarning,
17291723
stacklevel=2,
17301724
)
@@ -2883,7 +2877,8 @@ async def _():
28832877
if name:
28842878
if len(args) == 0:
28852879
raise ValueError(
2886-
"If name is provided, expecting call signature like publish_dataset(df, name='ds')"
2880+
"If name is provided, expecting call signature like"
2881+
" publish_dataset(df, name='ds')"
28872882
)
28882883
# in case this is a singleton, collapse it
28892884
elif len(args) == 1:
@@ -3099,7 +3094,6 @@ async def _run(
30993094
elif resp["status"] == "error":
31003095
# Exception raised by the remote function
31013096
_, exc, tb = clean_exception(**resp)
3102-
assert exc is not None
31033097
exc = exc.with_traceback(tb)
31043098
else:
31053099
assert resp["status"] == "OK"
@@ -3112,7 +3106,8 @@ async def _run(
31123106
results[key] = exc
31133107
elif on_error != "ignore":
31143108
raise ValueError(
3115-
f"on_error must be 'raise', 'return', or 'ignore'; got {on_error!r}"
3109+
"on_error must be 'raise', 'return', or 'ignore'; "
3110+
f"got {on_error!r}"
31163111
)
31173112

31183113
if wait:
@@ -3234,14 +3229,16 @@ def _get_computation_code(
32343229
)
32353230
if not isinstance(ignore_modules, list):
32363231
raise TypeError(
3237-
f"Ignored modules must be a list. Instead got ({type(ignore_modules)}, {ignore_modules})"
3232+
"Ignored modules must be a list. Instead got "
3233+
f"({type(ignore_modules)}, {ignore_modules})"
32383234
)
32393235
ignore_files = dask.config.get(
32403236
"distributed.diagnostics.computations.ignore-files"
32413237
)
32423238
if not isinstance(ignore_files, list):
32433239
raise TypeError(
3244-
f"Ignored files must be a list. Instead got ({type(ignore_files)}, {ignore_files})"
3240+
"Ignored files must be a list. Instead got "
3241+
f"({type(ignore_files)}, {ignore_files})"
32453242
)
32463243

32473244
mod_pattern: re.Pattern | None = None
@@ -3252,20 +3249,8 @@ def _get_computation_code(
32523249
"|".join([f"(?:{mod})" for mod in ignore_modules])
32533250
)
32543251
if ignore_files:
3255-
# Given ignore-files = [foo], match:
3256-
# /path/to/foo
3257-
# /path/to/foo.py[c]
3258-
# /path/to/foo/bar.py[c]
3259-
# \path\to\foo
3260-
# \path\to\foo.py[c]
3261-
# \path\to\foo\bar.py[c]
3262-
# <frozen foo>
3263-
# Do not match files that have 'foo' as a substring,
3264-
# unless the user explicitly states '.*foo.*'.
3265-
ignore_files_or = "|".join(mod for mod in ignore_files)
32663252
fname_pattern = re.compile(
3267-
rf".*[\\/]({ignore_files_or})([\\/]|\.pyc?$|$)"
3268-
rf"|<frozen ({ignore_files_or})>$"
3253+
r".*[\\/](" + "|".join(mod for mod in ignore_files) + r")([\\/]|$)"
32693254
)
32703255
else:
32713256
# stacklevel 0 or less - shows dask internals which likely isn't helpful
@@ -5193,7 +5178,8 @@ def register_scheduler_plugin(
51935178
Do not re-register if a plugin of the given name already exists.
51945179
"""
51955180
warnings.warn(
5196-
"`Client.register_scheduler_plugin` has been deprecated; please `Client.register_plugin` instead",
5181+
"`Client.register_scheduler_plugin` has been deprecated; "
5182+
"please `Client.register_plugin` instead",
51975183
DeprecationWarning,
51985184
stacklevel=2,
51995185
)
@@ -5362,7 +5348,8 @@ def register_worker_plugin(
53625348
unregister_worker_plugin
53635349
"""
53645350
warnings.warn(
5365-
"`Client.register_worker_plugin` has been deprecated; please use `Client.register_plugin` instead",
5351+
"`Client.register_worker_plugin` has been deprecated; "
5352+
"please use `Client.register_plugin` instead",
53665353
DeprecationWarning,
53675354
stacklevel=2,
53685355
)

0 commit comments

Comments
 (0)