I think it would be useful for any function which has a Delayed object as either an input or an output, to specify the expected type of the variable after task completion in the doc string. This will reduce the need to follow a chain of function calls to figure out the expected type during development. For example, in the DetectorDescriptorBase class, instead of
def create_computation_graph(self, image_graph: Delayed) -> Tuple[Delayed, Delayed]:
"""
Generates the computation graph for detections and their descriptors.
Args:
image_graph: computation graph for a single image (from a loader).
Returns:
Delayed tasks for detections.
Delayed task for corr. descriptors.
"""
# get delayed object, cannot separate two arguments immediately
joint_graph = dask.delayed(self.detect_and_describe)(image_graph)
keypoints_graph = joint_graph[0]
descriptor_graph = joint_graph[1]
return keypoints_graph, descriptor_graph
It could be something like
def create_computation_graph(self, image_graph: Delayed) -> Tuple[Delayed, Delayed]:
"""
Generates the computation graph for detections and their descriptors.
Args:
image_graph: computation graph for a single image (expects Image).
Returns:
Delayed tasks for detections (expects Keypoints).
Delayed task for corr. descriptors (expects np.ndarray).
"""
# get delayed object, cannot separate two arguments immediately
joint_graph = dask.delayed(self.detect_and_describe)(image_graph)
keypoints_graph = joint_graph[0]
descriptor_graph = joint_graph[1]
return keypoints_graph, descriptor_graph
I think it would be useful for any function which has a
Delayed
object as either an input or an output, to specify the expected type of the variable after task completion in the doc string. This will reduce the need to follow a chain of function calls to figure out the expected type during development. For example, in theDetectorDescriptorBase
class, instead ofIt could be something like