From 3332c0a1ce4bd44d0c9c3c619dea69d1b8be3881 Mon Sep 17 00:00:00 2001 From: Mati-ur-rehman-017 Date: Mon, 10 Mar 2025 19:25:05 +0500 Subject: [PATCH] Fixed D100 issues --- .vscode/settings.json | 3 +++ apis/python/node/dora/cuda.py | 2 ++ apis/python/node/generate_stubs.py | 15 +++++++++++ .../__node-name__/__node_name__/__init__.py | 2 ++ .../__node-name__/__node_name__/__main__.py | 2 ++ .../__node-name__/__node_name__/main.py | 3 +++ .../python/operator/operator-template.py | 2 ++ examples/cuda-benchmark/demo_receiver.py | 2 ++ examples/cuda-benchmark/demo_sender.py | 2 ++ examples/cuda-benchmark/helper.py | 4 ++- examples/cuda-benchmark/receiver.py | 2 ++ examples/cuda-benchmark/sender.py | 2 ++ examples/openai-server/openai_api_client.py | 4 +++ examples/piper/convert.py | 6 +++++ examples/piper/dummy_inference.py | 2 ++ examples/piper/dummy_inference_2.py | 2 ++ examples/piper/post_process_action.py | 2 ++ examples/piper/record.py | 3 +++ examples/piper/replay.py | 2 ++ .../python-operator-dataflow/file_saver_op.py | 4 +++ .../python-operator-dataflow/keyboard_op.py | 2 ++ examples/python-operator-dataflow/llm_op.py | 5 ++++ .../python-operator-dataflow/microphone_op.py | 3 +++ .../object_detection.py | 3 +++ examples/python-operator-dataflow/plot.py | 4 +++ .../sentence_transformers_op.py | 6 +++++ examples/python-operator-dataflow/utils.py | 2 ++ examples/python-operator-dataflow/webcam.py | 5 ++++ .../python-operator-dataflow/whisper_op.py | 3 +++ examples/python-ros2-dataflow/control_node.py | 2 ++ .../python-ros2-dataflow/random_turtle.py | 2 ++ examples/reachy2/parse_bbox.py | 2 ++ examples/reachy2/parse_bbox_minimal.py | 2 ++ examples/reachy2/pick_place.py | 7 +++++- examples/reachy2/state_machine.py | 4 +++ examples/translation/pretty_print.py | 4 +++ .../ros2-bridge/python/test_utils.py | 2 ++ .../dora_argotranslate/__init__.py | 2 ++ .../dora_argotranslate/main.py | 3 +++ .../tests/test_translate.py | 3 +++ .../dora_distil_whisper/__init__.py | 2 ++ .../dora_distil_whisper/main.py | 5 ++++ .../tests/test_distil_whisper.py | 3 +++ node-hub/dora-echo/dora_echo/__init__.py | 2 ++ node-hub/dora-echo/dora_echo/main.py | 3 +++ node-hub/dora-echo/tests/test_dora_echo.py | 3 +++ .../dora-internvl/dora_internvl/__init__.py | 2 ++ node-hub/dora-internvl/dora_internvl/main.py | 7 ++++++ .../dora-internvl/tests/test_dora_internvl.py | 3 +++ .../dora-ios-lidar/dora_ios_lidar/__init__.py | 2 ++ .../dora-ios-lidar/dora_ios_lidar/__main__.py | 2 ++ .../dora-ios-lidar/dora_ios_lidar/main.py | 10 ++++++++ .../tests/test_dora_ios_lidar.py | 3 +++ .../dora-keyboard/dora_keyboard/__init__.py | 2 ++ node-hub/dora-keyboard/dora_keyboard/main.py | 3 +++ node-hub/dora-keyboard/tests/test_keyboard.py | 3 +++ .../dora_kokoro_tts/__init__.py | 2 ++ .../dora_kokoro_tts/__main__.py | 2 ++ .../dora-kokoro-tts/dora_kokoro_tts/main.py | 3 +++ .../tests/test_dora_kokoro_tts.py | 3 +++ .../dora_microphone/__init__.py | 2 ++ .../dora-microphone/dora_microphone/main.py | 4 +++ .../dora-microphone/tests/test_microphone.py | 3 +++ .../dora_openai_server/__init__.py | 2 ++ .../dora_openai_server/main.py | 12 +++++++++ .../tests/test_dora_openai_server.py | 3 +++ node-hub/dora-opus/dora_opus/__init__.py | 2 ++ node-hub/dora-opus/dora_opus/main.py | 4 +++ node-hub/dora-opus/tests/test_translate.py | 3 +++ .../dora-outtetts/dora_outtetts/__init__.py | 2 ++ .../dora-outtetts/dora_outtetts/__main__.py | 2 ++ node-hub/dora-outtetts/dora_outtetts/main.py | 5 ++++ .../dora_outtetts/tests/test_main.py | 4 +++ node-hub/dora-parler/dora_parler/__init__.py | 2 ++ node-hub/dora-parler/dora_parler/main.py | 10 ++++++++ node-hub/dora-parler/tests/test_parler_tts.py | 3 +++ node-hub/dora-piper/dora_piper/__init__.py | 2 ++ node-hub/dora-piper/dora_piper/main.py | 3 +++ node-hub/dora-piper/tests/test_piper.py | 3 +++ .../dora-pyaudio/dora_pyaudio/__init__.py | 2 ++ .../dora-pyaudio/dora_pyaudio/__main__.py | 2 ++ node-hub/dora-pyaudio/dora_pyaudio/main.py | 2 ++ .../dora-pyaudio/tests/test_dora_pyaudio.py | 3 +++ .../dora_pyorbbecksdk/__init__.py | 2 ++ .../dora_pyorbbecksdk/main.py | 13 ++++++++++ .../tests/test_pyorbbecksdk.py | 3 +++ .../dora_pyrealsense/__init__.py | 2 ++ .../dora-pyrealsense/dora_pyrealsense/main.py | 3 +++ .../tests/test_dora_pyrealsense.py | 3 +++ node-hub/dora-qwen/dora_qwen/__init__.py | 2 ++ node-hub/dora-qwen/dora_qwen/__main__.py | 2 ++ node-hub/dora-qwen/dora_qwen/main.py | 7 ++++++ node-hub/dora-qwen/tests/test_dora_qwen.py | 3 +++ .../dora_qwen2_5_vl/__init__.py | 2 ++ .../dora-qwen2-5-vl/dora_qwen2_5_vl/main.py | 3 +++ .../dora-qwen2-5-vl/tests/test_dora_qwenvl.py | 3 +++ node-hub/dora-qwenvl/dora_qwenvl/__init__.py | 2 ++ node-hub/dora-qwenvl/dora_qwenvl/main.py | 3 +++ .../dora-qwenvl/tests/test_dora_qwenvl.py | 3 +++ node-hub/dora-rdt-1b/dora_rdt_1b/__init__.py | 2 ++ node-hub/dora-rdt-1b/dora_rdt_1b/main.py | 10 +++++++- node-hub/dora-rdt-1b/tests/conftest.py | 3 +++ .../dora-rdt-1b/tests/test_dora_rdt_1b.py | 10 ++++++++ .../dora-reachy2/dora_reachy2/__init__.py | 2 ++ node-hub/dora-reachy2/dora_reachy2/camera.py | 3 +++ node-hub/dora-reachy2/dora_reachy2/head.py | 3 +++ .../dora-reachy2/dora_reachy2/left_arm.py | 5 ++++ .../dora-reachy2/dora_reachy2/mobile_base.py | 3 +++ .../dora-reachy2/dora_reachy2/right_arm.py | 5 ++++ .../dora-reachy2/tests/test_dora_reachy2.py | 3 +++ node-hub/dora-sam2/dora_sam2/__init__.py | 2 ++ node-hub/dora-sam2/dora_sam2/__main__.py | 2 ++ node-hub/dora-sam2/dora_sam2/main.py | 3 +++ node-hub/dora-sam2/tests/test_dora_sam2.py | 3 +++ node-hub/dora-ugv/dora_ugv/__init__.py | 2 ++ node-hub/dora-ugv/dora_ugv/main.py | 3 +++ node-hub/dora-ugv/tests/test_ugv.py | 3 +++ node-hub/dora-vad/dora_vad/__init__.py | 2 ++ node-hub/dora-vad/dora_vad/main.py | 3 +++ node-hub/dora-vad/tests/test_translate.py | 3 +++ node-hub/dora-yolo/dora_yolo/__init__.py | 2 ++ node-hub/dora-yolo/dora_yolo/main.py | 3 +++ .../dora-yolo/tests/test_ultralytics_yolo.py | 3 +++ .../llama_factory_recorder/__init__.py | 2 ++ .../llama_factory_recorder/main.py | 25 +++++++++++++------ .../tests/test_llama_factory_recorder.py | 3 +++ node-hub/opencv-plot/opencv_plot/__init__.py | 2 ++ node-hub/opencv-plot/opencv_plot/main.py | 7 ++++++ .../opencv-plot/tests/test_opencv_plot.py | 3 +++ .../opencv_video_capture/__init__.py | 2 ++ .../opencv_video_capture/main.py | 3 +++ .../tests/test_opencv_video_capture.py | 3 +++ .../pyarrow-assert/pyarrow_assert/__init__.py | 2 ++ .../pyarrow-assert/pyarrow_assert/main.py | 3 +++ .../tests/test_pyarrow_assert.py | 3 +++ .../pyarrow-sender/pyarrow_sender/__init__.py | 2 ++ .../pyarrow-sender/pyarrow_sender/main.py | 3 +++ .../tests/test_pyarrow_sender.py | 3 +++ .../terminal-input/terminal_input/__init__.py | 2 ++ .../terminal-input/terminal_input/main.py | 3 +++ .../tests/test_terminal_input.py | 3 +++ .../receive_data.py | 3 +++ .../send_data.py | 3 +++ .../receive_data.py | 2 ++ .../send_data.py | 2 ++ 145 files changed, 490 insertions(+), 10 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..4cc133ec --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cmake.sourceDirectory": "/home/granger/coding/dora/examples/cmake-dataflow" +} \ No newline at end of file diff --git a/apis/python/node/dora/cuda.py b/apis/python/node/dora/cuda.py index fdd6fba7..578228e5 100644 --- a/apis/python/node/dora/cuda.py +++ b/apis/python/node/dora/cuda.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import pyarrow as pa # Make sure to install torch with cuda diff --git a/apis/python/node/generate_stubs.py b/apis/python/node/generate_stubs.py index 39aae8e1..298928bd 100644 --- a/apis/python/node/generate_stubs.py +++ b/apis/python/node/generate_stubs.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import argparse import ast import importlib @@ -11,6 +13,7 @@ from typing import Any, Dict, List, Optional, Set, Tuple, Union def path_to_type(*elements: str) -> ast.AST: + """TODO: Add docstring.""" base: ast.AST = ast.Name(id=elements[0], ctx=ast.Load()) for e in elements[1:]: base = ast.Attribute(value=base, attr=e, ctx=ast.Load()) @@ -66,6 +69,7 @@ BUILTINS: Dict[str, Union[None, Tuple[List[ast.AST], ast.AST]]] = { def module_stubs(module: Any) -> ast.Module: + """TODO: Add docstring.""" types_to_import = {"typing"} classes = [] functions = [] @@ -100,6 +104,7 @@ def module_stubs(module: Any) -> ast.Module: def class_stubs( cls_name: str, cls_def: Any, element_path: List[str], types_to_import: Set[str], ) -> ast.ClassDef: + """TODO: Add docstring.""" attributes: List[ast.AST] = [] methods: List[ast.AST] = [] magic_methods: List[ast.AST] = [] @@ -200,6 +205,7 @@ def data_descriptor_stub( element_path: List[str], types_to_import: Set[str], ) -> Union[Tuple[ast.AnnAssign, ast.Expr], Tuple[ast.AnnAssign]]: + """TODO: Add docstring.""" annotation = None doc_comment = None @@ -231,6 +237,7 @@ def function_stub( *, in_class: bool, ) -> ast.FunctionDef: + """TODO: Add docstring.""" body: List[ast.AST] = [] doc = inspect.getdoc(fn_def) if doc is not None: @@ -261,6 +268,7 @@ def arguments_stub( element_path: List[str], types_to_import: Set[str], ) -> ast.arguments: + """TODO: Add docstring.""" real_parameters: Mapping[str, inspect.Parameter] = inspect.signature( callable_def, ).parameters @@ -360,6 +368,7 @@ def arguments_stub( def returns_stub( callable_name: str, doc: str, element_path: List[str], types_to_import: Set[str], ) -> Optional[ast.AST]: + """TODO: Add docstring.""" m = re.findall(r"^ *:rtype: *([^\n]*) *$", doc, re.MULTILINE) if len(m) == 0: builtin = BUILTINS.get(callable_name) @@ -379,6 +388,7 @@ def returns_stub( def convert_type_from_doc( type_str: str, element_path: List[str], types_to_import: Set[str], ) -> ast.AST: + """TODO: Add docstring.""" type_str = type_str.strip() return parse_type_to_ast(type_str, element_path, types_to_import) @@ -387,6 +397,7 @@ def parse_type_to_ast( type_str: str, element_path: List[str], types_to_import: Set[str], ) -> ast.AST: # let's tokenize + """TODO: Add docstring.""" tokens = [] current_token = "" for c in type_str: @@ -416,6 +427,7 @@ def parse_type_to_ast( # then it's easy def parse_sequence(sequence: List[Any]) -> ast.AST: # we split based on "or" + """TODO: Add docstring.""" or_groups: List[List[str]] = [[]] print(sequence) # TODO: Fix sequence @@ -467,6 +479,7 @@ def parse_type_to_ast( def concatenated_path_to_type( path: str, element_path: List[str], types_to_import: Set[str], ) -> ast.AST: + """TODO: Add docstring.""" parts = path.split(".") if any(not p for p in parts): raise ValueError( @@ -478,6 +491,7 @@ def concatenated_path_to_type( def build_doc_comment(doc: str) -> Optional[ast.Expr]: + """TODO: Add docstring.""" lines = [line.strip() for line in doc.split("\n")] clean_lines = [] for line in lines: @@ -489,6 +503,7 @@ def build_doc_comment(doc: str) -> Optional[ast.Expr]: def format_with_ruff(file: str) -> None: + """TODO: Add docstring.""" subprocess.check_call(["python", "-m", "ruff", "format", file]) diff --git a/binaries/cli/src/template/python/__node-name__/__node_name__/__init__.py b/binaries/cli/src/template/python/__node-name__/__node_name__/__init__.py index cde7a377..79cbf370 100644 --- a/binaries/cli/src/template/python/__node-name__/__node_name__/__init__.py +++ b/binaries/cli/src/template/python/__node-name__/__node_name__/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/binaries/cli/src/template/python/__node-name__/__node_name__/__main__.py b/binaries/cli/src/template/python/__node-name__/__node_name__/__main__.py index 40e2b013..51a1554d 100644 --- a/binaries/cli/src/template/python/__node-name__/__node_name__/__main__.py +++ b/binaries/cli/src/template/python/__node-name__/__node_name__/__main__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + from .main import main if __name__ == "__main__": diff --git a/binaries/cli/src/template/python/__node-name__/__node_name__/main.py b/binaries/cli/src/template/python/__node-name__/__node_name__/main.py index 51ecda33..99f42676 100644 --- a/binaries/cli/src/template/python/__node-name__/__node_name__/main.py +++ b/binaries/cli/src/template/python/__node-name__/__node_name__/main.py @@ -1,8 +1,11 @@ +"""TODO: Add docstring.""" + import pyarrow as pa from dora import Node def main(): + """TODO: Add docstring.""" node = Node() for event in node: diff --git a/binaries/cli/src/template/python/operator/operator-template.py b/binaries/cli/src/template/python/operator/operator-template.py index f91a233c..9e48f579 100644 --- a/binaries/cli/src/template/python/operator/operator-template.py +++ b/binaries/cli/src/template/python/operator/operator-template.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + from dora import DoraStatus diff --git a/examples/cuda-benchmark/demo_receiver.py b/examples/cuda-benchmark/demo_receiver.py index 461df20a..ea8609ae 100644 --- a/examples/cuda-benchmark/demo_receiver.py +++ b/examples/cuda-benchmark/demo_receiver.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +"""TODO: Add docstring.""" + import os import time diff --git a/examples/cuda-benchmark/demo_sender.py b/examples/cuda-benchmark/demo_sender.py index 0c13c6d3..0f00de90 100644 --- a/examples/cuda-benchmark/demo_sender.py +++ b/examples/cuda-benchmark/demo_sender.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +"""TODO: Add docstring.""" + import os import time diff --git a/examples/cuda-benchmark/helper.py b/examples/cuda-benchmark/helper.py index 18c1f339..dd675013 100644 --- a/examples/cuda-benchmark/helper.py +++ b/examples/cuda-benchmark/helper.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import csv import os import platform @@ -27,7 +29,7 @@ LOG_HEADER = [ def record_results(name, current_size, latencies): - + """TODO: Add docstring.""" avg_latency = np.array(latencies).mean() # Calculate Q1 (25th percentile), median (50th percentile), and Q3 (75th percentile) diff --git a/examples/cuda-benchmark/receiver.py b/examples/cuda-benchmark/receiver.py index 7b700a9c..8115ed16 100644 --- a/examples/cuda-benchmark/receiver.py +++ b/examples/cuda-benchmark/receiver.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +"""TODO: Add docstring.""" + import os import time diff --git a/examples/cuda-benchmark/sender.py b/examples/cuda-benchmark/sender.py index ec7fcb94..702c37f0 100644 --- a/examples/cuda-benchmark/sender.py +++ b/examples/cuda-benchmark/sender.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +"""TODO: Add docstring.""" + import os import time diff --git a/examples/openai-server/openai_api_client.py b/examples/openai-server/openai_api_client.py index 7b8a51dd..0a88d5b1 100644 --- a/examples/openai-server/openai_api_client.py +++ b/examples/openai-server/openai_api_client.py @@ -1,9 +1,12 @@ +"""TODO: Add docstring.""" + from openai import OpenAI client = OpenAI(base_url="http://localhost:8000/v1", api_key="dummy_api_key") def test_list_models(): + """TODO: Add docstring.""" try: models = client.models.list() print("Available models:") @@ -14,6 +17,7 @@ def test_list_models(): def test_chat_completion(user_input): + """TODO: Add docstring.""" try: response = client.chat.completions.create( model="gpt-3.5-turbo", diff --git a/examples/piper/convert.py b/examples/piper/convert.py index 6e94f7d5..b4e65c2b 100644 --- a/examples/piper/convert.py +++ b/examples/piper/convert.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import numpy as np from scipy.spatial.transform import Rotation as R @@ -34,12 +36,14 @@ def convert_rotation_matrix_to_euler(rotmat): def normalize_vector(v): + """TODO: Add docstring.""" v_mag = np.linalg.norm(v, axis=-1, keepdims=True) v_mag = np.maximum(v_mag, 1e-8) return v / v_mag def cross_product(u, v): + """TODO: Add docstring.""" i = u[:, 1] * v[:, 2] - u[:, 2] * v[:, 1] j = u[:, 2] * v[:, 0] - u[:, 0] * v[:, 2] k = u[:, 0] * v[:, 1] - u[:, 1] * v[:, 0] @@ -49,6 +53,7 @@ def cross_product(u, v): def compute_rotation_matrix_from_ortho6d(ortho6d): + """TODO: Add docstring.""" x_raw = ortho6d[:, 0:3] y_raw = ortho6d[:, 3:6] @@ -69,5 +74,6 @@ def compute_ortho6d_from_rotation_matrix(matrix): # rotation matrix: [ | , |, | ] # [ a1, a2, a3] # [ | , |, | ] + """TODO: Add docstring.""" ortho6d = matrix[:, :, :2].transpose(0, 2, 1).reshape(matrix.shape[0], -1) return ortho6d diff --git a/examples/piper/dummy_inference.py b/examples/piper/dummy_inference.py index 08732eed..f15c122c 100644 --- a/examples/piper/dummy_inference.py +++ b/examples/piper/dummy_inference.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + from dora import Node node = Node() diff --git a/examples/piper/dummy_inference_2.py b/examples/piper/dummy_inference_2.py index 946a2a8c..7fc6b605 100644 --- a/examples/piper/dummy_inference_2.py +++ b/examples/piper/dummy_inference_2.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import h5py from dora import Node diff --git a/examples/piper/post_process_action.py b/examples/piper/post_process_action.py index 1da02a60..04e81744 100644 --- a/examples/piper/post_process_action.py +++ b/examples/piper/post_process_action.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + from dora import Node node = Node() diff --git a/examples/piper/record.py b/examples/piper/record.py index ec00de04..193e9bc4 100644 --- a/examples/piper/record.py +++ b/examples/piper/record.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import datetime import os @@ -112,6 +114,7 @@ if not os.path.exists(DATA_DIR): def save_data(data_dict, dataset_path, data_size): + """TODO: Add docstring.""" with h5py.File(dataset_path + ".hdf5", "w", rdcc_nbytes=1024**2 * 2) as root: root.attrs["sim"] = False root.attrs["compress"] = False diff --git a/examples/piper/replay.py b/examples/piper/replay.py index 31c0ac7c..f1a64dd6 100644 --- a/examples/piper/replay.py +++ b/examples/piper/replay.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import h5py diff --git a/examples/python-operator-dataflow/file_saver_op.py b/examples/python-operator-dataflow/file_saver_op.py index ea3bd69d..6874a0e2 100644 --- a/examples/python-operator-dataflow/file_saver_op.py +++ b/examples/python-operator-dataflow/file_saver_op.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import pyarrow as pa from dora import DoraStatus @@ -6,6 +8,7 @@ class Operator: """Inferring object from images.""" def __init__(self): + """TODO: Add docstring.""" self.last_file = "" self.last_path = "" self.last_netadata = None @@ -15,6 +18,7 @@ class Operator: dora_event, send_output, ) -> DoraStatus: + """TODO: Add docstring.""" if dora_event["type"] == "INPUT" and dora_event["id"] == "file": input = dora_event["value"][0].as_py() diff --git a/examples/python-operator-dataflow/keyboard_op.py b/examples/python-operator-dataflow/keyboard_op.py index 70d9e2bc..3aafd693 100644 --- a/examples/python-operator-dataflow/keyboard_op.py +++ b/examples/python-operator-dataflow/keyboard_op.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import pyarrow as pa from dora import Node from pynput import keyboard diff --git a/examples/python-operator-dataflow/llm_op.py b/examples/python-operator-dataflow/llm_op.py index 2e7c4856..5876b182 100644 --- a/examples/python-operator-dataflow/llm_op.py +++ b/examples/python-operator-dataflow/llm_op.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import json import os import re @@ -183,12 +185,14 @@ def replace_code_in_source(source_code, replacement_block: str): class Operator: + """TODO: Add docstring.""" def on_event( self, dora_event, send_output, ) -> DoraStatus: + """TODO: Add docstring.""" if dora_event["type"] == "INPUT" and dora_event["id"] == "code_modifier": input = dora_event["value"][0].as_py() @@ -261,6 +265,7 @@ class Operator: # Generate output # prompt = PROMPT_TEMPLATE.format(system_message=system_message, prompt=prompt)) + """TODO: Add docstring.""" input = tokenizer(prompt, return_tensors="pt") input_ids = input.input_ids.cuda() diff --git a/examples/python-operator-dataflow/microphone_op.py b/examples/python-operator-dataflow/microphone_op.py index 46408938..e3b8affc 100644 --- a/examples/python-operator-dataflow/microphone_op.py +++ b/examples/python-operator-dataflow/microphone_op.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import numpy as np import pyarrow as pa import sounddevice as sd @@ -16,6 +18,7 @@ class Operator: dora_event, send_output, ) -> DoraStatus: + """TODO: Add docstring.""" if dora_event["type"] == "INPUT": audio_data = sd.rec( int(SAMPLE_RATE * MAX_DURATION), diff --git a/examples/python-operator-dataflow/object_detection.py b/examples/python-operator-dataflow/object_detection.py index 7b07b858..d0db8fa5 100755 --- a/examples/python-operator-dataflow/object_detection.py +++ b/examples/python-operator-dataflow/object_detection.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import numpy as np import pyarrow as pa from dora import DoraStatus @@ -18,6 +20,7 @@ class Operator: dora_event, send_output, ) -> DoraStatus: + """TODO: Add docstring.""" if dora_event["type"] == "INPUT": frame = ( dora_event["value"].to_numpy().reshape((CAMERA_HEIGHT, CAMERA_WIDTH, 3)) diff --git a/examples/python-operator-dataflow/plot.py b/examples/python-operator-dataflow/plot.py index f55a3032..a8d0c407 100755 --- a/examples/python-operator-dataflow/plot.py +++ b/examples/python-operator-dataflow/plot.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import cv2 @@ -16,6 +18,7 @@ class Operator: """Plot image and bounding box.""" def __init__(self): + """TODO: Add docstring.""" self.bboxs = [] self.buffer = "" self.submitted = [] @@ -26,6 +29,7 @@ class Operator: dora_event, send_output, ): + """TODO: Add docstring.""" if dora_event["type"] == "INPUT": id = dora_event["id"] value = dora_event["value"] diff --git a/examples/python-operator-dataflow/sentence_transformers_op.py b/examples/python-operator-dataflow/sentence_transformers_op.py index 11952014..4aa3ecad 100644 --- a/examples/python-operator-dataflow/sentence_transformers_op.py +++ b/examples/python-operator-dataflow/sentence_transformers_op.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import sys @@ -15,6 +17,7 @@ SHOULD_BE_INCLUDED = [ ## Get all python files path in given directory def get_all_functions(path): + """TODO: Add docstring.""" raw = [] paths = [] for root, dirs, files in os.walk(path): @@ -34,6 +37,7 @@ def get_all_functions(path): def search(query_embedding, corpus_embeddings, paths, raw, k=5, file_extension=None): + """TODO: Add docstring.""" cos_scores = util.cos_sim(query_embedding, corpus_embeddings)[0] top_results = torch.topk(cos_scores, k=min(k, len(cos_scores)), sorted=True) out = [] @@ -47,6 +51,7 @@ class Operator: def __init__(self): ## TODO: Add a initialisation step + """TODO: Add docstring.""" self.model = SentenceTransformer("BAAI/bge-large-en-v1.5") self.encoding = [] # file directory @@ -61,6 +66,7 @@ class Operator: dora_event, send_output, ) -> DoraStatus: + """TODO: Add docstring.""" if dora_event["type"] == "INPUT": if dora_event["id"] == "query": values = dora_event["value"].to_pylist() diff --git a/examples/python-operator-dataflow/utils.py b/examples/python-operator-dataflow/utils.py index a40bd6d6..de726304 100644 --- a/examples/python-operator-dataflow/utils.py +++ b/examples/python-operator-dataflow/utils.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + LABELS = [ "person", "bicycle", diff --git a/examples/python-operator-dataflow/webcam.py b/examples/python-operator-dataflow/webcam.py index ff2efc7e..db363455 100755 --- a/examples/python-operator-dataflow/webcam.py +++ b/examples/python-operator-dataflow/webcam.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import time @@ -18,6 +20,7 @@ class Operator: """Sending image from webcam to the dataflow.""" def __init__(self): + """TODO: Add docstring.""" self.video_capture = cv2.VideoCapture(CAMERA_INDEX) self.start_time = time.time() self.video_capture.set(cv2.CAP_PROP_FRAME_WIDTH, CAMERA_WIDTH) @@ -29,6 +32,7 @@ class Operator: dora_event: str, send_output, ) -> DoraStatus: + """TODO: Add docstring.""" event_type = dora_event["type"] if event_type == "INPUT": ret, frame = self.video_capture.read() @@ -67,4 +71,5 @@ class Operator: return DoraStatus.STOP def __del__(self): + """TODO: Add docstring.""" self.video_capture.release() diff --git a/examples/python-operator-dataflow/whisper_op.py b/examples/python-operator-dataflow/whisper_op.py index 23955bf0..77a9dfa6 100644 --- a/examples/python-operator-dataflow/whisper_op.py +++ b/examples/python-operator-dataflow/whisper_op.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import pyarrow as pa import whisper from dora import DoraStatus @@ -13,6 +15,7 @@ class Operator: dora_event, send_output, ) -> DoraStatus: + """TODO: Add docstring.""" if dora_event["type"] == "INPUT": audio = dora_event["value"].to_numpy() audio = whisper.pad_or_trim(audio) diff --git a/examples/python-ros2-dataflow/control_node.py b/examples/python-ros2-dataflow/control_node.py index 53a9503f..b2f61b45 100755 --- a/examples/python-ros2-dataflow/control_node.py +++ b/examples/python-ros2-dataflow/control_node.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +"""TODO: Add docstring.""" + import random diff --git a/examples/python-ros2-dataflow/random_turtle.py b/examples/python-ros2-dataflow/random_turtle.py index 64632902..aa95236b 100755 --- a/examples/python-ros2-dataflow/random_turtle.py +++ b/examples/python-ros2-dataflow/random_turtle.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +"""TODO: Add docstring.""" + from dora import Node, Ros2Context, Ros2NodeOptions, Ros2QosPolicies diff --git a/examples/reachy2/parse_bbox.py b/examples/reachy2/parse_bbox.py index 40f19ec0..4b991a85 100644 --- a/examples/reachy2/parse_bbox.py +++ b/examples/reachy2/parse_bbox.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import json import os diff --git a/examples/reachy2/parse_bbox_minimal.py b/examples/reachy2/parse_bbox_minimal.py index 3df24e8c..8258bbd2 100644 --- a/examples/reachy2/parse_bbox_minimal.py +++ b/examples/reachy2/parse_bbox_minimal.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import json import os diff --git a/examples/reachy2/pick_place.py b/examples/reachy2/pick_place.py index 4bfd2b94..04d823a5 100644 --- a/examples/reachy2/pick_place.py +++ b/examples/reachy2/pick_place.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + # State Machine import json import os @@ -114,6 +116,7 @@ def extract_bboxes(json_text) -> (np.ndarray, np.ndarray): def handle_speech(last_text): + """TODO: Add docstring.""" global stop words = last_text.lower().split() if len(ACTIVATION_WORDS) > 0 and any(word in ACTIVATION_WORDS for word in words): @@ -137,7 +140,7 @@ def handle_speech(last_text): def wait_for_event(id, timeout=None, cache={}): - + """TODO: Add docstring.""" while True: event = node.next(timeout=timeout) if event is None: @@ -156,6 +159,7 @@ def wait_for_event(id, timeout=None, cache={}): def wait_for_events(ids: list[str], timeout=None, cache={}): + """TODO: Add docstring.""" response = {} while True: event = node.next(timeout=timeout) @@ -176,6 +180,7 @@ def wait_for_events(ids: list[str], timeout=None, cache={}): def get_prompt(): + """TODO: Add docstring.""" text = wait_for_event(id="text", timeout=0.3) if text is None: return None diff --git a/examples/reachy2/state_machine.py b/examples/reachy2/state_machine.py index 9e129815..b74ab9c6 100644 --- a/examples/reachy2/state_machine.py +++ b/examples/reachy2/state_machine.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + # State Machine import os @@ -76,6 +78,7 @@ l_release_closed_pose = [ def wait_for_event(id, timeout=None): + """TODO: Add docstring.""" while True: event = node.next(timeout=timeout) if event["type"] == "INPUT": @@ -87,6 +90,7 @@ def wait_for_event(id, timeout=None): def wait_for_events(ids: list[str], timeout=None): + """TODO: Add docstring.""" response = {} while True: event = node.next(timeout=timeout) diff --git a/examples/translation/pretty_print.py b/examples/translation/pretty_print.py index 167c3f6c..3f776e70 100644 --- a/examples/translation/pretty_print.py +++ b/examples/translation/pretty_print.py @@ -1,14 +1,18 @@ +"""TODO: Add docstring.""" + import os import shutil def clear_screen(): # Clear the screen based on the operating system + """TODO: Add docstring.""" os.system("cls" if os.name == "nt" else "clear") def print_centered(texts): # Get terminal size + """TODO: Add docstring.""" terminal_size = shutil.get_terminal_size() # Print newlines to move cursor to the middle vertically diff --git a/libraries/extensions/ros2-bridge/python/test_utils.py b/libraries/extensions/ros2-bridge/python/test_utils.py index 021e2f3b..08299ebb 100644 --- a/libraries/extensions/ros2-bridge/python/test_utils.py +++ b/libraries/extensions/ros2-bridge/python/test_utils.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import numpy as np import pyarrow as pa diff --git a/node-hub/dora-argotranslate/dora_argotranslate/__init__.py b/node-hub/dora-argotranslate/dora_argotranslate/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-argotranslate/dora_argotranslate/__init__.py +++ b/node-hub/dora-argotranslate/dora_argotranslate/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-argotranslate/dora_argotranslate/main.py b/node-hub/dora-argotranslate/dora_argotranslate/main.py index 1e949501..43272138 100644 --- a/node-hub/dora-argotranslate/dora_argotranslate/main.py +++ b/node-hub/dora-argotranslate/dora_argotranslate/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os os.environ["ARGOS_DEVICE_TYPE"] = "auto" @@ -22,6 +24,7 @@ argostranslate.package.install_from_path(package_to_install.download()) def main(): + """TODO: Add docstring.""" node = Node() while True: event = node.next() diff --git a/node-hub/dora-argotranslate/tests/test_translate.py b/node-hub/dora-argotranslate/tests/test_translate.py index 3ced2a6d..da3ee044 100644 --- a/node-hub/dora-argotranslate/tests/test_translate.py +++ b/node-hub/dora-argotranslate/tests/test_translate.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from dora_argotranslate.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/dora-distil-whisper/dora_distil_whisper/__init__.py b/node-hub/dora-distil-whisper/dora_distil_whisper/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-distil-whisper/dora_distil_whisper/__init__.py +++ b/node-hub/dora-distil-whisper/dora_distil_whisper/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-distil-whisper/dora_distil_whisper/main.py b/node-hub/dora-distil-whisper/dora_distil_whisper/main.py index 5644d206..eb3c7df7 100644 --- a/node-hub/dora-distil-whisper/dora_distil_whisper/main.py +++ b/node-hub/dora-distil-whisper/dora_distil_whisper/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import sys from pathlib import Path @@ -12,6 +14,7 @@ TRANSLATE = bool(os.getenv("TRANSLATE", "False") in ["True", "true"]) def load_model(): + """TODO: Add docstring.""" from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline MODEL_NAME_OR_PATH = os.getenv("MODEL_NAME_OR_PATH", DEFAULT_PATH) @@ -70,6 +73,7 @@ BAD_SENTENCES = [ def cut_repetition(text, min_repeat_length=4, max_repeat_length=50): + """TODO: Add docstring.""" if len(text) == 0: return text # Check if the text is primarily Chinese (you may need to adjust this threshold) @@ -103,6 +107,7 @@ def cut_repetition(text, min_repeat_length=4, max_repeat_length=50): def main(): + """TODO: Add docstring.""" node = Node() # For macos use mlx: diff --git a/node-hub/dora-distil-whisper/tests/test_distil_whisper.py b/node-hub/dora-distil-whisper/tests/test_distil_whisper.py index b0039c79..0c5ada0a 100644 --- a/node-hub/dora-distil-whisper/tests/test_distil_whisper.py +++ b/node-hub/dora-distil-whisper/tests/test_distil_whisper.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from dora_distil_whisper.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/dora-echo/dora_echo/__init__.py b/node-hub/dora-echo/dora_echo/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-echo/dora_echo/__init__.py +++ b/node-hub/dora-echo/dora_echo/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-echo/dora_echo/main.py b/node-hub/dora-echo/dora_echo/main.py index 4c668630..6558d69e 100644 --- a/node-hub/dora-echo/dora_echo/main.py +++ b/node-hub/dora-echo/dora_echo/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import argparse import os @@ -8,6 +10,7 @@ RUNNER_CI = True if os.getenv("CI") == "true" else False def main(): # Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables. + """TODO: Add docstring.""" parser = argparse.ArgumentParser(description="Simple arrow sender") parser.add_argument( diff --git a/node-hub/dora-echo/tests/test_dora_echo.py b/node-hub/dora-echo/tests/test_dora_echo.py index fee40070..6c1aa354 100644 --- a/node-hub/dora-echo/tests/test_dora_echo.py +++ b/node-hub/dora-echo/tests/test_dora_echo.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from dora_echo.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/dora-internvl/dora_internvl/__init__.py b/node-hub/dora-internvl/dora_internvl/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-internvl/dora_internvl/__init__.py +++ b/node-hub/dora-internvl/dora_internvl/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-internvl/dora_internvl/main.py b/node-hub/dora-internvl/dora_internvl/main.py index c9b7c9a3..194c2177 100644 --- a/node-hub/dora-internvl/dora_internvl/main.py +++ b/node-hub/dora-internvl/dora_internvl/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import numpy as np @@ -14,6 +16,7 @@ IMAGENET_STD = (0.229, 0.224, 0.225) def build_transform(input_size): + """TODO: Add docstring.""" MEAN, STD = IMAGENET_MEAN, IMAGENET_STD transform = T.Compose( [ @@ -27,6 +30,7 @@ def build_transform(input_size): def find_closest_aspect_ratio(aspect_ratio, target_ratios, width, height, image_size): + """TODO: Add docstring.""" best_ratio_diff = float("inf") best_ratio = (1, 1) area = width * height @@ -45,6 +49,7 @@ def find_closest_aspect_ratio(aspect_ratio, target_ratios, width, height, image_ def dynamic_preprocess( image, min_num=1, max_num=12, image_size=448, use_thumbnail=False, ): + """TODO: Add docstring.""" orig_width, orig_height = image.size aspect_ratio = orig_width / orig_height @@ -89,6 +94,7 @@ def dynamic_preprocess( def load_image(image_array: np.array, input_size=448, max_num=12): + """TODO: Add docstring.""" image = Image.fromarray(image_array).convert("RGB") transform = build_transform(input_size=input_size) images = dynamic_preprocess( @@ -101,6 +107,7 @@ def load_image(image_array: np.array, input_size=448, max_num=12): def main(): # Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables. + """TODO: Add docstring.""" model_path = os.getenv("MODEL", "OpenGVLab/InternVL2-1B") device = "cuda:0" if torch.cuda.is_available() else "cpu" diff --git a/node-hub/dora-internvl/tests/test_dora_internvl.py b/node-hub/dora-internvl/tests/test_dora_internvl.py index baabff78..9abe7bb0 100644 --- a/node-hub/dora-internvl/tests/test_dora_internvl.py +++ b/node-hub/dora-internvl/tests/test_dora_internvl.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from dora_internvl.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/dora-ios-lidar/dora_ios_lidar/__init__.py b/node-hub/dora-ios-lidar/dora_ios_lidar/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-ios-lidar/dora_ios_lidar/__init__.py +++ b/node-hub/dora-ios-lidar/dora_ios_lidar/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory 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 40e2b013..51a1554d 100644 --- a/node-hub/dora-ios-lidar/dora_ios_lidar/__main__.py +++ b/node-hub/dora-ios-lidar/dora_ios_lidar/__main__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + from .main import main if __name__ == "__main__": 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 c432d981..66e56f2f 100644 --- a/node-hub/dora-ios-lidar/dora_ios_lidar/main.py +++ b/node-hub/dora-ios-lidar/dora_ios_lidar/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + from threading import Event import cv2 @@ -8,7 +10,10 @@ from record3d import Record3DStream class DemoApp: + """TODO: Add docstring.""" + def __init__(self): + """TODO: Add docstring.""" self.event = Event() self.session = None self.DEVICE_TYPE__TRUEDEPTH = 0 @@ -20,10 +25,12 @@ class DemoApp: self.event.set() # Notify the main thread to stop waiting and process new frame. def on_stream_stopped(self): + """TODO: Add docstring.""" self.stop = True print("Stream stopped") def connect_to_device(self, dev_idx): + """TODO: Add docstring.""" print("Searching for devices") devs = Record3DStream.get_connected_devices() print(f"{len(devs)} device(s) found") @@ -42,11 +49,13 @@ class DemoApp: self.session.connect(dev) # Initiate connection and start capturing def get_intrinsic_mat_from_coeffs(self, coeffs): + """TODO: Add docstring.""" return np.array( [[coeffs.fx, 0, coeffs.tx], [0, coeffs.fy, coeffs.ty], [0, 0, 1]], ) def start_processing_stream(self): + """TODO: Add docstring.""" node = Node() for event in node: @@ -98,6 +107,7 @@ class DemoApp: def main(): + """TODO: Add docstring.""" app = DemoApp() app.connect_to_device(dev_idx=0) app.start_processing_stream() diff --git a/node-hub/dora-ios-lidar/tests/test_dora_ios_lidar.py b/node-hub/dora-ios-lidar/tests/test_dora_ios_lidar.py index 8ea3b973..2567116a 100644 --- a/node-hub/dora-ios-lidar/tests/test_dora_ios_lidar.py +++ b/node-hub/dora-ios-lidar/tests/test_dora_ios_lidar.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from dora_ios_lidar.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/dora-keyboard/dora_keyboard/__init__.py b/node-hub/dora-keyboard/dora_keyboard/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-keyboard/dora_keyboard/__init__.py +++ b/node-hub/dora-keyboard/dora_keyboard/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-keyboard/dora_keyboard/main.py b/node-hub/dora-keyboard/dora_keyboard/main.py index 0a315d0f..f3858fe0 100644 --- a/node-hub/dora-keyboard/dora_keyboard/main.py +++ b/node-hub/dora-keyboard/dora_keyboard/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import pyarrow as pa from dora import Node from pynput import keyboard @@ -5,6 +7,7 @@ from pynput.keyboard import Events def main(): + """TODO: Add docstring.""" node = Node() always_none = node.next(timeout=0.001) is None diff --git a/node-hub/dora-keyboard/tests/test_keyboard.py b/node-hub/dora-keyboard/tests/test_keyboard.py index 5ac295b7..fbea8356 100644 --- a/node-hub/dora-keyboard/tests/test_keyboard.py +++ b/node-hub/dora-keyboard/tests/test_keyboard.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from dora_keyboard.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/dora-kokoro-tts/dora_kokoro_tts/__init__.py b/node-hub/dora-kokoro-tts/dora_kokoro_tts/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-kokoro-tts/dora_kokoro_tts/__init__.py +++ b/node-hub/dora-kokoro-tts/dora_kokoro_tts/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-kokoro-tts/dora_kokoro_tts/__main__.py b/node-hub/dora-kokoro-tts/dora_kokoro_tts/__main__.py index 40e2b013..51a1554d 100644 --- a/node-hub/dora-kokoro-tts/dora_kokoro_tts/__main__.py +++ b/node-hub/dora-kokoro-tts/dora_kokoro_tts/__main__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + from .main import main if __name__ == "__main__": diff --git a/node-hub/dora-kokoro-tts/dora_kokoro_tts/main.py b/node-hub/dora-kokoro-tts/dora_kokoro_tts/main.py index 22975f8e..9df7f503 100644 --- a/node-hub/dora-kokoro-tts/dora_kokoro_tts/main.py +++ b/node-hub/dora-kokoro-tts/dora_kokoro_tts/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import pyarrow as pa from dora import Node from kokoro import KPipeline @@ -6,6 +8,7 @@ pipeline = KPipeline(lang_code="a") # <= make sure lang_code matches voice def main(): + """TODO: Add docstring.""" node = Node() for event in node: diff --git a/node-hub/dora-kokoro-tts/tests/test_dora_kokoro_tts.py b/node-hub/dora-kokoro-tts/tests/test_dora_kokoro_tts.py index 34dd2872..dd955248 100644 --- a/node-hub/dora-kokoro-tts/tests/test_dora_kokoro_tts.py +++ b/node-hub/dora-kokoro-tts/tests/test_dora_kokoro_tts.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from dora_kokoro_tts.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/dora-microphone/dora_microphone/__init__.py b/node-hub/dora-microphone/dora_microphone/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-microphone/dora_microphone/__init__.py +++ b/node-hub/dora-microphone/dora_microphone/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-microphone/dora_microphone/main.py b/node-hub/dora-microphone/dora_microphone/main.py index 16160bcb..b45756bc 100644 --- a/node-hub/dora-microphone/dora_microphone/main.py +++ b/node-hub/dora-microphone/dora_microphone/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import time as tm @@ -12,6 +14,7 @@ SAMPLE_RATE = int(os.getenv("SAMPLE_RATE", "16000")) def main(): # Initialize buffer and recording flag + """TODO: Add docstring.""" buffer = [] start_recording_time = tm.time() node = Node() @@ -20,6 +23,7 @@ def main(): finished = False def callback(indata, frames, time, status): + """TODO: Add docstring.""" nonlocal buffer, node, start_recording_time, finished if tm.time() - start_recording_time > MAX_DURATION: diff --git a/node-hub/dora-microphone/tests/test_microphone.py b/node-hub/dora-microphone/tests/test_microphone.py index 1e31830d..d0311045 100644 --- a/node-hub/dora-microphone/tests/test_microphone.py +++ b/node-hub/dora-microphone/tests/test_microphone.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from dora_microphone.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/dora-openai-server/dora_openai_server/__init__.py b/node-hub/dora-openai-server/dora_openai_server/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-openai-server/dora_openai_server/__init__.py +++ b/node-hub/dora-openai-server/dora_openai_server/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-openai-server/dora_openai_server/main.py b/node-hub/dora-openai-server/dora_openai_server/main.py index 32007729..aa4c25b8 100644 --- a/node-hub/dora-openai-server/dora_openai_server/main.py +++ b/node-hub/dora-openai-server/dora_openai_server/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import ast import asyncio from typing import List, Optional @@ -13,11 +15,15 @@ app = FastAPI() class ChatCompletionMessage(BaseModel): + """TODO: Add docstring.""" + role: str content: str class ChatCompletionRequest(BaseModel): + """TODO: Add docstring.""" + model: str messages: List[ChatCompletionMessage] temperature: Optional[float] = 1.0 @@ -25,6 +31,8 @@ class ChatCompletionRequest(BaseModel): class ChatCompletionResponse(BaseModel): + """TODO: Add docstring.""" + id: str object: str created: int @@ -38,6 +46,7 @@ node = Node() # provide the name to connect to the dataflow if dynamic node @app.post("/v1/chat/completions") async def create_chat_completion(request: ChatCompletionRequest): + """TODO: Add docstring.""" data = next( (msg.content for msg in request.messages if msg.role == "user"), "No user message found.", @@ -95,6 +104,7 @@ async def create_chat_completion(request: ChatCompletionRequest): @app.get("/v1/models") async def list_models(): + """TODO: Add docstring.""" return { "object": "list", "data": [ @@ -109,6 +119,7 @@ async def list_models(): async def run_fastapi(): + """TODO: Add docstring.""" config = uvicorn.Config(app, host="0.0.0.0", port=8000, log_level="info") server = uvicorn.Server(config) @@ -121,6 +132,7 @@ async def run_fastapi(): def main(): + """TODO: Add docstring.""" asyncio.run(run_fastapi()) diff --git a/node-hub/dora-openai-server/tests/test_dora_openai_server.py b/node-hub/dora-openai-server/tests/test_dora_openai_server.py index 58bc516c..47f02427 100644 --- a/node-hub/dora-openai-server/tests/test_dora_openai_server.py +++ b/node-hub/dora-openai-server/tests/test_dora_openai_server.py @@ -1,2 +1,5 @@ +"""TODO: Add docstring.""" + def test_import_main(): + """TODO: Add docstring.""" pass diff --git a/node-hub/dora-opus/dora_opus/__init__.py b/node-hub/dora-opus/dora_opus/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-opus/dora_opus/__init__.py +++ b/node-hub/dora-opus/dora_opus/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-opus/dora_opus/main.py b/node-hub/dora-opus/dora_opus/main.py index ece8e1ed..eb35b9c2 100644 --- a/node-hub/dora-opus/dora_opus/main.py +++ b/node-hub/dora-opus/dora_opus/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os from pathlib import Path @@ -26,6 +28,7 @@ model = AutoModelForSeq2SeqLM.from_pretrained(MODEL_NAME_OR_PATH) def cut_repetition(text, min_repeat_length=4, max_repeat_length=50): # Check if the text is primarily Chinese (you may need to adjust this threshold) + """TODO: Add docstring.""" if sum(1 for char in text if "\u4e00" <= char <= "\u9fff") / len(text) > 0.5: # Chinese text processing for repeat_length in range( @@ -54,6 +57,7 @@ def cut_repetition(text, min_repeat_length=4, max_repeat_length=50): def main(): + """TODO: Add docstring.""" node = Node() while True: event = node.next() diff --git a/node-hub/dora-opus/tests/test_translate.py b/node-hub/dora-opus/tests/test_translate.py index 63ba4f80..34db2f82 100644 --- a/node-hub/dora-opus/tests/test_translate.py +++ b/node-hub/dora-opus/tests/test_translate.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from dora_opus.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/dora-outtetts/dora_outtetts/__init__.py b/node-hub/dora-outtetts/dora_outtetts/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-outtetts/dora_outtetts/__init__.py +++ b/node-hub/dora-outtetts/dora_outtetts/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-outtetts/dora_outtetts/__main__.py b/node-hub/dora-outtetts/dora_outtetts/__main__.py index 40e2b013..51a1554d 100644 --- a/node-hub/dora-outtetts/dora_outtetts/__main__.py +++ b/node-hub/dora-outtetts/dora_outtetts/__main__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + from .main import main if __name__ == "__main__": diff --git a/node-hub/dora-outtetts/dora_outtetts/main.py b/node-hub/dora-outtetts/dora_outtetts/main.py index 69d92d24..6ef841cc 100644 --- a/node-hub/dora-outtetts/dora_outtetts/main.py +++ b/node-hub/dora-outtetts/dora_outtetts/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import argparse # Add argparse import import os import pathlib @@ -15,6 +17,7 @@ torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32 def load_interface(): + """TODO: Add docstring.""" if os.getenv("INTERFACE", "HF") == "HF": model_config = outetts.HFModelConfig_v1( model_path="OuteAI/OuteTTS-0.2-500M", @@ -39,6 +42,7 @@ def load_interface(): def create_speaker(interface, path): + """TODO: Add docstring.""" speaker = interface.create_speaker( audio_path=path, # If transcript is not provided, it will be automatically transcribed using Whisper @@ -53,6 +57,7 @@ def create_speaker(interface, path): def main(arg_list: list[str] | None = None): # Parse cli args + """TODO: Add docstring.""" parser = argparse.ArgumentParser(description="Dora Outetts Node") parser.add_argument("--create-speaker", type=str, help="Path to audio file") parser.add_argument("--test", action="store_true", help="Run tests") diff --git a/node-hub/dora-outtetts/dora_outtetts/tests/test_main.py b/node-hub/dora-outtetts/dora_outtetts/tests/test_main.py index a96d4fc7..45bf6183 100644 --- a/node-hub/dora-outtetts/dora_outtetts/tests/test_main.py +++ b/node-hub/dora-outtetts/dora_outtetts/tests/test_main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import pytest @@ -7,11 +9,13 @@ CI = os.getenv("CI", "false") in ["True", "true"] def test_import_main(): + """TODO: Add docstring.""" with pytest.raises(RuntimeError): main([]) def test_load_interface(): + """TODO: Add docstring.""" try: interface = load_interface() except RuntimeError: diff --git a/node-hub/dora-parler/dora_parler/__init__.py b/node-hub/dora-parler/dora_parler/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-parler/dora_parler/__init__.py +++ b/node-hub/dora-parler/dora_parler/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-parler/dora_parler/main.py b/node-hub/dora-parler/dora_parler/main.py index e82564b9..e6d221ed 100644 --- a/node-hub/dora-parler/dora_parler/main.py +++ b/node-hub/dora-parler/dora_parler/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import time from pathlib import Path @@ -58,6 +60,7 @@ stream = p.open(format=pyaudio.paInt16, channels=1, rate=sampling_rate, output=T def play_audio(audio_array): + """TODO: Add docstring.""" if np.issubdtype(audio_array.dtype, np.floating): max_val = np.max(np.abs(audio_array)) audio_array = (audio_array / max_val) * 32767 @@ -67,16 +70,21 @@ def play_audio(audio_array): class InterruptStoppingCriteria(StoppingCriteria): + """TODO: Add docstring.""" + def __init__(self): + """TODO: Add docstring.""" super().__init__() self.stop_signal = False def __call__( self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs, ) -> bool: + """TODO: Add docstring.""" return self.stop_signal def stop(self): + """TODO: Add docstring.""" self.stop_signal = True @@ -86,6 +94,7 @@ def generate_base( description=default_description, play_steps_in_s=0.5, ): + """TODO: Add docstring.""" prev_time = time.time() play_steps = int(frame_rate * play_steps_in_s) inputs = tokenizer(description, return_tensors="pt").to(device) @@ -133,6 +142,7 @@ def generate_base( def main(): + """TODO: Add docstring.""" generate_base(None, "Ready !", default_description, 0.5) node = Node() while True: diff --git a/node-hub/dora-parler/tests/test_parler_tts.py b/node-hub/dora-parler/tests/test_parler_tts.py index fdb34db2..91bb5dcd 100644 --- a/node-hub/dora-parler/tests/test_parler_tts.py +++ b/node-hub/dora-parler/tests/test_parler_tts.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from dora_parler.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/dora-piper/dora_piper/__init__.py b/node-hub/dora-piper/dora_piper/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-piper/dora_piper/__init__.py +++ b/node-hub/dora-piper/dora_piper/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-piper/dora_piper/main.py b/node-hub/dora-piper/dora_piper/main.py index df147530..f5e4af41 100644 --- a/node-hub/dora-piper/dora_piper/main.py +++ b/node-hub/dora-piper/dora_piper/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import time @@ -43,6 +45,7 @@ def enable_fun(piper: C_PiperInterface): def main(): + """TODO: Add docstring.""" elapsed_time = time.time() CAN_BUS = os.getenv("CAN_BUS", "") piper = C_PiperInterface(CAN_BUS) diff --git a/node-hub/dora-piper/tests/test_piper.py b/node-hub/dora-piper/tests/test_piper.py index a58efc3f..ecbd2bd9 100644 --- a/node-hub/dora-piper/tests/test_piper.py +++ b/node-hub/dora-piper/tests/test_piper.py @@ -1,4 +1,7 @@ +"""TODO: Add docstring.""" + def test_import_main(): + """TODO: Add docstring.""" from piper_sdk import C_PiperInterface ## Test piper installation diff --git a/node-hub/dora-pyaudio/dora_pyaudio/__init__.py b/node-hub/dora-pyaudio/dora_pyaudio/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-pyaudio/dora_pyaudio/__init__.py +++ b/node-hub/dora-pyaudio/dora_pyaudio/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-pyaudio/dora_pyaudio/__main__.py b/node-hub/dora-pyaudio/dora_pyaudio/__main__.py index 40e2b013..51a1554d 100644 --- a/node-hub/dora-pyaudio/dora_pyaudio/__main__.py +++ b/node-hub/dora-pyaudio/dora_pyaudio/__main__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + from .main import main if __name__ == "__main__": diff --git a/node-hub/dora-pyaudio/dora_pyaudio/main.py b/node-hub/dora-pyaudio/dora_pyaudio/main.py index 825cd532..67e0729b 100644 --- a/node-hub/dora-pyaudio/dora_pyaudio/main.py +++ b/node-hub/dora-pyaudio/dora_pyaudio/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import numpy as np diff --git a/node-hub/dora-pyaudio/tests/test_dora_pyaudio.py b/node-hub/dora-pyaudio/tests/test_dora_pyaudio.py index 73d84a70..1492eb6e 100644 --- a/node-hub/dora-pyaudio/tests/test_dora_pyaudio.py +++ b/node-hub/dora-pyaudio/tests/test_dora_pyaudio.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from dora_pyaudio.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/dora-pyorbbecksdk/dora_pyorbbecksdk/__init__.py b/node-hub/dora-pyorbbecksdk/dora_pyorbbecksdk/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-pyorbbecksdk/dora_pyorbbecksdk/__init__.py +++ b/node-hub/dora-pyorbbecksdk/dora_pyorbbecksdk/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-pyorbbecksdk/dora_pyorbbecksdk/main.py b/node-hub/dora-pyorbbecksdk/dora_pyorbbecksdk/main.py index eb2d38ca..3e431631 100644 --- a/node-hub/dora-pyorbbecksdk/dora_pyorbbecksdk/main.py +++ b/node-hub/dora-pyorbbecksdk/dora_pyorbbecksdk/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + # ****************************************************************************** # Copyright (c) 2023 Orbbec 3D Technology, Inc # @@ -40,11 +42,15 @@ except ImportError as err: class TemporalFilter: + """TODO: Add docstring.""" + def __init__(self, alpha): + """TODO: Add docstring.""" self.alpha = alpha self.previous_frame = None def process(self, frame): + """TODO: Add docstring.""" if self.previous_frame is None: result = frame else: @@ -56,18 +62,21 @@ class TemporalFilter: def yuyv_to_bgr(frame: np.ndarray, width: int, height: int) -> np.ndarray: + """TODO: Add docstring.""" yuyv = frame.reshape((height, width, 2)) bgr_image = cv2.cvtColor(yuyv, cv2.COLOR_YUV2BGR_YUY2) return bgr_image def uyvy_to_bgr(frame: np.ndarray, width: int, height: int) -> np.ndarray: + """TODO: Add docstring.""" uyvy = frame.reshape((height, width, 2)) bgr_image = cv2.cvtColor(uyvy, cv2.COLOR_YUV2BGR_UYVY) return bgr_image def i420_to_bgr(frame: np.ndarray, width: int, height: int) -> np.ndarray: + """TODO: Add docstring.""" y = frame[0:height, :] u = frame[height : height + height // 4].reshape(height // 2, width // 2) v = frame[height + height // 4 :].reshape(height // 2, width // 2) @@ -77,6 +86,7 @@ def i420_to_bgr(frame: np.ndarray, width: int, height: int) -> np.ndarray: def nv21_to_bgr(frame: np.ndarray, width: int, height: int) -> np.ndarray: + """TODO: Add docstring.""" y = frame[0:height, :] uv = frame[height : height + height // 2].reshape(height // 2, width) yuv_image = cv2.merge([y, uv]) @@ -85,6 +95,7 @@ def nv21_to_bgr(frame: np.ndarray, width: int, height: int) -> np.ndarray: def nv12_to_bgr(frame: np.ndarray, width: int, height: int) -> np.ndarray: + """TODO: Add docstring.""" y = frame[0:height, :] uv = frame[height : height + height // 2].reshape(height // 2, width) yuv_image = cv2.merge([y, uv]) @@ -93,6 +104,7 @@ def nv12_to_bgr(frame: np.ndarray, width: int, height: int) -> np.ndarray: def frame_to_bgr_image(frame: VideoFrame): + """TODO: Add docstring.""" width = frame.get_width() height = frame.get_height() color_format = frame.get_format() @@ -135,6 +147,7 @@ DEVICE_INDEX = int(os.getenv("DEVICE_INDEX", "0")) def main(): + """TODO: Add docstring.""" node = Node() config = Config() ctx = Context() diff --git a/node-hub/dora-pyorbbecksdk/tests/test_pyorbbecksdk.py b/node-hub/dora-pyorbbecksdk/tests/test_pyorbbecksdk.py index b00916cc..760ed683 100644 --- a/node-hub/dora-pyorbbecksdk/tests/test_pyorbbecksdk.py +++ b/node-hub/dora-pyorbbecksdk/tests/test_pyorbbecksdk.py @@ -1,4 +1,7 @@ +"""TODO: Add docstring.""" + def test_import_main(): + """TODO: Add docstring.""" return # Remove this if you want to test pyorbbecksdk installation # import pyorbbecksdk diff --git a/node-hub/dora-pyrealsense/dora_pyrealsense/__init__.py b/node-hub/dora-pyrealsense/dora_pyrealsense/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-pyrealsense/dora_pyrealsense/__init__.py +++ b/node-hub/dora-pyrealsense/dora_pyrealsense/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-pyrealsense/dora_pyrealsense/main.py b/node-hub/dora-pyrealsense/dora_pyrealsense/main.py index 04365e04..94a48d6a 100644 --- a/node-hub/dora-pyrealsense/dora_pyrealsense/main.py +++ b/node-hub/dora-pyrealsense/dora_pyrealsense/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import time @@ -11,6 +13,7 @@ RUNNER_CI = True if os.getenv("CI") == "true" else False def main(): + """TODO: Add docstring.""" FLIP = os.getenv("FLIP", "") DEVICE_SERIAL = os.getenv("DEVICE_SERIAL", "") image_height = int(os.getenv("IMAGE_HEIGHT", "480")) diff --git a/node-hub/dora-pyrealsense/tests/test_dora_pyrealsense.py b/node-hub/dora-pyrealsense/tests/test_dora_pyrealsense.py index b2531db1..d2e30241 100644 --- a/node-hub/dora-pyrealsense/tests/test_dora_pyrealsense.py +++ b/node-hub/dora-pyrealsense/tests/test_dora_pyrealsense.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from dora_pyrealsense.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/dora-qwen/dora_qwen/__init__.py b/node-hub/dora-qwen/dora_qwen/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-qwen/dora_qwen/__init__.py +++ b/node-hub/dora-qwen/dora_qwen/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-qwen/dora_qwen/__main__.py b/node-hub/dora-qwen/dora_qwen/__main__.py index 40e2b013..51a1554d 100644 --- a/node-hub/dora-qwen/dora_qwen/__main__.py +++ b/node-hub/dora-qwen/dora_qwen/__main__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + from .main import main if __name__ == "__main__": diff --git a/node-hub/dora-qwen/dora_qwen/main.py b/node-hub/dora-qwen/dora_qwen/main.py index 812462ef..348666df 100644 --- a/node-hub/dora-qwen/dora_qwen/main.py +++ b/node-hub/dora-qwen/dora_qwen/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import sys @@ -12,6 +14,7 @@ SYSTEM_PROMPT = os.getenv( def get_model_gguf(): + """TODO: Add docstring.""" from llama_cpp import Llama llm = Llama.from_pretrained( @@ -21,6 +24,7 @@ def get_model_gguf(): def get_model_darwin(): + """TODO: Add docstring.""" from mlx_lm import load model, tokenizer = load("mlx-community/Qwen2.5-0.5B-Instruct-8bit") @@ -28,6 +32,7 @@ def get_model_darwin(): def get_model_huggingface(): + """TODO: Add docstring.""" model_name = "Qwen/Qwen2.5-0.5B-Instruct" model = AutoModelForCausalLM.from_pretrained( @@ -41,6 +46,7 @@ ACTIVATION_WORDS = os.getenv("ACTIVATION_WORDS", "what how who where you").split def generate_hf(model, tokenizer, prompt: str, history) -> str: + """TODO: Add docstring.""" history += [{"role": "user", "content": prompt}] text = tokenizer.apply_chat_template( history, tokenize=False, add_generation_prompt=True, @@ -57,6 +63,7 @@ def generate_hf(model, tokenizer, prompt: str, history) -> str: def main(): + """TODO: Add docstring.""" history = [] # If OS is not Darwin, use Huggingface model if sys.platform != "": diff --git a/node-hub/dora-qwen/tests/test_dora_qwen.py b/node-hub/dora-qwen/tests/test_dora_qwen.py index da87ebb9..87b2182a 100644 --- a/node-hub/dora-qwen/tests/test_dora_qwen.py +++ b/node-hub/dora-qwen/tests/test_dora_qwen.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from dora_qwen.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/dora-qwen2-5-vl/dora_qwen2_5_vl/__init__.py b/node-hub/dora-qwen2-5-vl/dora_qwen2_5_vl/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-qwen2-5-vl/dora_qwen2_5_vl/__init__.py +++ b/node-hub/dora-qwen2-5-vl/dora_qwen2_5_vl/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-qwen2-5-vl/dora_qwen2_5_vl/main.py b/node-hub/dora-qwen2-5-vl/dora_qwen2_5_vl/main.py index 499e434f..12c2e083 100644 --- a/node-hub/dora-qwen2-5-vl/dora_qwen2_5_vl/main.py +++ b/node-hub/dora-qwen2-5-vl/dora_qwen2_5_vl/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os from pathlib import Path @@ -135,6 +137,7 @@ def generate(frames: dict, question, history, past_key_values=None, image_id=Non def main(): + """TODO: Add docstring.""" pa.array([]) # initialize pyarrow array node = Node() diff --git a/node-hub/dora-qwen2-5-vl/tests/test_dora_qwenvl.py b/node-hub/dora-qwen2-5-vl/tests/test_dora_qwenvl.py index e5d61dab..f9d60343 100644 --- a/node-hub/dora-qwen2-5-vl/tests/test_dora_qwenvl.py +++ b/node-hub/dora-qwen2-5-vl/tests/test_dora_qwenvl.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from dora_qwen2_5_vl.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/dora-qwenvl/dora_qwenvl/__init__.py b/node-hub/dora-qwenvl/dora_qwenvl/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-qwenvl/dora_qwenvl/__init__.py +++ b/node-hub/dora-qwenvl/dora_qwenvl/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-qwenvl/dora_qwenvl/main.py b/node-hub/dora-qwenvl/dora_qwenvl/main.py index 1bee60db..537e6133 100644 --- a/node-hub/dora-qwenvl/dora_qwenvl/main.py +++ b/node-hub/dora-qwenvl/dora_qwenvl/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os from pathlib import Path @@ -106,6 +108,7 @@ def generate(frames: dict, question): def main(): + """TODO: Add docstring.""" pa.array([]) # initialize pyarrow array node = Node() diff --git a/node-hub/dora-qwenvl/tests/test_dora_qwenvl.py b/node-hub/dora-qwenvl/tests/test_dora_qwenvl.py index 4105676f..74e912ed 100644 --- a/node-hub/dora-qwenvl/tests/test_dora_qwenvl.py +++ b/node-hub/dora-qwenvl/tests/test_dora_qwenvl.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from dora_qwenvl.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/dora-rdt-1b/dora_rdt_1b/__init__.py b/node-hub/dora-rdt-1b/dora_rdt_1b/__init__.py index 177dc7e4..e98e6121 100644 --- a/node-hub/dora-rdt-1b/dora_rdt_1b/__init__.py +++ b/node-hub/dora-rdt-1b/dora_rdt_1b/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import sys from pathlib import Path diff --git a/node-hub/dora-rdt-1b/dora_rdt_1b/main.py b/node-hub/dora-rdt-1b/dora_rdt_1b/main.py index 7cd1426d..c155b2a3 100644 --- a/node-hub/dora-rdt-1b/dora_rdt_1b/main.py +++ b/node-hub/dora-rdt-1b/dora_rdt_1b/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + # install dependencies as shown in the README here https://github.com/alik-git/RoboticsDiffusionTransformer?tab=readme-ov-file#installation import os from pathlib import Path @@ -39,6 +41,7 @@ with open(config_path, encoding="utf-8") as fp: def get_policy(): + """TODO: Add docstring.""" from dora_rdt_1b.RoboticsDiffusionTransformer.models.rdt_runner import RDTRunner pretrained_model_name_or_path = ROBOTIC_MODEL_NAME_OR_PATH @@ -51,6 +54,7 @@ def get_policy(): def get_vision_model(): + """TODO: Add docstring.""" from dora_rdt_1b.RoboticsDiffusionTransformer.models.multimodal_encoder.siglip_encoder import ( SiglipVisionTower, ) @@ -67,6 +71,7 @@ def get_vision_model(): def get_language_embeddings(): + """TODO: Add docstring.""" device = torch.device("cuda:0") lang_embeddings = torch.load( @@ -80,6 +85,7 @@ def get_language_embeddings(): def expand2square(pil_img, background_color): + """TODO: Add docstring.""" width, height = pil_img.size if width == height: return pil_img @@ -111,7 +117,7 @@ def process_image(rgbs_lst, image_processor, vision_encoder): # image pre-processing # The background image used for padding - + """TODO: Add docstring.""" image_tensor_list = [] for step in range(config["common"]["img_history_size"]): rgbs = rgbs_lst[step] @@ -137,6 +143,7 @@ def process_image(rgbs_lst, image_processor, vision_encoder): def get_states(proprio): # suppose you control in 7DOF joint position + """TODO: Add docstring.""" STATE_INDICES = [ STATE_VEC_IDX_MAPPING["left_arm_joint_0_pos"], STATE_VEC_IDX_MAPPING["left_arm_joint_1_pos"], @@ -183,6 +190,7 @@ def get_states(proprio): def main(): + """TODO: Add docstring.""" rdt = get_policy() lang_embeddings = get_language_embeddings() vision_encoder, image_processor = get_vision_model() diff --git a/node-hub/dora-rdt-1b/tests/conftest.py b/node-hub/dora-rdt-1b/tests/conftest.py index 46712c46..76b6efe9 100644 --- a/node-hub/dora-rdt-1b/tests/conftest.py +++ b/node-hub/dora-rdt-1b/tests/conftest.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def pytest_configure(): + """TODO: Add docstring.""" pytest.rdt = None pytest.lang_embeddings = None pytest.image_processor = None diff --git a/node-hub/dora-rdt-1b/tests/test_dora_rdt_1b.py b/node-hub/dora-rdt-1b/tests/test_dora_rdt_1b.py index f10bbc35..2d05087a 100644 --- a/node-hub/dora-rdt-1b/tests/test_dora_rdt_1b.py +++ b/node-hub/dora-rdt-1b/tests/test_dora_rdt_1b.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import numpy as np @@ -20,11 +22,13 @@ def test_import_main(): # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. # with pytest.raises(RuntimeError): # main() + """TODO: Add docstring.""" import dora_rdt_1b.RoboticsDiffusionTransformer as _ # noqa import dora_rdt_1b as _ # noqa def test_download_policy(): + """TODO: Add docstring.""" from dora_rdt_1b.main import get_policy ## in the future we should add this test within CI @@ -38,6 +42,7 @@ def test_download_policy(): def test_download_vision_model(): # Skip vision test as it is currently failing on macOS # See: https://github.com/dora-rs/dora/actions/runs/13484462433/job/37673857429 + """TODO: Add docstring.""" from dora_rdt_1b.main import get_vision_model (vision_encoder, image_processor) = get_vision_model() @@ -47,6 +52,7 @@ def test_download_vision_model(): def test_download_language_embeddings(): ## in the future we should add this test within CI + """TODO: Add docstring.""" if CI: return @@ -56,6 +62,7 @@ def test_download_language_embeddings(): def test_load_dummy_image(): + """TODO: Add docstring.""" from dora_rdt_1b.main import config # Load pretrained model (in HF style) @@ -117,6 +124,7 @@ def test_load_dummy_image(): if config["dataset"].get("image_aspect_ratio", "pad") == "pad": def expand2square(pil_img, background_color): + """TODO: Add docstring.""" width, height = pil_img.size if width == height: return pil_img @@ -155,6 +163,7 @@ def test_load_dummy_image(): def test_dummy_states(): + """TODO: Add docstring.""" from dora_rdt_1b.main import config ## in the future we should add this test within CI @@ -209,6 +218,7 @@ def test_dummy_states(): def test_dummy_input(): ## in the future we should add this test within CI + """TODO: Add docstring.""" if CI: return diff --git a/node-hub/dora-reachy2/dora_reachy2/__init__.py b/node-hub/dora-reachy2/dora_reachy2/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-reachy2/dora_reachy2/__init__.py +++ b/node-hub/dora-reachy2/dora_reachy2/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-reachy2/dora_reachy2/camera.py b/node-hub/dora-reachy2/dora_reachy2/camera.py index 9c29f918..b2e11d81 100644 --- a/node-hub/dora-reachy2/dora_reachy2/camera.py +++ b/node-hub/dora-reachy2/dora_reachy2/camera.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import numpy as np @@ -8,6 +10,7 @@ from reachy2_sdk.media.camera import CameraView def main(): + """TODO: Add docstring.""" ROBOT_IP = os.getenv("ROBOT_IP", "10.42.0.80") for _ in range(10): diff --git a/node-hub/dora-reachy2/dora_reachy2/head.py b/node-hub/dora-reachy2/dora_reachy2/head.py index c1eec1aa..91bff8f0 100644 --- a/node-hub/dora-reachy2/dora_reachy2/head.py +++ b/node-hub/dora-reachy2/dora_reachy2/head.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import numpy as np @@ -6,6 +8,7 @@ from reachy2_sdk import ReachySDK def main(): + """TODO: Add docstring.""" ROBOT_IP = os.getenv("ROBOT_IP", "10.42.0.80") for _i in range(5): diff --git a/node-hub/dora-reachy2/dora_reachy2/left_arm.py b/node-hub/dora-reachy2/dora_reachy2/left_arm.py index 409e46df..f9b45c7f 100644 --- a/node-hub/dora-reachy2/dora_reachy2/left_arm.py +++ b/node-hub/dora-reachy2/dora_reachy2/left_arm.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import time @@ -22,6 +24,7 @@ l_default_pose = [ def l_arm_go_to_mixed_angles(reachy, x, y, z): + """TODO: Add docstring.""" for theta in range(-80, -60, 10): r = R.from_euler("zyx", [0, theta, 0], degrees=True) transform = np.eye(4) @@ -67,6 +70,7 @@ def l_arm_go_to_mixed_angles(reachy, x, y, z): def manage_gripper(reachy, gripper, grasp): + """TODO: Add docstring.""" if (gripper == 100 and reachy.r_arm.gripper.get_current_opening() == 100) or ( gripper == 0.0 and ( @@ -90,6 +94,7 @@ def manage_gripper(reachy, gripper, grasp): def main(): + """TODO: Add docstring.""" reachy = ReachySDK(ROBOT_IP) if reachy.l_arm is not None: diff --git a/node-hub/dora-reachy2/dora_reachy2/mobile_base.py b/node-hub/dora-reachy2/dora_reachy2/mobile_base.py index a3999cf5..ac52e920 100644 --- a/node-hub/dora-reachy2/dora_reachy2/mobile_base.py +++ b/node-hub/dora-reachy2/dora_reachy2/mobile_base.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import time @@ -8,6 +10,7 @@ from reachy2_sdk import ReachySDK def main(): + """TODO: Add docstring.""" ROBOT_IP = os.getenv("ROBOT_IP", "10.42.0.80") reachy = ReachySDK(ROBOT_IP) diff --git a/node-hub/dora-reachy2/dora_reachy2/right_arm.py b/node-hub/dora-reachy2/dora_reachy2/right_arm.py index ee5a3d45..e88a54c4 100644 --- a/node-hub/dora-reachy2/dora_reachy2/right_arm.py +++ b/node-hub/dora-reachy2/dora_reachy2/right_arm.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import time @@ -21,6 +23,7 @@ r_default_pose = [ def r_arm_go_to_mixed_angles(reachy, x, y, z): + """TODO: Add docstring.""" for theta in range(-80, -60, 10): r = R.from_euler("zyx", [0, theta, 0], degrees=True) transform = np.eye(4) @@ -66,6 +69,7 @@ def r_arm_go_to_mixed_angles(reachy, x, y, z): def manage_gripper(reachy, gripper, grasp): + """TODO: Add docstring.""" if (gripper == 100 and reachy.r_arm.gripper.get_current_opening() == 100) or ( gripper == 0.0 and ( @@ -89,6 +93,7 @@ def manage_gripper(reachy, gripper, grasp): def main(): + """TODO: Add docstring.""" reachy = ReachySDK(ROBOT_IP) if reachy.r_arm is not None: diff --git a/node-hub/dora-reachy2/tests/test_dora_reachy2.py b/node-hub/dora-reachy2/tests/test_dora_reachy2.py index 04251f8b..7a6d8fa4 100644 --- a/node-hub/dora-reachy2/tests/test_dora_reachy2.py +++ b/node-hub/dora-reachy2/tests/test_dora_reachy2.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + # import pytest def test_pass(): + """TODO: Add docstring.""" pass diff --git a/node-hub/dora-sam2/dora_sam2/__init__.py b/node-hub/dora-sam2/dora_sam2/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-sam2/dora_sam2/__init__.py +++ b/node-hub/dora-sam2/dora_sam2/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-sam2/dora_sam2/__main__.py b/node-hub/dora-sam2/dora_sam2/__main__.py index 40e2b013..51a1554d 100644 --- a/node-hub/dora-sam2/dora_sam2/__main__.py +++ b/node-hub/dora-sam2/dora_sam2/__main__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + from .main import main if __name__ == "__main__": diff --git a/node-hub/dora-sam2/dora_sam2/main.py b/node-hub/dora-sam2/dora_sam2/main.py index f3130ddf..d2612cac 100644 --- a/node-hub/dora-sam2/dora_sam2/main.py +++ b/node-hub/dora-sam2/dora_sam2/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import cv2 import numpy as np import pyarrow as pa @@ -10,6 +12,7 @@ predictor = SAM2ImagePredictor.from_pretrained("facebook/sam2-hiera-large") def main(): + """TODO: Add docstring.""" pa.array([]) # initialize pyarrow array node = Node() frames = {} diff --git a/node-hub/dora-sam2/tests/test_dora_sam2.py b/node-hub/dora-sam2/tests/test_dora_sam2.py index 18488293..4ed0b83e 100644 --- a/node-hub/dora-sam2/tests/test_dora_sam2.py +++ b/node-hub/dora-sam2/tests/test_dora_sam2.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import pytest @@ -6,6 +8,7 @@ CI = os.getenv("CI", "false") in ["True", "true"] def test_import_main(): + """TODO: Add docstring.""" if CI: # Skip test as test requires Nvidia GPU return diff --git a/node-hub/dora-ugv/dora_ugv/__init__.py b/node-hub/dora-ugv/dora_ugv/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-ugv/dora_ugv/__init__.py +++ b/node-hub/dora-ugv/dora_ugv/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-ugv/dora_ugv/main.py b/node-hub/dora-ugv/dora_ugv/main.py index 10662375..5d27be73 100644 --- a/node-hub/dora-ugv/dora_ugv/main.py +++ b/node-hub/dora-ugv/dora_ugv/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + try: import ugv_sdk_py from ugv_sdk_py import hunter_robot @@ -15,6 +17,7 @@ from dora import Node def main(): # Create an instance of HunterRobot + """TODO: Add docstring.""" robot = hunter_robot.HunterRobot(ugv_sdk_py.ProtocolVersion.AGX_V2) # Connect to the robot diff --git a/node-hub/dora-ugv/tests/test_ugv.py b/node-hub/dora-ugv/tests/test_ugv.py index a6768dac..f5c8ab51 100644 --- a/node-hub/dora-ugv/tests/test_ugv.py +++ b/node-hub/dora-ugv/tests/test_ugv.py @@ -1,4 +1,7 @@ +"""TODO: Add docstring.""" + def test_import_main(): + """TODO: Add docstring.""" return # Remove this if you want to test ugv_sdk_py installation # import ugv_sdk_py diff --git a/node-hub/dora-vad/dora_vad/__init__.py b/node-hub/dora-vad/dora_vad/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-vad/dora_vad/__init__.py +++ b/node-hub/dora-vad/dora_vad/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-vad/dora_vad/main.py b/node-hub/dora-vad/dora_vad/main.py index 05e14773..bafb290d 100644 --- a/node-hub/dora-vad/dora_vad/main.py +++ b/node-hub/dora-vad/dora_vad/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os import numpy as np @@ -15,6 +17,7 @@ MIN_AUDIO_SAMPLING_DURATION_MS = int(os.getenv("MIN_AUDIO_SAMPLING_DURATION_MS", def main(): + """TODO: Add docstring.""" node = Node() last_audios = [] while True: diff --git a/node-hub/dora-vad/tests/test_translate.py b/node-hub/dora-vad/tests/test_translate.py index ea9a0648..3fb2acde 100644 --- a/node-hub/dora-vad/tests/test_translate.py +++ b/node-hub/dora-vad/tests/test_translate.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from dora_vad.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/dora-yolo/dora_yolo/__init__.py b/node-hub/dora-yolo/dora_yolo/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/dora-yolo/dora_yolo/__init__.py +++ b/node-hub/dora-yolo/dora_yolo/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/dora-yolo/dora_yolo/main.py b/node-hub/dora-yolo/dora_yolo/main.py index fb22a273..b8e345df 100644 --- a/node-hub/dora-yolo/dora_yolo/main.py +++ b/node-hub/dora-yolo/dora_yolo/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import argparse import os @@ -9,6 +11,7 @@ from ultralytics import YOLO def main(): # Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables. + """TODO: Add docstring.""" parser = argparse.ArgumentParser( description="UltraLytics YOLO: This node is used to perform object detection using the UltraLytics YOLO model.", ) diff --git a/node-hub/dora-yolo/tests/test_ultralytics_yolo.py b/node-hub/dora-yolo/tests/test_ultralytics_yolo.py index fa917b2e..1f25dd3d 100644 --- a/node-hub/dora-yolo/tests/test_ultralytics_yolo.py +++ b/node-hub/dora-yolo/tests/test_ultralytics_yolo.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from dora_yolo.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/llama-factory-recorder/llama_factory_recorder/__init__.py b/node-hub/llama-factory-recorder/llama_factory_recorder/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/llama-factory-recorder/llama_factory_recorder/__init__.py +++ b/node-hub/llama-factory-recorder/llama_factory_recorder/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/llama-factory-recorder/llama_factory_recorder/main.py b/node-hub/llama-factory-recorder/llama_factory_recorder/main.py index 209e1378..9e241b8a 100644 --- a/node-hub/llama-factory-recorder/llama_factory_recorder/main.py +++ b/node-hub/llama-factory-recorder/llama_factory_recorder/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import json import os from pathlib import Path @@ -15,8 +17,9 @@ DEFAULT_QUESTION = os.getenv( def write_dict_to_json(file_path, key: str, new_data): - """Writes a dictionary to a JSON file. If the file already contains a list of entries, - the new data will be appended to that list. Otherwise, it will create a new list. + """Write a dictionary to a JSON file. + + If the file already contains a list of entries,the new data will be appended to that list. Otherwise, it will create a new list. Parameters ---------- @@ -47,16 +50,23 @@ def write_dict_to_json(file_path, key: str, new_data): def save_image_and_add_to_json( frame_dict: dict, root_path, llama_root_path, jsonl_file, messages, ): - """Saves an image from a NumPy array and adds a new JSON object as a line to a JSONL file. + """Save an image from a NumPy array and add a new JSON object as a line to a JSONL file. + The function generates a sequential numeric image filename starting from 0 and follows the provided template structure. Parameters ---------- - - image_array: numpy.ndarray, the image data as a NumPy array. - - root_path: str, the root directory where the image will be saved. - - jsonl_file: str, the path to the JSONL file. - - messages: list of dicts, each containing 'content' and 'role'. + frame_dict : dict + Dictionary containing the image data as a numpy.ndarray. + root_path : str + The root directory where the image will be saved. + llama_root_path : str + TODO + jsonl_file : str + The path to the JSONL file. + messages : list of dict + List of dictionaries, each containing 'content' and 'role'. The image is saved as a PNG file, and the JSONL entry includes the 'messages' and 'images' keys. @@ -93,6 +103,7 @@ def save_image_and_add_to_json( def main(): + """TODO: Add docstring.""" pa.array([]) # initialize pyarrow array node = Node() diff --git a/node-hub/llama-factory-recorder/tests/test_llama_factory_recorder.py b/node-hub/llama-factory-recorder/tests/test_llama_factory_recorder.py index 34dee34c..70cdff6a 100644 --- a/node-hub/llama-factory-recorder/tests/test_llama_factory_recorder.py +++ b/node-hub/llama-factory-recorder/tests/test_llama_factory_recorder.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from llama_factory_recorder.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/opencv-plot/opencv_plot/__init__.py b/node-hub/opencv-plot/opencv_plot/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/opencv-plot/opencv_plot/__init__.py +++ b/node-hub/opencv-plot/opencv_plot/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/opencv-plot/opencv_plot/main.py b/node-hub/opencv-plot/opencv_plot/main.py index 1915f2b2..a7007d42 100644 --- a/node-hub/opencv-plot/opencv_plot/main.py +++ b/node-hub/opencv-plot/opencv_plot/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import argparse import os @@ -10,6 +12,8 @@ RUNNER_CI = True if os.getenv("CI") == "true" else False class Plot: + """TODO: Add docstring.""" + frame: np.array = np.array([]) bboxes: dict = { @@ -25,6 +29,7 @@ class Plot: def plot_frame(plot): + """TODO: Add docstring.""" for bbox in zip(plot.bboxes["bbox"], plot.bboxes["conf"], plot.bboxes["labels"]): [ [min_x, min_y, max_x, max_y], @@ -70,12 +75,14 @@ def plot_frame(plot): def yuv420p_to_bgr_opencv(yuv_array, width, height): + """TODO: Add docstring.""" yuv = yuv_array.reshape((height * 3 // 2, width)) return cv2.cvtColor(yuv, cv2.COLOR_YUV420p2RGB) def main(): # Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables. + """TODO: Add docstring.""" parser = argparse.ArgumentParser( description="OpenCV Plotter: This node is used to plot text and bounding boxes on an image.", ) diff --git a/node-hub/opencv-plot/tests/test_opencv_plot.py b/node-hub/opencv-plot/tests/test_opencv_plot.py index 002899d2..817b123a 100644 --- a/node-hub/opencv-plot/tests/test_opencv_plot.py +++ b/node-hub/opencv-plot/tests/test_opencv_plot.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from opencv_plot.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/opencv-video-capture/opencv_video_capture/__init__.py b/node-hub/opencv-video-capture/opencv_video_capture/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/opencv-video-capture/opencv_video_capture/__init__.py +++ b/node-hub/opencv-video-capture/opencv_video_capture/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/opencv-video-capture/opencv_video_capture/main.py b/node-hub/opencv-video-capture/opencv_video_capture/main.py index 6b52ff09..abfc08d1 100644 --- a/node-hub/opencv-video-capture/opencv_video_capture/main.py +++ b/node-hub/opencv-video-capture/opencv_video_capture/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import argparse import os import time @@ -14,6 +16,7 @@ FLIP = os.getenv("FLIP", "") def main(): # Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables. + """TODO: Add docstring.""" parser = argparse.ArgumentParser( description="OpenCV Video Capture: This node is used to capture video from a camera.", ) diff --git a/node-hub/opencv-video-capture/tests/test_opencv_video_capture.py b/node-hub/opencv-video-capture/tests/test_opencv_video_capture.py index bed0ab79..5ba96e8c 100644 --- a/node-hub/opencv-video-capture/tests/test_opencv_video_capture.py +++ b/node-hub/opencv-video-capture/tests/test_opencv_video_capture.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from opencv_video_capture.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/pyarrow-assert/pyarrow_assert/__init__.py b/node-hub/pyarrow-assert/pyarrow_assert/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/pyarrow-assert/pyarrow_assert/__init__.py +++ b/node-hub/pyarrow-assert/pyarrow_assert/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/pyarrow-assert/pyarrow_assert/main.py b/node-hub/pyarrow-assert/pyarrow_assert/main.py index 065347ac..1dd047fc 100644 --- a/node-hub/pyarrow-assert/pyarrow_assert/main.py +++ b/node-hub/pyarrow-assert/pyarrow_assert/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import argparse import ast import os @@ -10,6 +12,7 @@ RUNNER_CI = True if os.getenv("CI") == "true" else False def main(): # Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables. + """TODO: Add docstring.""" parser = argparse.ArgumentParser(description="Simple arrow sender") parser.add_argument( diff --git a/node-hub/pyarrow-assert/tests/test_pyarrow_assert.py b/node-hub/pyarrow-assert/tests/test_pyarrow_assert.py index a54230d6..dc1b395f 100644 --- a/node-hub/pyarrow-assert/tests/test_pyarrow_assert.py +++ b/node-hub/pyarrow-assert/tests/test_pyarrow_assert.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from pyarrow_assert.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/pyarrow-sender/pyarrow_sender/__init__.py b/node-hub/pyarrow-sender/pyarrow_sender/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/pyarrow-sender/pyarrow_sender/__init__.py +++ b/node-hub/pyarrow-sender/pyarrow_sender/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/pyarrow-sender/pyarrow_sender/main.py b/node-hub/pyarrow-sender/pyarrow_sender/main.py index 3ec0ce4c..68ce3a92 100644 --- a/node-hub/pyarrow-sender/pyarrow_sender/main.py +++ b/node-hub/pyarrow-sender/pyarrow_sender/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import argparse import ast import os @@ -10,6 +12,7 @@ RUNNER_CI = True if os.getenv("CI") == "true" else False def main(): # Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables. + """TODO: Add docstring.""" parser = argparse.ArgumentParser(description="Simple arrow sender") parser.add_argument( diff --git a/node-hub/pyarrow-sender/tests/test_pyarrow_sender.py b/node-hub/pyarrow-sender/tests/test_pyarrow_sender.py index c97dc751..bfc7e292 100644 --- a/node-hub/pyarrow-sender/tests/test_pyarrow_sender.py +++ b/node-hub/pyarrow-sender/tests/test_pyarrow_sender.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from pyarrow_sender.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/node-hub/terminal-input/terminal_input/__init__.py b/node-hub/terminal-input/terminal_input/__init__.py index cde7a377..79cbf370 100644 --- a/node-hub/terminal-input/terminal_input/__init__.py +++ b/node-hub/terminal-input/terminal_input/__init__.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import os # Define the path to the README file relative to the package directory diff --git a/node-hub/terminal-input/terminal_input/main.py b/node-hub/terminal-input/terminal_input/main.py index 254f0d5f..86c305b5 100644 --- a/node-hub/terminal-input/terminal_input/main.py +++ b/node-hub/terminal-input/terminal_input/main.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import argparse import ast import os @@ -11,6 +13,7 @@ RUNNER_CI = True if os.getenv("CI") == "true" else False def main(): # Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables. + """TODO: Add docstring.""" parser = argparse.ArgumentParser(description="Simple arrow sender") parser.add_argument( diff --git a/node-hub/terminal-input/tests/test_terminal_input.py b/node-hub/terminal-input/tests/test_terminal_input.py index 2b5024a3..f2913c0e 100644 --- a/node-hub/terminal-input/tests/test_terminal_input.py +++ b/node-hub/terminal-input/tests/test_terminal_input.py @@ -1,7 +1,10 @@ +"""TODO: Add docstring.""" + import pytest def test_import_main(): + """TODO: Add docstring.""" from terminal_input.main import main # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. diff --git a/tests/queue_size_and_timeout_python/receive_data.py b/tests/queue_size_and_timeout_python/receive_data.py index f5cdd271..6be2216d 100644 --- a/tests/queue_size_and_timeout_python/receive_data.py +++ b/tests/queue_size_and_timeout_python/receive_data.py @@ -1,9 +1,12 @@ +"""TODO: Add docstring.""" + import time from dora import Node def main() -> None: + """TODO: Add docstring.""" dora_node = Node() i = 0 diff --git a/tests/queue_size_and_timeout_python/send_data.py b/tests/queue_size_and_timeout_python/send_data.py index a29e1abb..861b3aa1 100644 --- a/tests/queue_size_and_timeout_python/send_data.py +++ b/tests/queue_size_and_timeout_python/send_data.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import time import pyarrow as pa @@ -7,6 +9,7 @@ start = time.time() def main() -> None: + """TODO: Add docstring.""" dora_node = Node() i = 0 while time.time() - start < 10: diff --git a/tests/queue_size_latest_data_python/receive_data.py b/tests/queue_size_latest_data_python/receive_data.py index ef46580f..56aa73d4 100644 --- a/tests/queue_size_latest_data_python/receive_data.py +++ b/tests/queue_size_latest_data_python/receive_data.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import time from dora import Node diff --git a/tests/queue_size_latest_data_python/send_data.py b/tests/queue_size_latest_data_python/send_data.py index 140e3184..2541c6e3 100644 --- a/tests/queue_size_latest_data_python/send_data.py +++ b/tests/queue_size_latest_data_python/send_data.py @@ -1,3 +1,5 @@ +"""TODO: Add docstring.""" + import time import numpy as np