diff --git a/apis/python/node/dora/__init__.py b/apis/python/node/dora/__init__.py index e830ba94..15c2b777 100644 --- a/apis/python/node/dora/__init__.py +++ b/apis/python/node/dora/__init__.py @@ -1,5 +1,6 @@ """ -# dora-rs +# dora-rs. + This is the dora python client for interacting with dora dataflow. You can install it via: ```bash @@ -28,8 +29,7 @@ from .dora import ( class DoraStatus(Enum): - """Dora status to indicate if operator `on_input` loop - should be stopped. + """Dora status to indicate if operator `on_input` loop should be stopped. Args: Enum (u8): Status signaling to dora operator to diff --git a/apis/python/node/dora/__init__.pyi b/apis/python/node/dora/__init__.pyi index c53e86ac..88d656c1 100644 --- a/apis/python/node/dora/__init__.pyi +++ b/apis/python/node/dora/__init__.pyi @@ -16,6 +16,7 @@ class Enum: @typing.final class Node: """The custom node API lets you integrate `dora` into your application. + It allows you to retrieve input and send output in any fashion you want. Use with: @@ -28,7 +29,8 @@ class Node: """ def __init__(self, node_id: str=None) -> None: - """The custom node API lets you integrate `dora` into your application. + """Use the custom node API to embed `dora` into your application. + It allows you to retrieve input and send output in any fashion you want. Use with: @@ -41,21 +43,23 @@ class Node: """ def dataflow_descriptor(self) -> dict: - """Returns the full dataflow descriptor that this node is part of. + """Return the full dataflow descriptor that this node is part of. This method returns the parsed dataflow YAML file. """ def dataflow_id(self) -> str: - """Returns the dataflow id.""" + """Return the dataflow id.""" def merge_external_events(self, subscription: dora.Ros2Subscription) -> None: """Merge an external event stream with dora main loop. + This currently only work with ROS2. """ def next(self, timeout: float=None) -> dict: """`.next()` gives you the next input that the node has received. + It blocks until the next event becomes available. You can use timeout in seconds to return if no input is available. It will return `None` when all senders has been dropped. diff --git a/apis/python/node/dora/cuda.py b/apis/python/node/dora/cuda.py index 578228e5..5a5e0518 100644 --- a/apis/python/node/dora/cuda.py +++ b/apis/python/node/dora/cuda.py @@ -14,7 +14,7 @@ from pyarrow import cuda def torch_to_ipc_buffer(tensor: torch.TensorType) -> tuple[pa.array, dict]: - """Converts a Pytorch tensor into a pyarrow buffer containing the IPC handle and its metadata. + """Convert a Pytorch tensor into a pyarrow buffer containing the IPC handle and its metadata. Example Use: ```python @@ -35,7 +35,7 @@ def torch_to_ipc_buffer(tensor: torch.TensorType) -> tuple[pa.array, dict]: def ipc_buffer_to_ipc_handle(handle_buffer: pa.array) -> cuda.IpcMemHandle: - """Converts a buffer containing a serialized handler into cuda IPC MemHandle. + """Convert a buffer containing a serialized handler into cuda IPC MemHandle. example use: ```python @@ -57,7 +57,7 @@ def ipc_buffer_to_ipc_handle(handle_buffer: pa.array) -> cuda.IpcMemHandle: def cudabuffer_to_numba(buffer: cuda.CudaBuffer, metadata: dict) -> DeviceNDArray: - """Converts a pyarrow CUDA buffer to numba. + """Convert a pyarrow CUDA buffer to numba. example use: ```python @@ -81,7 +81,7 @@ def cudabuffer_to_numba(buffer: cuda.CudaBuffer, metadata: dict) -> DeviceNDArra def cudabuffer_to_torch(buffer: cuda.CudaBuffer, metadata: dict) -> torch.Tensor: - """Converts a pyarrow CUDA buffer to a torch tensor. + """Convert a pyarrow CUDA buffer to a torch tensor. example use: ```python diff --git a/binaries/cli/src/template/python/operator/operator-template.py b/binaries/cli/src/template/python/operator/operator-template.py index 9e48f579..b3d13668 100644 --- a/binaries/cli/src/template/python/operator/operator-template.py +++ b/binaries/cli/src/template/python/operator/operator-template.py @@ -7,14 +7,16 @@ class Operator: """Template docstring.""" def __init__(self): - """Called on initialisation.""" + """Perform initialization tasks.""" def on_event( self, dora_event, send_output, ) -> DoraStatus: - """Args: + """TODO :Description. + + Args: dora_event: Event containing an `id`, `data` and `metadata`. send_output Callable[[str, bytes | pa.Array, Optional[dict]], None]: Function for sending output to the dataflow: @@ -38,4 +40,4 @@ class Operator: return DoraStatus.CONTINUE def __del__(self): - """Called before being deleted.""" + """Perform actions before being deleted.""" diff --git a/examples/python-operator-dataflow/llm_op.py b/examples/python-operator-dataflow/llm_op.py index 5876b182..4bf088df 100644 --- a/examples/python-operator-dataflow/llm_op.py +++ b/examples/python-operator-dataflow/llm_op.py @@ -66,7 +66,7 @@ tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME_OR_PATH, use_fast=True) def extract_python_code_blocks(text): - """Extracts Python code blocks from the given text that are enclosed in triple backticks with a python language identifier. + """Extract Python code blocks from the given text that are enclosed in triple backticks with a python language identifier. Parameters ---------- @@ -90,7 +90,7 @@ def extract_python_code_blocks(text): def extract_json_code_blocks(text): - """Extracts json code blocks from the given text that are enclosed in triple backticks with a json language identifier. + """Extract json code blocks from the given text that are enclosed in triple backticks with a json language identifier. Parameters ---------- @@ -113,7 +113,7 @@ def extract_json_code_blocks(text): def remove_last_line(python_code): - """Removes the last line from a given string of Python code. + """Remove the last line from a given string of Python code. Parameters ---------- @@ -132,6 +132,7 @@ def remove_last_line(python_code): def calculate_similarity(source, target): """Calculate a similarity score between the source and target strings. + This uses the edit distance relative to the length of the strings. """ edit_distance = pylcs.edit_distance(source, target) @@ -142,9 +143,7 @@ def calculate_similarity(source, target): def find_best_match_location(source_code, target_block): - """Find the best match for the target_block within the source_code by searching line by line, - considering blocks of varying lengths. - """ + """Find the best match for the target_block within the source_code by searching line by line, considering blocks of varying lengths.""" source_lines = source_code.split("\n") target_lines = target_block.split("\n") diff --git a/examples/python-operator-dataflow/sentence_transformers_op.py b/examples/python-operator-dataflow/sentence_transformers_op.py index 4aa3ecad..51499be4 100644 --- a/examples/python-operator-dataflow/sentence_transformers_op.py +++ b/examples/python-operator-dataflow/sentence_transformers_op.py @@ -47,7 +47,7 @@ def search(query_embedding, corpus_embeddings, paths, raw, k=5, file_extension=N class Operator: - """ """ + """TODO: Add docstring.""" def __init__(self): ## TODO: Add a initialisation step diff --git a/examples/reachy2/parse_bbox.py b/examples/reachy2/parse_bbox.py index 4b991a85..0edb66bc 100644 --- a/examples/reachy2/parse_bbox.py +++ b/examples/reachy2/parse_bbox.py @@ -13,7 +13,7 @@ IMAGE_RESIZE_RATIO = float(os.getenv("IMAGE_RESIZE_RATIO", "1.0")) def extract_bboxes(json_text): - """Extracts bounding boxes from a JSON string with markdown markers and returns them as a NumPy array. + """Extract bounding boxes from a JSON string with markdown markers and return them as a NumPy array. Parameters ---------- diff --git a/examples/reachy2/parse_bbox_minimal.py b/examples/reachy2/parse_bbox_minimal.py index 8258bbd2..d3800dd6 100644 --- a/examples/reachy2/parse_bbox_minimal.py +++ b/examples/reachy2/parse_bbox_minimal.py @@ -13,7 +13,7 @@ IMAGE_RESIZE_RATIO = float(os.getenv("IMAGE_RESIZE_RATIO", "1.0")) def extract_bboxes(json_text) -> (np.ndarray, np.ndarray): - """Extracts bounding boxes from a JSON string with markdown markers and returns them as a NumPy array. + """Extract bounding boxes from a JSON string with markdown markers and return them as a NumPy array. Parameters ---------- diff --git a/examples/reachy2/pick_place.py b/examples/reachy2/pick_place.py index 04d823a5..93f178a8 100644 --- a/examples/reachy2/pick_place.py +++ b/examples/reachy2/pick_place.py @@ -82,7 +82,7 @@ stop = True def extract_bboxes(json_text) -> (np.ndarray, np.ndarray): - """Extracts bounding boxes from a JSON string with markdown markers and returns them as a NumPy array. + """Extract bounding boxes from a JSON string with markdown markers and return them as a NumPy array. Parameters ---------- diff --git a/node-hub/dora-ios-lidar/dora_ios_lidar/main.py b/node-hub/dora-ios-lidar/dora_ios_lidar/main.py index 66e56f2f..af6c9382 100644 --- a/node-hub/dora-ios-lidar/dora_ios_lidar/main.py +++ b/node-hub/dora-ios-lidar/dora_ios_lidar/main.py @@ -21,7 +21,7 @@ class DemoApp: self.stop = False def on_new_frame(self): - """This method is called from non-main thread, therefore cannot be used for presenting UI.""" + """on_new_frame method is called from non-main thread, therefore cannot be used for presenting UI.""" self.event.set() # Notify the main thread to stop waiting and process new frame. def on_stream_stopped(self): diff --git a/node-hub/dora-pyaudio/dora_pyaudio/main.py b/node-hub/dora-pyaudio/dora_pyaudio/main.py index 67e0729b..2cc3f5f4 100644 --- a/node-hub/dora-pyaudio/dora_pyaudio/main.py +++ b/node-hub/dora-pyaudio/dora_pyaudio/main.py @@ -34,7 +34,7 @@ def play_audio( def main(): - """Main function for the node.""" + """Run main function for the node.""" node = Node() stream = None audio = np.array([])