Skip to content

Commit c3091a0

Browse files
authored
Tidy DataFuture argument types (#3742)
The task ID is never optional: a DataFuture always comes from a Parsl task. (in the same way that an AppFuture always has a task record) Long ago, Files could be specified as strings. This behaviour was removed slightly less long ago. Right now, typeguard should be detecting if a string is passed, because of the type signature, and so the explicit type check for strings should be unnecessary. This PR removes that explicit type check. The future being tracked by the data future is not necessarily an AppFuture: it can be any kind of future that completes to indicate the represented file is now available. That is already reflected in the type annotations and code, but this PR fixes the docstring. # Changed Behaviour none ## Type of change - Code maintenance/cleanup
1 parent 4686c07 commit c3091a0

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

parsl/app/futures.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"""
33
import logging
44
from concurrent.futures import Future
5-
from typing import Optional
65

76
import typeguard
87

@@ -39,24 +38,23 @@ def parent_callback(self, parent_fu):
3938
self.set_result(self.file_obj)
4039

4140
@typeguard.typechecked
42-
def __init__(self, fut: Future, file_obj: File, tid: Optional[int] = None) -> None:
41+
def __init__(self, fut: Future, file_obj: File, tid: int) -> None:
4342
"""Construct the DataFuture object.
4443
4544
If the file_obj is a string convert to a File.
4645
4746
Args:
48-
- fut (AppFuture) : AppFuture that this DataFuture will track
49-
- file_obj (string/File obj) : Something representing file(s)
47+
- fut (Future) : Future that this DataFuture will track.
48+
Completion of ``fut`` indicates that the data is
49+
ready.
50+
- file_obj (File) : File that this DataFuture represents the availability of
5051
5152
Kwargs:
5253
- tid (task_id) : Task id that this DataFuture tracks
5354
"""
5455
super().__init__()
5556
self._tid = tid
56-
if isinstance(file_obj, File):
57-
self.file_obj = file_obj
58-
else:
59-
raise ValueError("DataFuture must be initialized with a File, not {}".format(type(file_obj)))
57+
self.file_obj = file_obj
6058
self.parent = fut
6159

6260
self.parent.add_done_callback(self.parent_callback)

0 commit comments

Comments
 (0)