diff --git a/.github/workflows/node-hub-ci-cd.yml b/.github/workflows/node-hub-ci-cd.yml index eee7ed1e7..2bdf87f27 100644 --- a/.github/workflows/node-hub-ci-cd.yml +++ b/.github/workflows/node-hub-ci-cd.yml @@ -18,12 +18,34 @@ jobs: outputs: folders: ${{ steps.jobs.outputs.folders }} steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - id: jobs uses: kmanimaran/list-folder-action@v4 with: path: ./node-hub + + lint: + runs-on: ubuntu-24.04 + needs: [find-jobs] + name: Lint + strategy: + fail-fast: ${{ github.event_name != 'workflow_dispatch' && !(github.event_name == 'release' && startsWith(github.ref, 'refs/tags/')) }} + matrix: + folder: ${{ fromJson(needs.find-jobs.outputs.folders )}} + steps: + - uses: actions/checkout@v4 + + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v5 + with: + enable-cache: true + + - name: Run linting + working-directory: node-hub/${{ matrix.folder }} + run: | + uv tool install ruff + ruff check . ci: runs-on: ${{ matrix.platform }} diff --git a/benches/mllm/benchmark_script.py b/benches/mllm/benchmark_script.py index 6ac4c48b9..6c39fbafb 100644 --- a/benches/mllm/benchmark_script.py +++ b/benches/mllm/benchmark_script.py @@ -98,7 +98,8 @@ def write_to_csv(filename, header, row): def main(): - # Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables. + # 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") diff --git a/node-hub/dora-argotranslate/dora_argotranslate/main.py b/node-hub/dora-argotranslate/dora_argotranslate/main.py index 2bab22ee7..0c1359e20 100644 --- a/node-hub/dora-argotranslate/dora_argotranslate/main.py +++ b/node-hub/dora-argotranslate/dora_argotranslate/main.py @@ -17,7 +17,8 @@ available_packages = argostranslate.package.get_available_packages() package_to_install = next( filter( - lambda x: x.from_code == from_code and x.to_code == to_code, available_packages, + lambda x: x.from_code == from_code and x.to_code == to_code, + available_packages, ), ) argostranslate.package.install_from_path(package_to_install.download()) diff --git a/node-hub/dora-argotranslate/pyproject.toml b/node-hub/dora-argotranslate/pyproject.toml index a440d5677..70440bfc9 100644 --- a/node-hub/dora-argotranslate/pyproject.toml +++ b/node-hub/dora-argotranslate/pyproject.toml @@ -29,4 +29,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-argotranslate/tests/test_translate.py b/node-hub/dora-argotranslate/tests/test_translate.py index da3ee0447..f9bed5650 100644 --- a/node-hub/dora-argotranslate/tests/test_translate.py +++ b/node-hub/dora-argotranslate/tests/test_translate.py @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-cotracker/tests/test_dora_cotracker.py b/node-hub/dora-cotracker/tests/test_dora_cotracker.py index 50d8eb836..0493d4820 100644 --- a/node-hub/dora-cotracker/tests/test_dora_cotracker.py +++ b/node-hub/dora-cotracker/tests/test_dora_cotracker.py @@ -4,6 +4,7 @@ def test_import_main(): from dora_cotracker.main import main - # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-dav1d/pyproject.toml b/node-hub/dora-dav1d/pyproject.toml index aa869035b..c45f191f8 100644 --- a/node-hub/dora-dav1d/pyproject.toml +++ b/node-hub/dora-dav1d/pyproject.toml @@ -23,4 +23,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] 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 007b3b43d..f3d953e6c 100644 --- a/node-hub/dora-distil-whisper/dora_distil_whisper/main.py +++ b/node-hub/dora-distil-whisper/dora_distil_whisper/main.py @@ -32,9 +32,11 @@ def remove_text_noise(text: str, text_noise="") -> str: text # Return the original text if text_noise is empty or just whitespace ) - # Helper function to normalize text (remove punctuation, make lowercase, and handle hyphens) + # Helper function to normalize text (remove punctuation, make lowercase, and handle + # hyphens) def normalize(s): - # Replace hyphens with spaces to treat "Notre-Dame" and "notre dame" as equivalent + # Replace hyphens with spaces to treat "Notre-Dame" and "notre dame" as + # equivalent s = re.sub(r"-", " ", s) # Remove other punctuation and convert to lowercase return re.sub(r"[^\w\s]", "", s).lower() @@ -236,5 +238,7 @@ def main(): if text.strip() == "" or text.strip() == ".": continue node.send_output( - "text", pa.array([text]), {"language": TARGET_LANGUAGE}, + "text", + pa.array([text]), + {"language": TARGET_LANGUAGE}, ) diff --git a/node-hub/dora-distil-whisper/pyproject.toml b/node-hub/dora-distil-whisper/pyproject.toml index 64e893dfc..59aa4a55f 100644 --- a/node-hub/dora-distil-whisper/pyproject.toml +++ b/node-hub/dora-distil-whisper/pyproject.toml @@ -37,4 +37,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] 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 0c5ada0a4..976d8e275 100644 --- a/node-hub/dora-distil-whisper/tests/test_distil_whisper.py +++ b/node-hub/dora-distil-whisper/tests/test_distil_whisper.py @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-echo/dora_echo/main.py b/node-hub/dora-echo/dora_echo/main.py index 6558d69ec..cc6b0f545 100644 --- a/node-hub/dora-echo/dora_echo/main.py +++ b/node-hub/dora-echo/dora_echo/main.py @@ -9,7 +9,8 @@ def main(): - # Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables. + # 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") diff --git a/node-hub/dora-echo/pyproject.toml b/node-hub/dora-echo/pyproject.toml index 8db2e2857..b822588d2 100644 --- a/node-hub/dora-echo/pyproject.toml +++ b/node-hub/dora-echo/pyproject.toml @@ -28,4 +28,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-echo/tests/test_dora_echo.py b/node-hub/dora-echo/tests/test_dora_echo.py index 6c1aa3548..655d32e94 100644 --- a/node-hub/dora-echo/tests/test_dora_echo.py +++ b/node-hub/dora-echo/tests/test_dora_echo.py @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-gradio/dora_gradio/main.py b/node-hub/dora-gradio/dora_gradio/main.py index bd3d142ed..305c70114 100644 --- a/node-hub/dora-gradio/dora_gradio/main.py +++ b/node-hub/dora-gradio/dora_gradio/main.py @@ -13,6 +13,7 @@ logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) + class DoraGradioUI: def __init__(self): self.node = Node() @@ -33,28 +34,32 @@ def handle_audio_stream(self, stream, new_chunk, text_state): if new_chunk is not None: try: sr, y = new_chunk - + # Convert to mono and normalize like microphone node if y.ndim > 1: y = y[:, 0] y = y.astype(np.float32) if np.abs(y).max() > 1.0: y = y / 32768.0 # For int16 input - + # Resample to 16kHz if needed if sr != self.sample_rate: y = librosa.resample(y, orig_sr=sr, target_sr=self.sample_rate) - + self.buffer.extend(y) current_time = time.time() if current_time - self.start_recording_time > self.max_duration: audio_data = np.array(self.buffer, dtype=np.float32).ravel() audio_data = np.clip(audio_data, -1.0, 1.0) - self.node.send_output("audio", pa.array(audio_data), { - "sample_rate": self.sample_rate, - "channels": 1, - "timestamp": int(time.time() * 1_000_000_000) - }) + self.node.send_output( + "audio", + pa.array(audio_data), + { + "sample_rate": self.sample_rate, + "channels": 1, + "timestamp": int(time.time() * 1_000_000_000), + }, + ) self.buffer = [] self.start_recording_time = current_time return stream, "", "✓ Streaming audio..." @@ -71,20 +76,24 @@ def handle_video_stream(self, frame): if frame.shape[1] != 640 or frame.shape[0] != 480: frame = cv2.resize(frame, (640, 480)) timestamp = int(time.time() * 1_000_000_000) - self.node.send_output("image", pa.array(frame.ravel()), { - "encoding": "bgr8", - "width": frame.shape[1], - "height": frame.shape[0], - "timestamp": timestamp, - "_time": timestamp - }) - + self.node.send_output( + "image", + pa.array(frame.ravel()), + { + "encoding": "bgr8", + "width": frame.shape[1], + "height": frame.shape[0], + "timestamp": timestamp, + "_time": timestamp, + }, + ) + return frame except Exception as e: logger.error(f"Error in video stream: {e}") return np.zeros((480, 640, 3), dtype=np.uint8) return None - + def create_interface(self): with gr.Blocks(theme=self.theme, title="Dora Input Interface") as interface: gr.Markdown("## Dora Input Interface") @@ -95,10 +104,8 @@ def create_interface(self): modality="video", mode="send-receive", rtc_configuration={ - "iceServers": [ - {"urls": ["stun:stun.l.google.com:19302"]} - ] - } + "iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}] + }, ) with gr.Tab("Audio and Text Input"): with gr.Group(): @@ -106,8 +113,8 @@ def create_interface(self): audio_state = gr.State(None) text_state = gr.State("") audio_input = gr.Audio( - sources=["microphone"], - streaming=True, + sources=["microphone"], + streaming=True, type="numpy", ) audio_status = gr.Markdown("Status: Ready") @@ -117,9 +124,9 @@ def create_interface(self): chatbot = gr.Chatbot(show_label=False, height=200) with gr.Row(): text_input = gr.Textbox( - placeholder="Type your message here...", + placeholder="Type your message here...", show_label=False, - scale=4 + scale=4, ) text_send = gr.Button("Send Text", scale=1) @@ -127,9 +134,17 @@ def create_interface(self): stop_button = gr.Button("Stop Server", variant="stop", scale=0.5) # Event handlers - text_input.submit(self.handle_text_input, [text_input, chatbot], [text_input, chatbot]) - text_send.click(self.handle_text_input, [text_input, chatbot], [text_input, chatbot]) - audio_input.stream(self.handle_audio_stream, [audio_state, audio_input, text_state], [audio_state, text_state, audio_status]) + text_input.submit( + self.handle_text_input, [text_input, chatbot], [text_input, chatbot] + ) + text_send.click( + self.handle_text_input, [text_input, chatbot], [text_input, chatbot] + ) + audio_input.stream( + self.handle_audio_stream, + [audio_state, audio_input, text_state], + [audio_state, text_state, audio_status], + ) stop_button.click(self.kill_server) return interface @@ -140,11 +155,11 @@ def launch(self): # import subprocess # subprocess.run('lsof -ti :7860 | xargs kill -9', shell=True, stderr=subprocess.DEVNULL) interface = self.create_interface() - + def cleanup(signum, frame): interface.close() os._exit(0) - + signal.signal(signal.SIGINT, cleanup) signal.signal(signal.SIGTERM, cleanup) interface.launch(server_name="0.0.0.0", server_port=7860, quiet=False) @@ -158,9 +173,11 @@ def kill_server(self): logger.info("Manually stopping server...") os._exit(0) + def main(): ui = DoraGradioUI() ui.launch() + if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/node-hub/dora-gradio/tests/test_dora_gradio.py b/node-hub/dora-gradio/tests/test_dora_gradio.py index a1c77d89c..01f9b8bdb 100644 --- a/node-hub/dora-gradio/tests/test_dora_gradio.py +++ b/node-hub/dora-gradio/tests/test_dora_gradio.py @@ -4,6 +4,7 @@ def test_import_main(): from dora_gradio.main import main - # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-internvl/dora_internvl/main.py b/node-hub/dora-internvl/dora_internvl/main.py index b86082708..28d354e7c 100644 --- a/node-hub/dora-internvl/dora_internvl/main.py +++ b/node-hub/dora-internvl/dora_internvl/main.py @@ -20,8 +20,13 @@ def build_transform(input_size): mean, std = IMAGENET_MEAN, IMAGENET_STD return transforms.Compose( [ - transforms.Lambda(lambda img: img.convert("RGB") if img.mode != "RGB" else img), - transforms.Resize((input_size, input_size), interpolation=InterpolationMode.BICUBIC), + transforms.Lambda( + lambda img: img.convert("RGB") if img.mode != "RGB" else img, + ), + transforms.Resize( + (input_size, input_size), + interpolation=InterpolationMode.BICUBIC, + ), transforms.ToTensor(), transforms.Normalize(mean=mean, std=std), ], @@ -46,7 +51,11 @@ 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, + image, + min_num=1, + max_num=12, + image_size=448, + use_thumbnail=False, ): """TODO: Add docstring.""" orig_width, orig_height = image.size @@ -64,7 +73,11 @@ def dynamic_preprocess( # find the closest aspect ratio to the target target_aspect_ratio = find_closest_aspect_ratio( - aspect_ratio, target_ratios, orig_width, orig_height, image_size, + aspect_ratio, + target_ratios, + orig_width, + orig_height, + image_size, ) # calculate the target width and height @@ -97,19 +110,24 @@ def load_image(image_array: np.array, input_size=448, max_num=12): image = Image.fromarray(image_array).convert("RGB") transform = build_transform(input_size=input_size) images = dynamic_preprocess( - image, image_size=input_size, use_thumbnail=True, max_num=max_num, + image, + image_size=input_size, + use_thumbnail=True, + max_num=max_num, ) pixel_values = [transform(image) for image in images] return torch.stack(pixel_values) def main(): - # Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables. + # 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" - # If you want to load a model using multiple GPUs, please refer to the `Multiple GPUs` section. + # If you want to load a model using multiple GPUs, please refer to the + # `Multiple GPUs` section. model = ( AutoModel.from_pretrained( model_path, @@ -122,7 +140,9 @@ def main(): .to(device) ) tokenizer = AutoTokenizer.from_pretrained( - model_path, trust_remote_code=True, use_fast=False, + model_path, + trust_remote_code=True, + use_fast=False, ) node = Node() @@ -171,7 +191,10 @@ def main(): ) generation_config = dict(max_new_tokens=1024, do_sample=True) response = model.chat( - tokenizer, pixel_values, question, generation_config, + tokenizer, + pixel_values, + question, + generation_config, ) node.send_output( "text", diff --git a/node-hub/dora-internvl/pyproject.toml b/node-hub/dora-internvl/pyproject.toml index 74f41b05c..ff68bc456 100644 --- a/node-hub/dora-internvl/pyproject.toml +++ b/node-hub/dora-internvl/pyproject.toml @@ -41,4 +41,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-internvl/tests/test_dora_internvl.py b/node-hub/dora-internvl/tests/test_dora_internvl.py index 9abe7bb07..c47600b56 100644 --- a/node-hub/dora-internvl/tests/test_dora_internvl.py +++ b/node-hub/dora-internvl/tests/test_dora_internvl.py @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): 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 13c675249..0ac74b359 100644 --- a/node-hub/dora-ios-lidar/dora_ios_lidar/main.py +++ b/node-hub/dora-ios-lidar/dora_ios_lidar/main.py @@ -27,8 +27,11 @@ def __init__(self): self.stop = False def on_new_frame(self): - """on_new_frame method is called from non-main thread, therefore cannot be used for presenting UI.""" - self.event.set() # Notify the main thread to stop waiting and process new frame. + """TODO: Add docstring.""" + # on_new_frame method is called from non-main thread, therefore cannot be used + # for presenting UI. + # Notify the main thread to stop waiting and process new frame. + self.event.set() def on_stream_stopped(self): """TODO: Add docstring.""" diff --git a/node-hub/dora-ios-lidar/pyproject.toml b/node-hub/dora-ios-lidar/pyproject.toml index f09480b80..b17210b8f 100644 --- a/node-hub/dora-ios-lidar/pyproject.toml +++ b/node-hub/dora-ios-lidar/pyproject.toml @@ -25,4 +25,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] 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 2567116a4..1573d8f5e 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 @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-keyboard/pyproject.toml b/node-hub/dora-keyboard/pyproject.toml index 62f028280..1cfd01cd8 100644 --- a/node-hub/dora-keyboard/pyproject.toml +++ b/node-hub/dora-keyboard/pyproject.toml @@ -34,4 +34,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-keyboard/tests/test_keyboard.py b/node-hub/dora-keyboard/tests/test_keyboard.py index fbea83561..cf1b36297 100644 --- a/node-hub/dora-keyboard/tests/test_keyboard.py +++ b/node-hub/dora-keyboard/tests/test_keyboard.py @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-kit-car/pyproject.toml b/node-hub/dora-kit-car/pyproject.toml index 5f7b1f6f6..eac8f6ede 100644 --- a/node-hub/dora-kit-car/pyproject.toml +++ b/node-hub/dora-kit-car/pyproject.toml @@ -26,4 +26,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] 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 7762cfca1..924e979d8 100644 --- a/node-hub/dora-kokoro-tts/dora_kokoro_tts/main.py +++ b/node-hub/dora-kokoro-tts/dora_kokoro_tts/main.py @@ -1,4 +1,5 @@ """TODO: Add docstring.""" + import os import re @@ -8,11 +9,12 @@ LANGUAGE = os.getenv("LANGUAGE", "en") + def main(): """TODO: Add docstring.""" if LANGUAGE in ["en", "english"]: pipeline = KPipeline(lang_code="a") - elif LANGUAGE in ["zh","ch","chinese"]: + elif LANGUAGE in ["zh", "ch", "chinese"]: pipeline = KPipeline(lang_code="z") else: print("warning: Defaulting to english speaker as language not found") @@ -24,10 +26,11 @@ def main(): if event["type"] == "INPUT": if event["id"] == "text": text = event["value"][0].as_py() - if re.findall(r'[\u4e00-\u9fff]+', text): + if re.findall(r"[\u4e00-\u9fff]+", text): pipeline = KPipeline(lang_code="z") elif pipeline.lang_code != "a": - pipeline = KPipeline(lang_code="a") # <= make sure lang_code matches voice + # make sure lang_code matches voice + pipeline = KPipeline(lang_code="a") generator = pipeline( text, diff --git a/node-hub/dora-kokoro-tts/pyproject.toml b/node-hub/dora-kokoro-tts/pyproject.toml index 712b3188d..c0ae9a35a 100644 --- a/node-hub/dora-kokoro-tts/pyproject.toml +++ b/node-hub/dora-kokoro-tts/pyproject.toml @@ -30,4 +30,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] 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 dd955248a..46264c2e7 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 @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-llama-cpp-python/dora_llama_cpp_python/main.py b/node-hub/dora-llama-cpp-python/dora_llama_cpp_python/main.py index b4d4c1952..66b9239f1 100644 --- a/node-hub/dora-llama-cpp-python/dora_llama_cpp_python/main.py +++ b/node-hub/dora-llama-cpp-python/dora_llama_cpp_python/main.py @@ -41,7 +41,8 @@ def get_model(): else: # Load from HuggingFace logging.info( - f"Downloading model {MODEL_NAME_OR_PATH} with pattern {MODEL_FILE_PATTERN}" + f"Downloading model {MODEL_NAME_OR_PATH} with pattern " + f"{MODEL_FILE_PATTERN}" ) llm = Llama.from_pretrained( repo_id=MODEL_NAME_OR_PATH, diff --git a/node-hub/dora-llama-cpp-python/pyproject.toml b/node-hub/dora-llama-cpp-python/pyproject.toml index 404521cea..e7c1b537d 100644 --- a/node-hub/dora-llama-cpp-python/pyproject.toml +++ b/node-hub/dora-llama-cpp-python/pyproject.toml @@ -51,4 +51,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-llama-cpp-python/tests/test_dora_llama_cpp_python.py b/node-hub/dora-llama-cpp-python/tests/test_dora_llama_cpp_python.py index a9b0a9e5e..28b133727 100644 --- a/node-hub/dora-llama-cpp-python/tests/test_dora_llama_cpp_python.py +++ b/node-hub/dora-llama-cpp-python/tests/test_dora_llama_cpp_python.py @@ -7,6 +7,7 @@ def test_import_main(): """TODO: Add docstring.""" from dora_llama_cpp_python.main import main - # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-magma/pyproject.toml b/node-hub/dora-magma/pyproject.toml index 1982b032e..0c04dbfee 100644 --- a/node-hub/dora-magma/pyproject.toml +++ b/node-hub/dora-magma/pyproject.toml @@ -48,4 +48,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-microphone/pyproject.toml b/node-hub/dora-microphone/pyproject.toml index 4e3ccae81..73d9a675e 100644 --- a/node-hub/dora-microphone/pyproject.toml +++ b/node-hub/dora-microphone/pyproject.toml @@ -34,4 +34,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-microphone/tests/test_microphone.py b/node-hub/dora-microphone/tests/test_microphone.py index d03110456..3d4e48333 100644 --- a/node-hub/dora-microphone/tests/test_microphone.py +++ b/node-hub/dora-microphone/tests/test_microphone.py @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-mujoco-husky/dora_mujoco_husky/main.py b/node-hub/dora-mujoco-husky/dora_mujoco_husky/main.py index 4986fc9c1..67850689f 100644 --- a/node-hub/dora-mujoco-husky/dora_mujoco_husky/main.py +++ b/node-hub/dora-mujoco-husky/dora_mujoco_husky/main.py @@ -18,60 +18,69 @@ def clamp(value, min_val, max_val): """Clamp value between min_val and max_val.""" return max(min(value, max_val), min_val) + def main(): try: node = Node("mujoco_husky") print("Initializing Mujoco Husky simulation...") - + ensure_meshes() - + model_path = os.path.join(os.path.dirname(__file__), "husky/husky.xml") model = mujoco.MjModel.from_xml_path(model_path) data = mujoco.MjData(model) - + # Define velocity limits - max_linear_velocity = 2.0 - max_angular_velocity = 3.0 - + max_linear_velocity = 2.0 + max_angular_velocity = 3.0 + with mujoco.viewer.launch_passive(model, data) as viewer: print("Simulation initialized successfully") for event in node: if event["type"] == "INPUT" and event["id"] == "cmd_vel": - cmd_vel = event["value"].to_pylist() - linear_x = clamp(float(cmd_vel[0]), -max_linear_velocity, max_linear_velocity) - angular_z = clamp(float(cmd_vel[5]), -max_angular_velocity, max_angular_velocity) + linear_x = clamp( + float(cmd_vel[0]), -max_linear_velocity, max_linear_velocity + ) + angular_z = clamp( + float(cmd_vel[5]), -max_angular_velocity, max_angular_velocity + ) wheel_radius = 0.17775 # Actual Husky wheel radius wheel_separation = 0.59 # Actual Husky track width - - left_velocity = ((linear_x - angular_z * wheel_separation / 2.0) / wheel_radius) - right_velocity = ((linear_x + angular_z * wheel_separation / 2.0) / wheel_radius) - + + left_velocity = ( + linear_x - angular_z * wheel_separation / 2.0 + ) / wheel_radius + right_velocity = ( + linear_x + angular_z * wheel_separation / 2.0 + ) / wheel_radius + # Apply wheel velocities - data.ctrl[0] = left_velocity - data.ctrl[1] = right_velocity - data.ctrl[2] = left_velocity - data.ctrl[3] = right_velocity - - + data.ctrl[0] = left_velocity + data.ctrl[1] = right_velocity + data.ctrl[2] = left_velocity + data.ctrl[3] = right_velocity + mujoco.mj_step(model, data) viewer.sync() - + # Send position and velocity data or any other form of feedback from mujoco position = data.qpos[:3].tolist() velocity = data.qvel[:3].tolist() - - node.send_output("position", + + node.send_output( + "position", data=pa.array(position, type=pa.float64()), - metadata={"type": "position"} + metadata={"type": "position"}, ) - - node.send_output("velocity", + + node.send_output( + "velocity", data=pa.array(velocity, type=pa.float64()), - metadata={"type": "velocity"} + metadata={"type": "velocity"}, ) except KeyboardInterrupt: @@ -80,5 +89,6 @@ def main(): print(f"Simulation error: {e}") raise e + if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/node-hub/dora-mujoco-husky/dora_mujoco_husky/mesh_downloader.py b/node-hub/dora-mujoco-husky/dora_mujoco_husky/mesh_downloader.py index 08b9d82e0..8fad1f58b 100644 --- a/node-hub/dora-mujoco-husky/dora_mujoco_husky/mesh_downloader.py +++ b/node-hub/dora-mujoco-husky/dora_mujoco_husky/mesh_downloader.py @@ -9,27 +9,29 @@ "wheel.stl", "top_plate.stl", "user_rail.stl", - "bumper.stl" + "bumper.stl", ] REPO_ID = "SGPatil/mujoco-husky-meshes" REPO_TYPE = "dataset" + def get_cache_dir(): cache_dir = Path.home() / ".cache" / "dora-mujoco-husky" / "meshes" cache_dir.mkdir(parents=True, exist_ok=True) return cache_dir + def ensure_meshes(): """Download and install required mesh files for the Husky robot simulation if they are not already present in the local cache. - + Raises: Exception: If there is an error downloading any of the mesh files. """ mesh_dir = Path(__file__).parent / "husky" / "meshes" mesh_dir.mkdir(parents=True, exist_ok=True) - + print("Checking mesh files...") try: for filename in MESH_FILES: @@ -38,19 +40,20 @@ def ensure_meshes(): repo_id=REPO_ID, filename=filename, repo_type=REPO_TYPE, - cache_dir=get_cache_dir() + cache_dir=get_cache_dir(), ) - + mesh_file = mesh_dir / filename if not mesh_file.exists(): print(f"Installing {filename} to {mesh_file}") mesh_file.write_bytes(Path(downloaded_path).read_bytes()) - + except Exception as e: print(f"Error downloading mesh files: {e}") raise e - + print("All mesh files are ready") + if __name__ == "__main__": - ensure_meshes() \ No newline at end of file + ensure_meshes() diff --git a/node-hub/dora-mujoco-husky/tests/test_dora_mujoco_husky.py b/node-hub/dora-mujoco-husky/tests/test_dora_mujoco_husky.py index 7b066b4ec..4471c24f8 100644 --- a/node-hub/dora-mujoco-husky/tests/test_dora_mujoco_husky.py +++ b/node-hub/dora-mujoco-husky/tests/test_dora_mujoco_husky.py @@ -4,6 +4,7 @@ def test_import_main(): from dora_mujoco_husky.main import main - # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-object-to-pose/pyproject.toml b/node-hub/dora-object-to-pose/pyproject.toml index 68fe3f3d4..558c4d039 100644 --- a/node-hub/dora-object-to-pose/pyproject.toml +++ b/node-hub/dora-object-to-pose/pyproject.toml @@ -23,4 +23,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] 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 aa4c25b8f..f3f694d10 100644 --- a/node-hub/dora-openai-server/dora_openai_server/main.py +++ b/node-hub/dora-openai-server/dora_openai_server/main.py @@ -65,7 +65,12 @@ async def create_chat_completion(request: ChatCompletionRequest): print("Passing input as string") if isinstance(data, list): data = pa.array(data) # initialize pyarrow array - elif isinstance(data, str) or isinstance(data, int) or isinstance(data, float) or isinstance(data, dict): + elif ( + isinstance(data, str) + or isinstance(data, int) + or isinstance(data, float) + or isinstance(data, dict) + ): data = pa.array([data]) else: data = pa.array(data) # initialize pyarrow array diff --git a/node-hub/dora-openai-server/pyproject.toml b/node-hub/dora-openai-server/pyproject.toml index 8b29cec9a..267ed8650 100644 --- a/node-hub/dora-openai-server/pyproject.toml +++ b/node-hub/dora-openai-server/pyproject.toml @@ -37,4 +37,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] 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 18cfb6cda..69f4b66b7 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,4 +1,5 @@ """TODO: Add docstring.""" + def test_import_main(): """TODO: Add docstring.""" diff --git a/node-hub/dora-opus/dora_opus/main.py b/node-hub/dora-opus/dora_opus/main.py index eb35b9c2d..b2bcea69d 100644 --- a/node-hub/dora-opus/dora_opus/main.py +++ b/node-hub/dora-opus/dora_opus/main.py @@ -32,7 +32,8 @@ def cut_repetition(text, min_repeat_length=4, max_repeat_length=50): if sum(1 for char in text if "\u4e00" <= char <= "\u9fff") / len(text) > 0.5: # Chinese text processing for repeat_length in range( - min_repeat_length, min(max_repeat_length, len(text) // 2), + min_repeat_length, + min(max_repeat_length, len(text) // 2), ): for i in range(len(text) - repeat_length * 2 + 1): chunk1 = text[i : i + repeat_length] @@ -44,7 +45,8 @@ def cut_repetition(text, min_repeat_length=4, max_repeat_length=50): # Non-Chinese (space-separated) text processing words = text.split() for repeat_length in range( - min_repeat_length, min(max_repeat_length, len(words) // 2), + min_repeat_length, + min(max_repeat_length, len(words) // 2), ): for i in range(len(words) - repeat_length * 2 + 1): chunk1 = " ".join(words[i : i + repeat_length]) diff --git a/node-hub/dora-opus/pyproject.toml b/node-hub/dora-opus/pyproject.toml index 696f2f9c5..1e7202670 100644 --- a/node-hub/dora-opus/pyproject.toml +++ b/node-hub/dora-opus/pyproject.toml @@ -38,4 +38,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-opus/tests/test_translate.py b/node-hub/dora-opus/tests/test_translate.py index f03028d02..da5b72763 100644 --- a/node-hub/dora-opus/tests/test_translate.py +++ b/node-hub/dora-opus/tests/test_translate.py @@ -6,6 +6,7 @@ def test_import_main(): pass # OPUS is no longer maintained in favor of dora-phi4 # 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. # nwith pytest.raises(RuntimeError): # nmain() diff --git a/node-hub/dora-outtetts/dora_outtetts/main.py b/node-hub/dora-outtetts/dora_outtetts/main.py index 6ef841cc3..e7f8a43fa 100644 --- a/node-hub/dora-outtetts/dora_outtetts/main.py +++ b/node-hub/dora-outtetts/dora_outtetts/main.py @@ -45,7 +45,8 @@ 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 + # If transcript is not provided, it will be automatically transcribed using + # Whisper transcript=None, # Set to None to use Whisper for transcription whisper_model="turbo", # Optional: specify Whisper model (default: "turbo") whisper_device=None, # Optional: specify device for Whisper (default: None) @@ -97,7 +98,8 @@ def main(arg_list: list[str] | None = None): ) elif event["id"] == "text": - # Warning: Make sure to add my_output_id and my_input_id within the dataflow. + # Warning: Make sure to add my_output_id and my_input_id within the + # dataflow. text = event["value"][0].as_py() output = interface.generate( text=text, diff --git a/node-hub/dora-outtetts/pyproject.toml b/node-hub/dora-outtetts/pyproject.toml index 32cd93698..6ae753c52 100644 --- a/node-hub/dora-outtetts/pyproject.toml +++ b/node-hub/dora-outtetts/pyproject.toml @@ -38,4 +38,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-parler/dora_parler/main.py b/node-hub/dora-parler/dora_parler/main.py index e6d221eda..929286706 100644 --- a/node-hub/dora-parler/dora_parler/main.py +++ b/node-hub/dora-parler/dora_parler/main.py @@ -18,7 +18,8 @@ set_seed, ) -device = "cuda:0" # if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu" +# if torch.cuda.is_available() else "mps" if torch.backends.mps.is_available() else "cpu" # noqa: E501 +device = "cuda:0" torch_dtype = torch.float16 if device != "cpu" else torch.float32 DEFAULT_PATH = "ylacombe/parler-tts-mini-jenny-30H" @@ -33,7 +34,9 @@ MODEL_NAME_OR_PATH = snapshot_download(MODEL_NAME_OR_PATH) model = ParlerTTSForConditionalGeneration.from_pretrained( - MODEL_NAME_OR_PATH, torch_dtype=torch_dtype, low_cpu_mem_usage=True, + MODEL_NAME_OR_PATH, + torch_dtype=torch_dtype, + low_cpu_mem_usage=True, ).to(device) model.generation_config.cache_implementation = "static" model.forward = torch.compile(model.forward, mode="default") @@ -46,7 +49,8 @@ default_text = "Hello, my name is Reachy the best robot in the world !" default_description = ( - "Jenny delivers her words quite expressively, in a very confined sounding environment with clear audio quality.", + "Jenny delivers her words quite expressively, in a very confined sounding " + "environment with clear audio quality.", ) @@ -78,7 +82,10 @@ def __init__(self): self.stop_signal = False def __call__( - self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs, + self, + input_ids: torch.LongTensor, + scores: torch.FloatTensor, + **kwargs, ) -> bool: """TODO: Add docstring.""" return self.stop_signal diff --git a/node-hub/dora-parler/pyproject.toml b/node-hub/dora-parler/pyproject.toml index 1b6208082..5cd5a42b9 100644 --- a/node-hub/dora-parler/pyproject.toml +++ b/node-hub/dora-parler/pyproject.toml @@ -40,4 +40,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-parler/tests/test_parler_tts.py b/node-hub/dora-parler/tests/test_parler_tts.py index 91bb5dcde..1e605acbb 100644 --- a/node-hub/dora-parler/tests/test_parler_tts.py +++ b/node-hub/dora-parler/tests/test_parler_tts.py @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-phi4/dora_phi4/main.py b/node-hub/dora-phi4/dora_phi4/main.py index bac068152..80fa9f25a 100644 --- a/node-hub/dora-phi4/dora_phi4/main.py +++ b/node-hub/dora-phi4/dora_phi4/main.py @@ -42,6 +42,7 @@ USE_FLASH_ATTN = False try: import flash_attn as _ # noqa + USE_FLASH_ATTN = True except (ImportError, ModuleNotFoundError): pass @@ -98,13 +99,19 @@ "translator elisabeth buffard reviewer denise rq", "Translator Elisabeth Buffard Reviewer Denise RQ.", "Translator Denise RQ Reviewer Denise RQ.", - "the company also has a presence the united states canada brazil argentina mexico colombia peru chile uruguay", - "the company also has a presence the united states canada brazil mexico argentina colombia chile peru and uruguay", - "the company also has a presence the united states canada brazil argentina mexico and the united kingdom", - "the company also presence in the united states canada brazil argentina mexico colombia peru chile uruguay", - "The company also has a presence in the United States, Canada, Brazil, Argentina, Mexico, Colombia, Peru, Chile, and Uruguay." + "the company also has a presence the united states canada brazil argentina mexico " + "colombia peru chile uruguay", + "the company also has a presence the united states canada brazil mexico argentina " + "colombia chile peru and uruguay", + "the company also has a presence the united states canada brazil argentina mexico " + "and the united kingdom", + "the company also presence in the united states canada brazil argentina mexico " + "colombia peru chile uruguay", + "The company also has a presence in the United States, Canada, Brazil, Argentina, " + "Mexico, Colombia, Peru, Chile, and Uruguay." "the company also has presence in the united states canada the united kingdom", - "company also has a presence the united states canada brazil argentina colombia mexico peru chile and uruguay", + "company also has a presence the united states canada brazil argentina colombia " + "mexico peru chile and uruguay", "the company also has a presence the united states canada and the united kingdom", "the company also announced that it will acquire the online retailer zappos", "the company has a market capitalization of 15 trillion yen", @@ -130,9 +137,11 @@ def remove_text_noise(text: str, text_noise="") -> str: text # Return the original text if text_noise is empty or just whitespace ) - # Helper function to normalize text (remove punctuation, make lowercase, and handle hyphens) + # Helper function to normalize text + # (remove punctuation, make lowercase, and handle hyphens) def normalize(s): - # Replace hyphens with spaces to treat "Notre-Dame" and "notre dame" as equivalent + # Replace hyphens with spaces to treat "Notre-Dame" and "notre dame" as + # equivalent s = re.sub(r"-", " ", s) # Remove other punctuation and convert to lowercase return re.sub(r"[^\w\s]", "", s).lower() @@ -257,7 +266,10 @@ def main(): else: audio_prompt = "" - prompt = f"{user_prompt}{audio_prompt}{image_prompt}{text}{prompt_suffix}{assistant_prompt}" + prompt = ( + f"{user_prompt}{audio_prompt}{image_prompt}{text}{prompt_suffix}" + f"{assistant_prompt}" + ) # Process input inputs = processor( diff --git a/node-hub/dora-phi4/pyproject.toml b/node-hub/dora-phi4/pyproject.toml index 984f781db..5c8de49a9 100644 --- a/node-hub/dora-phi4/pyproject.toml +++ b/node-hub/dora-phi4/pyproject.toml @@ -42,4 +42,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-phi4/tests/test_dora_phi4.py b/node-hub/dora-phi4/tests/test_dora_phi4.py index ab280144e..cf8032996 100644 --- a/node-hub/dora-phi4/tests/test_dora_phi4.py +++ b/node-hub/dora-phi4/tests/test_dora_phi4.py @@ -7,6 +7,7 @@ def test_import_main(): """TODO: Add docstring.""" from dora_phi4.main import main - # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-piper/pyproject.toml b/node-hub/dora-piper/pyproject.toml index c526a12e0..f4816615c 100644 --- a/node-hub/dora-piper/pyproject.toml +++ b/node-hub/dora-piper/pyproject.toml @@ -25,4 +25,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-piper/tests/test_piper.py b/node-hub/dora-piper/tests/test_piper.py index ecbd2bd96..a1e729343 100644 --- a/node-hub/dora-piper/tests/test_piper.py +++ b/node-hub/dora-piper/tests/test_piper.py @@ -1,5 +1,6 @@ """TODO: Add docstring.""" + def test_import_main(): """TODO: Add docstring.""" from piper_sdk import C_PiperInterface diff --git a/node-hub/dora-pyaudio/pyproject.toml b/node-hub/dora-pyaudio/pyproject.toml index bf3a62d66..3cc2e1062 100644 --- a/node-hub/dora-pyaudio/pyproject.toml +++ b/node-hub/dora-pyaudio/pyproject.toml @@ -30,4 +30,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-pyaudio/tests/test_dora_pyaudio.py b/node-hub/dora-pyaudio/tests/test_dora_pyaudio.py index 1492eb6ee..f087dc97a 100644 --- a/node-hub/dora-pyaudio/tests/test_dora_pyaudio.py +++ b/node-hub/dora-pyaudio/tests/test_dora_pyaudio.py @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-pyorbbecksdk/dora_pyorbbecksdk/main.py b/node-hub/dora-pyorbbecksdk/dora_pyorbbecksdk/main.py index 1d00db615..a8dad40a5 100644 --- a/node-hub/dora-pyorbbecksdk/dora_pyorbbecksdk/main.py +++ b/node-hub/dora-pyorbbecksdk/dora_pyorbbecksdk/main.py @@ -55,7 +55,11 @@ def process(self, frame): result = frame else: result = cv2.addWeighted( - frame, self.alpha, self.previous_frame, 1 - self.alpha, 0, + frame, + self.alpha, + self.previous_frame, + 1 - self.alpha, + 0, ) self.previous_frame = result return result @@ -150,7 +154,10 @@ def main(): profile_list = pipeline.get_stream_profile_list(OBSensorType.COLOR_SENSOR) try: color_profile: VideoStreamProfile = profile_list.get_video_stream_profile( - 640, 480, OBFormat.RGB, 30, + 640, + 480, + OBFormat.RGB, + 30, ) except OBError as e: print(e) @@ -159,7 +166,10 @@ def main(): profile_list = pipeline.get_stream_profile_list(OBSensorType.DEPTH_SENSOR) try: depth_profile: VideoStreamProfile = profile_list.get_video_stream_profile( - 640, 480, OBFormat.Y16, 30, + 640, + 480, + OBFormat.Y16, + 30, ) except OBError as e: print(e) @@ -209,7 +219,12 @@ def main(): node.send_output("depth", storage) # Convert to Image depth_image = cv2.normalize( - depth_data, None, 0, 255, cv2.NORM_MINMAX, dtype=cv2.CV_8U, + depth_data, + None, + 0, + 255, + cv2.NORM_MINMAX, + dtype=cv2.CV_8U, ) # Send Depth Image depth_image = cv2.applyColorMap(depth_image, cv2.COLORMAP_JET) diff --git a/node-hub/dora-pyorbbecksdk/pyproject.toml b/node-hub/dora-pyorbbecksdk/pyproject.toml index 08d28afd5..f0ec14434 100644 --- a/node-hub/dora-pyorbbecksdk/pyproject.toml +++ b/node-hub/dora-pyorbbecksdk/pyproject.toml @@ -28,4 +28,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-pyorbbecksdk/tests/test_pyorbbecksdk.py b/node-hub/dora-pyorbbecksdk/tests/test_pyorbbecksdk.py index 760ed683f..882b577a5 100644 --- a/node-hub/dora-pyorbbecksdk/tests/test_pyorbbecksdk.py +++ b/node-hub/dora-pyorbbecksdk/tests/test_pyorbbecksdk.py @@ -1,5 +1,6 @@ """TODO: Add docstring.""" + def test_import_main(): """TODO: Add docstring.""" return # Remove this if you want to test pyorbbecksdk installation @@ -8,6 +9,7 @@ def test_import_main(): # from opencv_video_capture.main import main # skip test as pyorbbecksdk installation is a bit complicated - # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. # with pytest.raises(RuntimeError): # main() diff --git a/node-hub/dora-pyrealsense/pyproject.toml b/node-hub/dora-pyrealsense/pyproject.toml index b9a572fe1..d8bec8f2f 100644 --- a/node-hub/dora-pyrealsense/pyproject.toml +++ b/node-hub/dora-pyrealsense/pyproject.toml @@ -31,4 +31,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-pyrealsense/tests/test_dora_pyrealsense.py b/node-hub/dora-pyrealsense/tests/test_dora_pyrealsense.py index d2e30241f..d00fd53a2 100644 --- a/node-hub/dora-pyrealsense/tests/test_dora_pyrealsense.py +++ b/node-hub/dora-pyrealsense/tests/test_dora_pyrealsense.py @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(ConnectionError): main() diff --git a/node-hub/dora-qwen/dora_qwen/main.py b/node-hub/dora-qwen/dora_qwen/main.py index 957abf429..af0e8e6ed 100644 --- a/node-hub/dora-qwen/dora_qwen/main.py +++ b/node-hub/dora-qwen/dora_qwen/main.py @@ -82,7 +82,8 @@ def main(): for event in node: if event["type"] == "INPUT": - # Warning: Make sure to add my_output_id and my_input_id within the dataflow. + # Warning: Make sure to add my_output_id and my_input_id within the + # dataflow. text = event["value"][0].as_py() words = text.lower().split() diff --git a/node-hub/dora-qwen/pyproject.toml b/node-hub/dora-qwen/pyproject.toml index c78728e9c..23aa52eec 100644 --- a/node-hub/dora-qwen/pyproject.toml +++ b/node-hub/dora-qwen/pyproject.toml @@ -52,4 +52,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-qwen/tests/test_dora_qwen.py b/node-hub/dora-qwen/tests/test_dora_qwen.py index 87b2182a6..2e21182a1 100644 --- a/node-hub/dora-qwen/tests/test_dora_qwen.py +++ b/node-hub/dora-qwen/tests/test_dora_qwen.py @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() 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 3125858c3..9c81316ed 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 @@ -23,7 +23,8 @@ SYSTEM_PROMPT = os.getenv( "SYSTEM_PROMPT", - "You're a very succinct AI assistant, that describes image with a very short sentence.", + "You're a very succinct AI assistant, that describes image with a very short " + "sentence.", ) ACTIVATION_WORDS = os.getenv("ACTIVATION_WORDS", "").split() @@ -104,7 +105,8 @@ def generate(frames: dict, question, history, past_key_values=None, image_id=Non inputs = inputs.to(model.device) # Inference: Generation of the output - ## TODO: Add past_key_values to the inputs when https://github.com/huggingface/transformers/issues/34678 is fixed. + # TODO: Add past_key_values to the inputs when + # https://github.com/huggingface/transformers/issues/34678 is fixed. outputs = model.generate( **inputs, max_new_tokens=128, # past_key_values=past_key_values diff --git a/node-hub/dora-qwen2-5-vl/pyproject.toml b/node-hub/dora-qwen2-5-vl/pyproject.toml index 532e67a1d..0412fee21 100644 --- a/node-hub/dora-qwen2-5-vl/pyproject.toml +++ b/node-hub/dora-qwen2-5-vl/pyproject.toml @@ -58,4 +58,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] 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 f9d603430..49769b51c 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 @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-qwenvl/dora_qwenvl/main.py b/node-hub/dora-qwenvl/dora_qwenvl/main.py index 537e61332..5799b5603 100644 --- a/node-hub/dora-qwenvl/dora_qwenvl/main.py +++ b/node-hub/dora-qwenvl/dora_qwenvl/main.py @@ -74,7 +74,9 @@ def generate(frames: dict, question): # Preparation for inference text = processor.apply_chat_template( - messages, tokenize=False, add_generation_prompt=True, + messages, + tokenize=False, + add_generation_prompt=True, ) image_inputs, video_inputs = process_vision_info(messages) inputs = processor( @@ -128,7 +130,19 @@ def main(): width = metadata["width"] height = metadata["height"] - if encoding == "bgr8" or encoding == "rgb8" or encoding in ["jpeg", "jpg", "jpe", "bmp", "webp", "png"]: + if ( + encoding == "bgr8" + or encoding == "rgb8" + or encoding + in [ + "jpeg", + "jpg", + "jpe", + "bmp", + "webp", + "png", + ] + ): channels = 3 storage_type = np.uint8 else: diff --git a/node-hub/dora-qwenvl/pyproject.toml b/node-hub/dora-qwenvl/pyproject.toml index ddb309488..8813554e3 100644 --- a/node-hub/dora-qwenvl/pyproject.toml +++ b/node-hub/dora-qwenvl/pyproject.toml @@ -45,4 +45,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-qwenvl/tests/test_dora_qwenvl.py b/node-hub/dora-qwenvl/tests/test_dora_qwenvl.py index 74e912ed7..e646f9c55 100644 --- a/node-hub/dora-qwenvl/tests/test_dora_qwenvl.py +++ b/node-hub/dora-qwenvl/tests/test_dora_qwenvl.py @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-rav1e/pyproject.toml b/node-hub/dora-rav1e/pyproject.toml index e59d54947..cdaf6d92f 100644 --- a/node-hub/dora-rav1e/pyproject.toml +++ b/node-hub/dora-rav1e/pyproject.toml @@ -23,4 +23,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] 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 b43c97dc0..061f22a11 100644 --- a/node-hub/dora-rdt-1b/dora_rdt_1b/main.py +++ b/node-hub/dora-rdt-1b/dora_rdt_1b/main.py @@ -18,7 +18,8 @@ VISION_DEFAULT_PATH = "robotics-diffusion-transformer/rdt-1b" ROBOTIC_MODEL_NAME_OR_PATH = os.getenv( - "ROBOTIC_MODEL_NAME_OR_PATH", VISION_DEFAULT_PATH, + "ROBOTIC_MODEL_NAME_OR_PATH", + VISION_DEFAULT_PATH, ) LANGUAGE_EMBEDDING_PATH = os.getenv("LANGUAGE_EMBEDDING", "lang_embed.pt") @@ -55,7 +56,7 @@ def get_policy(): def get_vision_model(): """TODO: Add docstring.""" - from dora_rdt_1b.RoboticsDiffusionTransformer.models.multimodal_encoder.siglip_encoder import ( + from dora_rdt_1b.RoboticsDiffusionTransformer.models.multimodal_encoder.siglip_encoder import ( # noqa: E501 SiglipVisionTower, ) @@ -79,9 +80,11 @@ def get_language_embeddings(): map_location=device, ) + # Size: (b, L_lang, D) or None, language condition tokens (variable length), + # dimension D is assumed to be the same as the hidden size. return lang_embeddings.unsqueeze( 0, - ) # Size: (b, L_lang, D) or None, language condition tokens (variable length), dimension D is assumed to be the same as the hidden size. + ) def expand2square(pil_img, background_color): @@ -99,15 +102,17 @@ def expand2square(pil_img, background_color): def process_image(rgbs_lst, image_processor, vision_encoder): - # previous_image_path = "/mnt/hpfs/1ms.ai/dora/node-hub/dora-rdt-1b/dora_rdt_1b/RoboticsDiffusionTransformer/img.jpeg" + # previous_image_path = "/mnt/hpfs/1ms.ai/dora/node-hub/dora-rdt-1b/dora_rdt_1b/RoboticsDiffusionTransformer/img.jpeg" # noqa: E501 # # previous_image = None # if t = 0 # previous_image = Image.fromarray(previous_image_path).convert("RGB") # if t > 0 - # current_image_path = "/mnt/hpfs/1ms.ai/dora/node-hub/dora-rdt-1b/dora_rdt_1b/RoboticsDiffusionTransformer/img.jpeg" + # current_image_path = "/mnt/hpfs/1ms.ai/dora/node-hub/dora-rdt-1b/dora_rdt_1b/RoboticsDiffusionTransformer/img.jpeg" # noqa: E501 # current_image = Image.fromarray(current_image_path).convert("RGB") - # here I suppose you only have an image from exterior (e.g., 3rd person view) and you don't have any state information - # the images should arrange in sequence [exterior_image, right_wrist_image, left_wrist_image] * image_history_size (e.g., 2) + # here I suppose you only have an image from exterior (e.g., 3rd person view) and + # you don't have any state information the images should arrange in sequence + # [exterior_image, right_wrist_image, left_wrist_image] * image_history_size + # (e.g., 2) # rgbs_lst = [[previous_image, None, None], [current_image, None, None]] # if your have an right_wrist_image, then it should be # rgbs_lst = [ @@ -163,21 +168,27 @@ def get_states(proprio): b, n = 1, 1 # batch size and state history size states = torch.zeros( - (b, n, config["model"]["state_token_dim"]), device=DEVICE, dtype=DTYPE, + (b, n, config["model"]["state_token_dim"]), + device=DEVICE, + dtype=DTYPE, ) # suppose you do not have proprio - # it's kind of tricky, I strongly suggest adding proprio as input and further fine-tuning + # it's kind of tricky, I strongly suggest adding proprio as input and further + # fine-tuning proprio = torch.tensor(proprio, device=DEVICE, dtype=DTYPE).reshape( (1, 1, -1), ) # b, n = 1, 1 # batch size and state history size # if you have proprio, you can do like this - # format like this: [arm_joint_0_pos, arm_joint_1_pos, arm_joint_2_pos, arm_joint_3_pos, arm_joint_4_pos, arm_joint_5_pos, arm_joint_6_pos, gripper_open] + # format like this: [arm_joint_0_pos, arm_joint_1_pos, arm_joint_2_pos, + # arm_joint_3_pos, arm_joint_4_pos, arm_joint_5_pos, arm_joint_6_pos, gripper_open] # proprio = torch.tensor([0, 1, 2, 3, 4, 5, 6, 0.5]).reshape((1, 1, -1)) states[:, :, state_indices] = proprio state_elem_mask = torch.zeros( - (1, config["model"]["state_token_dim"]), device=DEVICE, dtype=torch.bool, + (1, config["model"]["state_token_dim"]), + device=DEVICE, + dtype=torch.bool, ) state_elem_mask[:, state_indices] = True @@ -213,7 +224,11 @@ def main(): metadata = event["metadata"] encoding = metadata["encoding"] - if encoding == "bgr8" or encoding == "rgb8" or encoding in ["jpeg", "jpg", "jpe", "bmp", "webp", "png"]: + if ( + encoding == "bgr8" + or encoding == "rgb8" + or encoding in ["jpeg", "jpg", "jpe", "bmp", "webp", "png"] + ): channels = 3 storage_type = np.uint8 else: @@ -243,7 +258,8 @@ def main(): else: raise RuntimeError(f"Unsupported image encoding: {encoding}") frames[f"last_{event_id}"] = frames.get( - event_id, Image.fromarray(frame), + event_id, + Image.fromarray(frame), ) frames[event_id] = Image.fromarray(frame) elif "jointstate" in event_id: @@ -270,7 +286,9 @@ def main(): ], ] image_embeds = process_image( - rgbs_lst, image_processor, vision_encoder, + rgbs_lst, + image_processor, + vision_encoder, ) ## Embed states @@ -285,19 +303,24 @@ def main(): actions = rdt.predict_action( lang_tokens=lang_embeddings, lang_attn_mask=torch.ones( - lang_embeddings.shape[:2], dtype=torch.bool, device=DEVICE, + lang_embeddings.shape[:2], + dtype=torch.bool, + device=DEVICE, ), img_tokens=image_embeds, state_tokens=states, # how can I get this? action_mask=state_elem_mask.unsqueeze(1), # how can I get this? ctrl_freqs=torch.tensor( - [25.0], device=DEVICE, + [25.0], + device=DEVICE, ), # would this default work? ) # (1, chunk_size, 128) # select the meaning action via STATE_INDICES action = actions[ - :, :, state_indices, + :, + :, + state_indices, ] # (1, chunk_size, len(STATE_INDICES)) = (1, chunk_size, 7+ 1) action = action.detach().float().to("cpu").numpy() node.send_output("action", pa.array(action.ravel())) diff --git a/node-hub/dora-rdt-1b/pyproject.toml b/node-hub/dora-rdt-1b/pyproject.toml index 9b2fd8780..bf3125618 100644 --- a/node-hub/dora-rdt-1b/pyproject.toml +++ b/node-hub/dora-rdt-1b/pyproject.toml @@ -55,4 +55,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] 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 75d9f06cd..22f320b79 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 @@ -19,7 +19,8 @@ def test_import_main(): # from dora_rdt_1b.main import main - # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. + # 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.""" @@ -80,8 +81,10 @@ def test_load_dummy_image(): current_image_path = "/path/to/img.jpeg" current_image = Image.open(current_image_path).convert("RGB") - # here I suppose you only have an image from exterior (e.g., 3rd person view) and you don't have any state information - # the images should arrange in sequence [exterior_image, right_wrist_image, left_wrist_image] * image_history_size (e.g., 2) + # here I suppose you only have an image from exterior (e.g., 3rd person view) and + # you don't have any state information the images should arrange in sequence + # [exterior_image, right_wrist_image, left_wrist_image] * image_history_size + # (e.g., 2) rgbs_lst = [[previous_image, None, None], [current_image, None, None]] # if your have an right_wrist_image, then it should be # rgbs_lst = [ @@ -171,7 +174,8 @@ def test_dummy_states(): return # suppose you do not have proprio - # it's kind of tricky, I strongly suggest adding proprio as input and further fine-tuning + # it's kind of tricky, I strongly suggest adding proprio as input and further + # fine-tuning b, n = 1, 1 # batch size and state history size states = torch.zeros( (b, n, config["model"]["state_token_dim"]), @@ -180,7 +184,8 @@ def test_dummy_states(): ) # if you have proprio, you can do like this - # format like this: [arm_joint_0_pos, arm_joint_1_pos, arm_joint_2_pos, arm_joint_3_pos, arm_joint_4_pos, arm_joint_5_pos, arm_joint_6_pos, gripper_open] + # format like this: [arm_joint_0_pos, arm_joint_1_pos, arm_joint_2_pos, + # arm_joint_3_pos, arm_joint_4_pos, arm_joint_5_pos, arm_joint_6_pos, gripper_open] # proprio = torch.tensor([0, 1, 2, 3, 4, 5, 6, 0.5]).reshape((1, 1, -1)) # states[:, :, state_indices] = proprio diff --git a/node-hub/dora-reachy1/dora_reachy1/main.py b/node-hub/dora-reachy1/dora_reachy1/main.py index 4699b498f..0cd705e70 100644 --- a/node-hub/dora-reachy1/dora_reachy1/main.py +++ b/node-hub/dora-reachy1/dora_reachy1/main.py @@ -1,4 +1,5 @@ """TODO: Add docstring.""" + import os import time @@ -70,7 +71,12 @@ def main(): default_pose = r_arm_inverse_kinematics(reachy, r_arm_pose, [0, 0, 0]) goto( - {joint: pos for joint, pos in zip(reachy.r_arm.joints.values(), default_pose, strict=False)}, + { + joint: pos + for joint, pos in zip( + reachy.r_arm.joints.values(), default_pose, strict=False + ) + }, duration=3, ) @@ -84,7 +90,9 @@ def main(): goto( { joint: pos - for joint, pos in zip(reachy.r_arm.joints.values(), joint_pose, strict=False) + for joint, pos in zip( + reachy.r_arm.joints.values(), joint_pose, strict=False + ) }, duration=0.200, ) @@ -119,7 +127,9 @@ def main(): { joint: pos for joint, pos in zip( - reachy.r_arm.joints.values(), default_pose, strict=False, + reachy.r_arm.joints.values(), + default_pose, + strict=False, ) }, duration=3, diff --git a/node-hub/dora-reachy1/pyproject.toml b/node-hub/dora-reachy1/pyproject.toml index aed064967..3e0398b06 100644 --- a/node-hub/dora-reachy1/pyproject.toml +++ b/node-hub/dora-reachy1/pyproject.toml @@ -37,4 +37,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-reachy1/tests/test_dora_reachy1.py b/node-hub/dora-reachy1/tests/test_dora_reachy1.py index 470cc4fc5..3e2729bf7 100644 --- a/node-hub/dora-reachy1/tests/test_dora_reachy1.py +++ b/node-hub/dora-reachy1/tests/test_dora_reachy1.py @@ -10,6 +10,7 @@ def test_pass(): # def test_import_main(): # from dora_reachy1.main import main -# Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. +# Check that everything is working, and catch dora Runtime Exception as we're not +# running in a dora dataflow. # with pytest.raises(RuntimeError): # main() diff --git a/node-hub/dora-reachy1/tests/test_dora_reachy1_vision.py b/node-hub/dora-reachy1/tests/test_dora_reachy1_vision.py index 76eedcf1f..3ddcef70a 100644 --- a/node-hub/dora-reachy1/tests/test_dora_reachy1_vision.py +++ b/node-hub/dora-reachy1/tests/test_dora_reachy1_vision.py @@ -7,6 +7,7 @@ def test_import_main(): """TODO: Add docstring.""" from dora_reachy1_vision.main import main - # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-reachy2/dora_reachy2/left_arm.py b/node-hub/dora-reachy2/dora_reachy2/left_arm.py index 949771690..f7c701b39 100644 --- a/node-hub/dora-reachy2/dora_reachy2/left_arm.py +++ b/node-hub/dora-reachy2/dora_reachy2/left_arm.py @@ -38,10 +38,11 @@ def l_arm_go_to_mixed_angles(reachy, x, y, z): continue for yaw in range(0, 90, 30): - ## First try turning left pitch = -90 - r = Rotation.from_euler("ZYX", (-yaw, 0, 0), degrees=True) * Rotation.from_euler( + r = Rotation.from_euler( + "ZYX", (-yaw, 0, 0), degrees=True + ) * Rotation.from_euler( "ZYX", (0, pitch, 0), degrees=True, @@ -105,7 +106,6 @@ def main(): for event in node: if event["type"] == "INPUT": if event["id"] == "pose": - values: np.array = event["value"].to_numpy(zero_copy_only=False) encoding = event["metadata"]["encoding"] wait = event["metadata"].get("wait", True) @@ -127,7 +127,6 @@ def main(): if response_ik: joint_values.append((joints, gripper)) else: - break if not response_ik: diff --git a/node-hub/dora-reachy2/dora_reachy2/right_arm.py b/node-hub/dora-reachy2/dora_reachy2/right_arm.py index 0050d3046..ce3d8859e 100644 --- a/node-hub/dora-reachy2/dora_reachy2/right_arm.py +++ b/node-hub/dora-reachy2/dora_reachy2/right_arm.py @@ -37,7 +37,6 @@ def r_arm_go_to_mixed_angles(reachy, x, y, z): continue for yaw in range(0, 90, 30): - ## First try turning left pitch = -90 r = Rotation.from_euler("ZYX", (yaw, 0, 0), degrees=True) * Rotation.from_euler( @@ -104,7 +103,6 @@ def main(): for event in node: if event["type"] == "INPUT": if event["id"] == "pose": - values: np.array = event["value"].to_numpy(zero_copy_only=False) encoding = event["metadata"]["encoding"] wait = event["metadata"].get("wait", True) @@ -126,7 +124,6 @@ def main(): if response_ik: joint_values.append((joints, gripper)) else: - break if not response_ik: diff --git a/node-hub/dora-reachy2/pyproject.toml b/node-hub/dora-reachy2/pyproject.toml index 3b64479fe..79cd6422a 100644 --- a/node-hub/dora-reachy2/pyproject.toml +++ b/node-hub/dora-reachy2/pyproject.toml @@ -34,4 +34,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-reachy2/tests/test_dora_reachy2.py b/node-hub/dora-reachy2/tests/test_dora_reachy2.py index 824f256f0..d60e4e1a6 100644 --- a/node-hub/dora-reachy2/tests/test_dora_reachy2.py +++ b/node-hub/dora-reachy2/tests/test_dora_reachy2.py @@ -10,7 +10,8 @@ def test_pass(): # def test_import_camera_main(): # from dora_reachy2.camera import main -# # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. +# # Check that everything is working, and catch dora Runtime Exception as we're not +# running in a dora dataflow. # with pytest.raises(RuntimeError): # main() @@ -18,7 +19,8 @@ def test_pass(): # def test_import_head_main(): # from dora_reachy2.head import main -# # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. +# # Check that everything is working, and catch dora Runtime Exception as we're not +# running in a dora dataflow. # with pytest.raises(RuntimeError): # main() @@ -26,7 +28,8 @@ def test_pass(): # def test_import_left_arm_main(): # from dora_reachy2.left_arm import main -# # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. +# # Check that everything is working, and catch dora Runtime Exception as we're not +# running in a dora dataflow. # with pytest.raises(RuntimeError): # main() @@ -34,6 +37,7 @@ def test_pass(): # def test_import_right_arm_main(): # from dora_reachy2.right_arm import main -# # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. +# # Check that everything is working, and catch dora Runtime Exception as we're not +# running in a dora dataflow. # with pytest.raises(RuntimeError): # main() diff --git a/node-hub/dora-rerun/pyproject.toml b/node-hub/dora-rerun/pyproject.toml index e06c5c54b..fa17f815a 100644 --- a/node-hub/dora-rerun/pyproject.toml +++ b/node-hub/dora-rerun/pyproject.toml @@ -28,4 +28,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-sam2/pyproject.toml b/node-hub/dora-sam2/pyproject.toml index 6ad124b88..bfb0b114d 100644 --- a/node-hub/dora-sam2/pyproject.toml +++ b/node-hub/dora-sam2/pyproject.toml @@ -33,4 +33,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-sam2/tests/test_dora_sam2.py b/node-hub/dora-sam2/tests/test_dora_sam2.py index 4ed0b83e8..3dfdb6721 100644 --- a/node-hub/dora-sam2/tests/test_dora_sam2.py +++ b/node-hub/dora-sam2/tests/test_dora_sam2.py @@ -15,6 +15,7 @@ def test_import_main(): from dora_sam2.main import main - # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-transformers/dora_transformers/main.py b/node-hub/dora-transformers/dora_transformers/main.py index e11e331fe..2489adce4 100644 --- a/node-hub/dora-transformers/dora_transformers/main.py +++ b/node-hub/dora-transformers/dora_transformers/main.py @@ -20,7 +20,7 @@ MAX_TOKENS = int(os.getenv("MAX_TOKENS", "512")) DEVICE = os.getenv("DEVICE", "auto") TORCH_DTYPE = os.getenv("TORCH_DTYPE", "auto") -HISTORY= os.getenv("HISTORY", "False").lower() == "true" +HISTORY = os.getenv("HISTORY", "False").lower() == "true" # Words that trigger the model to respond @@ -91,7 +91,12 @@ def main(): if len(ACTIVATION_WORDS) == 0 or any( word in ACTIVATION_WORDS for word in words ): - response, tmp_history = generate_response(model, tokenizer, text, history) + response, tmp_history = generate_response( + model, + tokenizer, + text, + history, + ) history = tmp_history if HISTORY else history node.send_output( output_id="text", data=pa.array([response]), metadata={} diff --git a/node-hub/dora-transformers/pyproject.toml b/node-hub/dora-transformers/pyproject.toml index a6c770343..8839c59bc 100644 --- a/node-hub/dora-transformers/pyproject.toml +++ b/node-hub/dora-transformers/pyproject.toml @@ -36,4 +36,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-transformers/tests/test_dora_transformers.py b/node-hub/dora-transformers/tests/test_dora_transformers.py index 0fec3a9a6..829a68ae7 100644 --- a/node-hub/dora-transformers/tests/test_dora_transformers.py +++ b/node-hub/dora-transformers/tests/test_dora_transformers.py @@ -7,6 +7,7 @@ def test_import_main(): """TODO: Add docstring.""" from dora_transformers.main import main - # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-ugv/pyproject.toml b/node-hub/dora-ugv/pyproject.toml index 3ae0421fa..18b838585 100644 --- a/node-hub/dora-ugv/pyproject.toml +++ b/node-hub/dora-ugv/pyproject.toml @@ -25,4 +25,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-ugv/tests/test_ugv.py b/node-hub/dora-ugv/tests/test_ugv.py index f5c8ab516..337e56581 100644 --- a/node-hub/dora-ugv/tests/test_ugv.py +++ b/node-hub/dora-ugv/tests/test_ugv.py @@ -1,5 +1,6 @@ """TODO: Add docstring.""" + def test_import_main(): """TODO: Add docstring.""" return # Remove this if you want to test ugv_sdk_py installation @@ -9,6 +10,7 @@ def test_import_main(): # from opencv_video_capture.main import main # skip test as pyorbbecksdk installation is a bit complicated - # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. # with pytest.raises(RuntimeError): # main() diff --git a/node-hub/dora-vad/dora_vad/main.py b/node-hub/dora-vad/dora_vad/main.py index 9a674ddb9..e361a528d 100644 --- a/node-hub/dora-vad/dora_vad/main.py +++ b/node-hub/dora-vad/dora_vad/main.py @@ -43,7 +43,8 @@ def main(): len(speech_timestamps) > 0 and len(audio) > MIN_AUDIO_SAMPLING_DURATION_MS * sr / 1000 ): - # Check if the audio is not cut at the end. And only return if there is a long time spent + # Check if the audio is not cut at the end. And only return if there is + # a long time spent if speech_timestamps[-1]["end"] == len(audio): node.send_output( "timestamp_start", diff --git a/node-hub/dora-vad/pyproject.toml b/node-hub/dora-vad/pyproject.toml index d9e914728..dbb602c72 100644 --- a/node-hub/dora-vad/pyproject.toml +++ b/node-hub/dora-vad/pyproject.toml @@ -25,4 +25,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-vad/tests/test_translate.py b/node-hub/dora-vad/tests/test_translate.py index 3fb2acde1..9d36ebfaa 100644 --- a/node-hub/dora-vad/tests/test_translate.py +++ b/node-hub/dora-vad/tests/test_translate.py @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dora-yolo/dora_yolo/main.py b/node-hub/dora-yolo/dora_yolo/main.py index b8e345df2..ad70f1e59 100644 --- a/node-hub/dora-yolo/dora_yolo/main.py +++ b/node-hub/dora-yolo/dora_yolo/main.py @@ -10,10 +10,14 @@ def main(): - # Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables. + # 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.", + description=( + "UltraLytics YOLO: This node is used to perform object detection using " + "the UltraLytics YOLO model." + ), ) parser.add_argument( diff --git a/node-hub/dora-yolo/pyproject.toml b/node-hub/dora-yolo/pyproject.toml index 4e7047b8d..f736d6984 100644 --- a/node-hub/dora-yolo/pyproject.toml +++ b/node-hub/dora-yolo/pyproject.toml @@ -28,4 +28,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dora-yolo/tests/test_ultralytics_yolo.py b/node-hub/dora-yolo/tests/test_ultralytics_yolo.py index 1f25dd3d5..4d2e3d22b 100644 --- a/node-hub/dora-yolo/tests/test_ultralytics_yolo.py +++ b/node-hub/dora-yolo/tests/test_ultralytics_yolo.py @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/dynamixel-client/dynamixel_client/bus.py b/node-hub/dynamixel-client/dynamixel_client/bus.py index 6809f4e7a..eb1268983 100644 --- a/node-hub/dynamixel-client/dynamixel_client/bus.py +++ b/node-hub/dynamixel-client/dynamixel_client/bus.py @@ -29,13 +29,15 @@ def wrap_joints_and_values( :param joints: A list, numpy array, or pyarrow array of joint names. :type joints: Union[list[str], np.array, pa.Array] - :param values: A single integer value, or a list, numpy array, or pyarrow array of integer values. - If a single integer is provided, it will be broadcasted to all joints. + :param values: A single integer value, or a list, numpy array, or pyarrow array of + integer values. If a single integer is provided, it will be + broadcasted to all joints. :type values: Union[int, list[int], np.array, pa.Array] :return: A structured array with two fields: - "joints": A string field containing the names of the joints. - - "values": An Int32Array containing the values corresponding to the joints. + - "values": An Int32Array containing the values corresponding to the + joints. :rtype: pa.StructArray :raises ValueError: If lengths of joints and values do not match. @@ -46,14 +48,16 @@ def wrap_joints_and_values( values = [100, 200, 300] struct_array = wrap_joints_and_values(joints, values) - This example wraps the given joints and their corresponding values into a structured array. + This example wraps the given joints and their corresponding values into a structured + array. Another example with a single integer value: joints = ["shoulder_pan", "shoulder_lift", "elbow_flex"] value = 150 struct_array = wrap_joints_and_values(joints, value) - This example broadcasts the single integer value to all joints and wraps them into a structured array. + This example broadcasts the single integer value to all joints and wraps them into a + structured array. """ if isinstance(values, int): @@ -71,7 +75,9 @@ def wrap_joints_and_values( mask = values.is_null() return pa.StructArray.from_arrays( - arrays=[joints, values], names=["joints", "values"], mask=mask, + arrays=[joints, values], + names=["joints", "values"], + mask=mask, ).drop_null() @@ -248,8 +254,8 @@ def write(self, data_name: str, data: pa.StructArray): ] else: raise NotImplementedError( - f"Value of the number of bytes to be sent is expected to be in [1, 2, 4], but {packet_bytes_size} " - f"is provided instead.", + f"Value of the number of bytes to be sent is expected to be in " + f"[1, 2, 4], but {packet_bytes_size} is provided instead.", ) if init_group: @@ -260,8 +266,8 @@ def write(self, data_name: str, data: pa.StructArray): comm = self.group_writers[group_key].txPacket() if comm != COMM_SUCCESS: raise ConnectionError( - f"Write failed due to communication error on port {self.port} for group_key {group_key}: " - f"{self.packet_handler.getTxRxResult(comm)}", + f"Write failed due to communication error on port {self.port} for " + f"group_key {group_key}: {self.packet_handler.getTxRxResult(comm)}", ) def read(self, data_name: str, motor_names: pa.Array) -> pa.StructArray: @@ -291,14 +297,16 @@ def read(self, data_name: str, motor_names: pa.Array) -> pa.StructArray: comm = self.group_readers[group_key].txRxPacket() if comm != COMM_SUCCESS: raise ConnectionError( - f"Read failed due to communication error on port {self.port} for group_key {group_key}: " - f"{self.packet_handler.getTxRxResult(comm)}", + f"Read failed due to communication error on port {self.port} for " + f"group_key {group_key}: {self.packet_handler.getTxRxResult(comm)}", ) values = pa.array( [ self.group_readers[group_key].getData( - idx, packet_address, packet_bytes_size, + idx, + packet_address, + packet_bytes_size, ) for idx in motor_ids ], diff --git a/node-hub/dynamixel-client/dynamixel_client/main.py b/node-hub/dynamixel-client/dynamixel_client/main.py index fae0c375b..b7d532d61 100644 --- a/node-hub/dynamixel-client/dynamixel_client/main.py +++ b/node-hub/dynamixel-client/dynamixel_client/main.py @@ -1,6 +1,7 @@ """Dynamixel Client: This node is used to represent a chain of dynamixel motors. -It can be used to read positions, velocities, currents, and set goal positions and currents. +It can be used to read positions, velocities, currents, and set goal positions and +currents. """ import argparse @@ -28,8 +29,8 @@ def __init__(self, config: dict[str, any]): self.config["joints"] = pa.array(config["joints"], pa.string()) self.bus = DynamixelBus(config["port"], description) - # Set client configuration values, raise errors if the values are not set to indicate that the motors are not - # configured correctly + # Set client configuration values, raise errors if the values are not set to + # indicate that the motors are not configured correctly self.bus.write_torque_enable(self.config["torque"]) self.bus.write_goal_current(self.config["goal_current"]) @@ -130,8 +131,11 @@ def write_goal_current(self, goal_current: pa.StructArray): def main(): """Handle dynamic nodes, ask for the name of the node in the dataflow.""" parser = argparse.ArgumentParser( - description="Dynamixel Client: This node is used to represent a chain of dynamixel motors. It can be used to " - "read positions, velocities, currents, and set goal positions and currents.", + description=( + "Dynamixel Client: This node is used to represent a chain of dynamixel " + "motors. It can be used to read positions, velocities, currents, and set " + "goal positions and currents." + ), ) parser.add_argument( @@ -160,8 +164,8 @@ def main(): # Check if port is set if not os.environ.get("PORT") and args.port is None: raise ValueError( - "The port is not set. Please set the port of the dynamixel motors in the environment variables or as an " - "argument.", + "The port is not set. Please set the port of the dynamixel motors in the " + "environment variables or as an argument.", ) port = os.environ.get("PORT") if args.port is None else args.port @@ -169,8 +173,8 @@ def main(): # Check if config is set if not os.environ.get("CONFIG") and args.config is None: raise ValueError( - "The configuration is not set. Please set the configuration of the dynamixel motors in the environment " - "variables or as an argument.", + "The configuration is not set. Please set the configuration of the " + "dynamixel motors in the environment variables or as an argument.", ) with open(os.environ.get("CONFIG") if args.config is None else args.config) as file: @@ -202,7 +206,8 @@ def main(): "goal_current": wrap_joints_and_values( pa.array(config.keys(), pa.string()), pa.array( - [config[joint]["goal_current"] for joint in joints], type=pa.uint32(), + [config[joint]["goal_current"] for joint in joints], + type=pa.uint32(), ), ), "P": wrap_joints_and_values( diff --git a/node-hub/dynamixel-client/pyproject.toml b/node-hub/dynamixel-client/pyproject.toml index 958a921a2..225cedfda 100644 --- a/node-hub/dynamixel-client/pyproject.toml +++ b/node-hub/dynamixel-client/pyproject.toml @@ -32,4 +32,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/dynamixel-client/tests/test_dynamixel_client.py b/node-hub/dynamixel-client/tests/test_dynamixel_client.py index 09b067cf3..70f6729d4 100644 --- a/node-hub/dynamixel-client/tests/test_dynamixel_client.py +++ b/node-hub/dynamixel-client/tests/test_dynamixel_client.py @@ -9,6 +9,7 @@ def test_pass(): # def test_import_main(): # from dynamixel_client.main import main -# Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. +# Check that everything is working, and catch dora Runtime Exception as we're not +# running in a dora dataflow. # with pytest.raises(RuntimeError): # main() diff --git a/node-hub/feetech-client/feetech_client/bus.py b/node-hub/feetech-client/feetech_client/bus.py index 6e42d4db9..3376de937 100644 --- a/node-hub/feetech-client/feetech_client/bus.py +++ b/node-hub/feetech-client/feetech_client/bus.py @@ -1,4 +1,5 @@ """TODO: Add docstring.""" + import enum from typing import Union @@ -105,9 +106,9 @@ def __init__(self, port: str, description: dict[str, (np.uint8, str)]): """Args:-. port: the serial port to connect to the Feetech bus - description: a dictionary containing the description of the motors connected to the bus. The keys are the - motor names and the values are tuples containing the motor id and the motor model. - + description: a dictionary containing the description of the motors connected to + the bus. The keys are the motor names and the values are tuples containing the + motor id and the motor model. """ self.port = port self.descriptions = description @@ -193,8 +194,8 @@ def write(self, data_name: str, data: pa.StructArray): ] else: raise NotImplementedError( - f"Value of the number of bytes to be sent is expected to be in [1, 2, 4], but {packet_bytes_size} " - f"is provided instead.", + f"Value of the number of bytes to be sent is expected to be in " + f"[1, 2, 4], but {packet_bytes_size} is provided instead.", ) if init_group: @@ -205,8 +206,8 @@ def write(self, data_name: str, data: pa.StructArray): comm = self.group_writers[group_key].txPacket() if comm != COMM_SUCCESS: raise ConnectionError( - f"Write failed due to communication error on port {self.port} for group_key {group_key}: " - f"{self.packet_handler.getTxRxResult(comm)}", + f"Write failed due to communication error on port {self.port} for " + f"group_key {group_key}: {self.packet_handler.getTxRxResult(comm)}", ) def read(self, data_name: str, motor_names: pa.Array) -> pa.StructArray: @@ -236,14 +237,16 @@ def read(self, data_name: str, motor_names: pa.Array) -> pa.StructArray: comm = self.group_readers[group_key].txRxPacket() if comm != COMM_SUCCESS: raise ConnectionError( - f"Read failed due to communication error on port {self.port} for group_key {group_key}: " - f"{self.packet_handler.getTxRxResult(comm)}", + f"Read failed due to communication error on port {self.port} for " + f"group_key {group_key}: {self.packet_handler.getTxRxResult(comm)}", ) values = pa.array( [ self.group_readers[group_key].getData( - idx, packet_address, packet_bytes_size, + idx, + packet_address, + packet_bytes_size, ) for idx in motor_ids ], diff --git a/node-hub/feetech-client/feetech_client/main.py b/node-hub/feetech-client/feetech_client/main.py index 14203334a..f66a4d003 100644 --- a/node-hub/feetech-client/feetech_client/main.py +++ b/node-hub/feetech-client/feetech_client/main.py @@ -1,4 +1,8 @@ -"""Feetech Client: This node is used to represent a chain of feetech motors. It can be used to read positions, velocities, currents, and set goal positions and currents.""" +"""Implement the Feetech Client. + +This node is used to represent a chain of feetech motors. It can be used to read +positions, velocities, currents, and set goal positions and currents. +""" import argparse import json @@ -24,8 +28,8 @@ def __init__(self, config: dict[str, any]): self.config["joints"] = pa.array(config["joints"], pa.string()) self.bus = FeetechBus(config["port"], description) - # Set client configuration values and raise errors if the values are not set to indicate that the motors are not - # configured correctly + # Set client configuration values and raise errors if the values are not set to + # indicate that the motors are not configured correctly self.bus.write_torque_enable(self.config["torque"]) @@ -107,9 +111,9 @@ def write_goal_position(self, goal_position: pa.StructArray): def main(): """Handle dynamic nodes, ask for the name of the node in the dataflow.""" parser = argparse.ArgumentParser( - description="Feetech Client: This node is used to represent a chain of feetech motors. " - "It can be used to read " - "positions, velocities, currents, and set goal positions and currents.", + description="Feetech Client: This node is used to represent a chain of feetech " + "motors. It can be used to read positions, velocities, currents, and set goal " + "positions and currents.", ) parser.add_argument( @@ -138,8 +142,8 @@ def main(): # Check if port is set if not os.environ.get("PORT") and args.port is None: raise ValueError( - "The port is not set. Please set the port of the feetech motors in the environment variables or as an " - "argument.", + "The port is not set. Please set the port of the feetech motors in the " + "environment variables or as an argument.", ) port = os.environ.get("PORT") if args.port is None else args.port @@ -147,8 +151,8 @@ def main(): # Check if config is set if not os.environ.get("CONFIG") and args.config is None: raise ValueError( - "The configuration is not set. Please set the configuration of the feetech motors in the environment " - "variables or as an argument.", + "The configuration is not set. Please set the configuration of the feetech " + "motors in the environment variables or as an argument.", ) with open(os.environ.get("CONFIG") if args.config is None else args.config) as file: diff --git a/node-hub/feetech-client/pyproject.toml b/node-hub/feetech-client/pyproject.toml index 678ef90d6..51b26db1a 100644 --- a/node-hub/feetech-client/pyproject.toml +++ b/node-hub/feetech-client/pyproject.toml @@ -33,4 +33,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/feetech-client/tests/test_feetech_client.py b/node-hub/feetech-client/tests/test_feetech_client.py index de98f7e79..7369f7ef4 100644 --- a/node-hub/feetech-client/tests/test_feetech_client.py +++ b/node-hub/feetech-client/tests/test_feetech_client.py @@ -9,6 +9,7 @@ def test_pass(): # def test_import_main(): # from feetech_client.main import main -# Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. +# Check that everything is working, and catch dora Runtime Exception as we're not +# running in a dora dataflow. # with pytest.raises(RuntimeError): # main() diff --git a/node-hub/gamepad/gamepad/main.py b/node-hub/gamepad/gamepad/main.py index 91b26ae6b..ef141531f 100644 --- a/node-hub/gamepad/gamepad/main.py +++ b/node-hub/gamepad/gamepad/main.py @@ -8,53 +8,55 @@ import pygame import pyarrow as pa + class Controller: """controller mapping.""" def __init__(self): """Change this according to your controller mapping. Currently Logitech F710.""" self.axisNames = { - 'LEFT-X': 0, - 'LEFT-Y': 1, - 'LT': 2, - 'RIGHT-X': 3, - 'RIGHT-Y': 4, - 'RT': 5, - 'DPAD-X': 6, - 'DPAD-Y': 7 + "LEFT-X": 0, + "LEFT-Y": 1, + "LT": 2, + "RIGHT-X": 3, + "RIGHT-Y": 4, + "RT": 5, + "DPAD-X": 6, + "DPAD-Y": 7, } self.buttonNames = { - 'A': 0, - 'B': 1, - 'X': 2, - 'Y': 3, - 'LB': 4, - 'RB': 5, - 'BACK': 6, - 'START': 7, - 'LOGITECH': 8, - 'LEFT-STICK': 9, - 'RIGHT-STICK': 10 + "A": 0, + "B": 1, + "X": 2, + "Y": 3, + "LB": 4, + "RB": 5, + "BACK": 6, + "START": 7, + "LOGITECH": 8, + "LEFT-STICK": 9, + "RIGHT-STICK": 10, } + def main(): node = Node("gamepad") - + pygame.init() pygame.joystick.init() - + if pygame.joystick.get_count() == 0: print("No gamepad found! Please connect your controller.") return - + joystick = pygame.joystick.Joystick(0) joystick.init() controller = Controller() - + max_linear_speed = 1.0 # Maximum speed in m/s max_angular_speed = 1.5 # Maximum angular speed in rad/s - + print("Gamepad Controls:") print("Left Stick Y-Axis: Forward/Backward") print("Left Stick X-Axis: Left/Right Turn") @@ -65,32 +67,24 @@ def main(): for event in node: pygame.event.pump() - forward = -joystick.get_axis(controller.axisNames['LEFT-Y']) - turn = -joystick.get_axis(controller.axisNames['LEFT-X']) - + forward = -joystick.get_axis(controller.axisNames["LEFT-Y"]) + turn = -joystick.get_axis(controller.axisNames["LEFT-X"]) + deadzone = 0.05 forward = 0.0 if abs(forward) < deadzone else forward turn = 0.0 if abs(turn) < deadzone else turn - + forward_speed = forward * max_linear_speed turn_speed = turn * max_angular_speed - - cmd_vel = [ - forward_speed, - 0.0, - 0.0, - 0.0, - 0.0, - turn_speed - ] - + + cmd_vel = [forward_speed, 0.0, 0.0, 0.0, 0.0, turn_speed] + node.send_output( output_id="cmd_vel", data=pa.array(cmd_vel, type=pa.float64()), - metadata={"type": "cmd_vel"} + metadata={"type": "cmd_vel"}, ) - except KeyboardInterrupt: print("\nExiting...") finally: @@ -100,7 +94,7 @@ def main(): node.send_output( output_id="cmd_vel", data=pa.array(zero_cmd, type=pa.float64()), - metadata={"type": "cmd_vel"} + metadata={"type": "cmd_vel"}, ) diff --git a/node-hub/gamepad/tests/test_gamepad.py b/node-hub/gamepad/tests/test_gamepad.py index c6df640aa..32f86471e 100644 --- a/node-hub/gamepad/tests/test_gamepad.py +++ b/node-hub/gamepad/tests/test_gamepad.py @@ -4,6 +4,7 @@ def test_import_main(): from gamepad.main import main - # Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/lebai-client/lebai_client/main.py b/node-hub/lebai-client/lebai_client/main.py index 4c692a7fb..c62af1df0 100644 --- a/node-hub/lebai-client/lebai_client/main.py +++ b/node-hub/lebai-client/lebai_client/main.py @@ -1,4 +1,5 @@ """TODO: Add docstring.""" + import json import os import time @@ -29,7 +30,8 @@ def save_json_file(file_path, data): lebai_sdk.init() ROBOT_IP = os.getenv( - "LEBAI_IP", "10.42.0.253", + "LEBAI_IP", + "10.42.0.253", ) # 设定机器人ip地址,需要根据机器人实际ip地址修改 diff --git a/node-hub/lebai-client/pyproject.toml b/node-hub/lebai-client/pyproject.toml index a7c8a83e7..06b02bd27 100644 --- a/node-hub/lebai-client/pyproject.toml +++ b/node-hub/lebai-client/pyproject.toml @@ -32,4 +32,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/lebai-client/test/test.py b/node-hub/lebai-client/test/test.py index 8937d4133..5fd8f59db 100644 --- a/node-hub/lebai-client/test/test.py +++ b/node-hub/lebai-client/test/test.py @@ -1,4 +1,5 @@ """TODO: Add docstring.""" + import lebai_sdk lebai_sdk.init() @@ -25,7 +26,11 @@ def main(): r = 0 # 交融半径 (m)。用于指定路径的平滑效果 lebai.movel( - cartesian_pose, a, v, t, r, + cartesian_pose, + a, + v, + t, + r, ) # 直线运动 https://help.lebai.ltd/sdk/motion.html#%E7%9B%B4%E7%BA%BF%E8%BF%90%E5%8A%A8 lebai.wait_move() # 等待运动完成 # scene_number = "10000" #需要调用的场景编号 diff --git a/node-hub/lebai-client/tests/test_lebai_client.py b/node-hub/lebai-client/tests/test_lebai_client.py index a507997bf..8e9e54be3 100644 --- a/node-hub/lebai-client/tests/test_lebai_client.py +++ b/node-hub/lebai-client/tests/test_lebai_client.py @@ -9,6 +9,7 @@ def test_pass(): # def test_import_main(): # from lebai_client.main import main -# Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. +# Check that everything is working, and catch dora Runtime Exception as we're not +# running in a dora dataflow. # with pytest.raises(RuntimeError): # main() diff --git a/node-hub/lerobot-dashboard/lerobot_dashboard/main.py b/node-hub/lerobot-dashboard/lerobot_dashboard/main.py index 2ddd742f4..3cf514682 100644 --- a/node-hub/lerobot-dashboard/lerobot_dashboard/main.py +++ b/node-hub/lerobot-dashboard/lerobot_dashboard/main.py @@ -1,4 +1,4 @@ -"""Following Dora node is a minimalistic interface that shows two images and text in a Pygame window.""" +"""A minimalistic interface that shows two images and text in a Pygame window.""" import argparse import os @@ -11,7 +11,10 @@ def main(): """Handle dynamic nodes, ask for the name of the node in the dataflow.""" parser = argparse.ArgumentParser( - description="LeRobot Record: This node is used to record episodes of a robot interacting with the environment.", + description=( + "LeRobot Record: This node is used to record episodes of a robot " + "interacting with the environment." + ), ) parser.add_argument( @@ -78,7 +81,9 @@ def main(): } image_left = pygame.image.frombuffer( - image["data"], (image["width"], image["height"]), "BGR", + image["data"], + (image["width"], image["height"]), + "BGR", ) elif event_id == "image_right": @@ -91,7 +96,9 @@ def main(): } image_right = pygame.image.frombuffer( - image["data"], (image["width"], image["height"]), "BGR", + image["data"], + (image["width"], image["height"]), + "BGR", ) elif event_id == "tick": diff --git a/node-hub/lerobot-dashboard/pyproject.toml b/node-hub/lerobot-dashboard/pyproject.toml index eee5fc2a5..7f0b66710 100644 --- a/node-hub/lerobot-dashboard/pyproject.toml +++ b/node-hub/lerobot-dashboard/pyproject.toml @@ -34,4 +34,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/lerobot-dashboard/tests/test_lerobot_dashboard.py b/node-hub/lerobot-dashboard/tests/test_lerobot_dashboard.py index b3cab3b79..b40b82e9a 100644 --- a/node-hub/lerobot-dashboard/tests/test_lerobot_dashboard.py +++ b/node-hub/lerobot-dashboard/tests/test_lerobot_dashboard.py @@ -9,6 +9,7 @@ def test_pass(): # def test_import_main(): # from lerobot_dashboard.main import main -# Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. +# Check that everything is working, and catch dora Runtime Exception as we're not +# running in a dora dataflow. # with pytest.raises(RuntimeError): # main() 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 57f13ea5c..e3804920f 100644 --- a/node-hub/llama-factory-recorder/llama_factory_recorder/main.py +++ b/node-hub/llama-factory-recorder/llama_factory_recorder/main.py @@ -19,9 +19,9 @@ def write_dict_to_json(file_path, key: str, new_data): """Write a dictionary to a JSON file. - If the JSON file already contains an object with the given key mapping to a list of entries, - the new data will be appended to that list. Otherwise, a new key is created with a list - containing the provided dictionary. + If the JSON file already contains an object with the given key mapping to a list of + entries, the new data will be appended to that list. Otherwise, a new key is created + with a list containing the provided dictionary. Parameters ---------- @@ -54,9 +54,13 @@ 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, + frame_dict: dict, + root_path, + llama_root_path, + jsonl_file, + messages, ): - """Save an image from a NumPy array and add a new JSON object as a line to a JSONL file. + """Save an image from a NumPy array and add a new 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. @@ -74,7 +78,8 @@ def save_image_and_add_to_json( 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. + The image is saved as a PNG file, and the JSONL entry includes the 'messages' and + 'images' keys. """ # Create the root directory if it doesn't exist @@ -114,7 +119,8 @@ def main(): node = Node() assert os.getenv("LLAMA_FACTORY_ROOT_PATH"), ( - "LLAMA_FACTORY_ROOT_PATH is not set, Either git clone the repo or set the environment variable" + "LLAMA_FACTORY_ROOT_PATH is not set, Either git clone the repo or set the " + "environment variable" ) llama_factory_root_path = Path(os.getenv("LLAMA_FACTORY_ROOT_PATH")) / "data" diff --git a/node-hub/llama-factory-recorder/pyproject.toml b/node-hub/llama-factory-recorder/pyproject.toml index 4a894bb2c..a309d32a8 100644 --- a/node-hub/llama-factory-recorder/pyproject.toml +++ b/node-hub/llama-factory-recorder/pyproject.toml @@ -32,4 +32,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] 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 70cdff6ab..3d77a3fba 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 @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/mujoco-client/mujoco_client/main.py b/node-hub/mujoco-client/mujoco_client/main.py index d6543f336..3924414f8 100644 --- a/node-hub/mujoco-client/mujoco_client/main.py +++ b/node-hub/mujoco-client/mujoco_client/main.py @@ -1,4 +1,8 @@ -"""Mujoco Client: This node is used to represent simulated robot, it can be used to read virtual positions, or can be controlled.""" +"""Implements the Mujoco Client node. + +This node is used to represent simulated robot, it can be used to read virtual +positions, or can be controlled. +""" import argparse import json @@ -90,8 +94,8 @@ def write_goal_position(self, goal_position_with_joints): def main(): """Handle dynamic nodes, ask for the name of the node in the dataflow.""" parser = argparse.ArgumentParser( - description="MujoCo Client: This node is used to represent a MuJoCo simulation. It can be used instead of a " - "follower arm to test the dataflow.", + description="MujoCo Client: This node is used to represent a MuJoCo " + "simulation. It can be used instead of a follower arm to test the dataflow.", ) parser.add_argument( @@ -109,7 +113,10 @@ def main(): ) parser.add_argument( - "--config", type=str, help="The configuration of the joints.", default=None, + "--config", + type=str, + help="The configuration of the joints.", + default=None, ) args = parser.parse_args() @@ -124,8 +131,8 @@ def main(): # Check if config is set if not os.environ.get("CONFIG") and args.config is None: raise ValueError( - "The configuration is not set. Please set the configuration of the simulated motors in the environment " - "variables or as an argument.", + "The configuration is not set. Please set the configuration of the " + "simulated motors in the environment variables or as an argument.", ) with open(os.environ.get("CONFIG") if args.config is None else args.config) as file: diff --git a/node-hub/mujoco-client/pyproject.toml b/node-hub/mujoco-client/pyproject.toml index a99dda7ee..c2586743d 100644 --- a/node-hub/mujoco-client/pyproject.toml +++ b/node-hub/mujoco-client/pyproject.toml @@ -33,4 +33,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/mujoco-client/tests/test_mujoco_client.py b/node-hub/mujoco-client/tests/test_mujoco_client.py index 5b4f371af..d05398950 100644 --- a/node-hub/mujoco-client/tests/test_mujoco_client.py +++ b/node-hub/mujoco-client/tests/test_mujoco_client.py @@ -9,6 +9,7 @@ def test_pass(): # def test_import_main(): # from mujoco_client.main import main -# Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. +# Check that everything is working, and catch dora Runtime Exception as we're not +# running in a dora dataflow. # with pytest.raises(RuntimeError): # main() diff --git a/node-hub/opencv-plot/opencv_plot/main.py b/node-hub/opencv-plot/opencv_plot/main.py index 78b26756d..17f3d893f 100644 --- a/node-hub/opencv-plot/opencv_plot/main.py +++ b/node-hub/opencv-plot/opencv_plot/main.py @@ -89,10 +89,14 @@ def yuv420p_to_bgr_opencv(yuv_array, width, height): def main(): - # Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables. + # 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.", + description=( + "OpenCV Plotter: This node is used to plot text and bounding boxes on an " + "image." + ), ) parser.add_argument( diff --git a/node-hub/opencv-plot/pyproject.toml b/node-hub/opencv-plot/pyproject.toml index 6b4412a40..dcf9c6b0d 100644 --- a/node-hub/opencv-plot/pyproject.toml +++ b/node-hub/opencv-plot/pyproject.toml @@ -34,4 +34,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/opencv-plot/tests/test_opencv_plot.py b/node-hub/opencv-plot/tests/test_opencv_plot.py index 817b123a5..13ee2e629 100644 --- a/node-hub/opencv-plot/tests/test_opencv_plot.py +++ b/node-hub/opencv-plot/tests/test_opencv_plot.py @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() 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 abfc08d17..4bd012416 100644 --- a/node-hub/opencv-video-capture/opencv_video_capture/main.py +++ b/node-hub/opencv-video-capture/opencv_video_capture/main.py @@ -15,10 +15,13 @@ def main(): - # Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables. + # 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.", + description=( + "OpenCV Video Capture: This node is used to capture video from a camera." + ), ) parser.add_argument( @@ -32,7 +35,10 @@ def main(): "--path", type=int, required=False, - help="The path of the device to capture (e.g. /dev/video1, or an index like 0, 1...", + help=( + "The path of the device to capture (e.g. /dev/video1, or an index like " + "0, 1...)" + ), default=0, ) parser.add_argument( diff --git a/node-hub/opencv-video-capture/pyproject.toml b/node-hub/opencv-video-capture/pyproject.toml index 9baee6ea5..36b243a9c 100644 --- a/node-hub/opencv-video-capture/pyproject.toml +++ b/node-hub/opencv-video-capture/pyproject.toml @@ -28,4 +28,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] 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 5ba96e8cb..3484f0c64 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 @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/pyarrow-assert/pyarrow_assert/main.py b/node-hub/pyarrow-assert/pyarrow_assert/main.py index dfa0414b1..0d79329d1 100644 --- a/node-hub/pyarrow-assert/pyarrow_assert/main.py +++ b/node-hub/pyarrow-assert/pyarrow_assert/main.py @@ -9,7 +9,8 @@ def main(): - # Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables. + # 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") diff --git a/node-hub/pyarrow-assert/pyproject.toml b/node-hub/pyarrow-assert/pyproject.toml index 8a3ef6991..e14aeecf6 100644 --- a/node-hub/pyarrow-assert/pyproject.toml +++ b/node-hub/pyarrow-assert/pyproject.toml @@ -29,4 +29,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/pyarrow-assert/tests/test_pyarrow_assert.py b/node-hub/pyarrow-assert/tests/test_pyarrow_assert.py index dc1b395f2..b0cf42bf9 100644 --- a/node-hub/pyarrow-assert/tests/test_pyarrow_assert.py +++ b/node-hub/pyarrow-assert/tests/test_pyarrow_assert.py @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/pyarrow-sender/pyarrow_sender/main.py b/node-hub/pyarrow-sender/pyarrow_sender/main.py index f584380cc..3633e2290 100644 --- a/node-hub/pyarrow-sender/pyarrow_sender/main.py +++ b/node-hub/pyarrow-sender/pyarrow_sender/main.py @@ -9,7 +9,8 @@ def main(): - # Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables. + # 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") @@ -38,7 +39,8 @@ def main(): if data is None: raise ValueError( - "No data provided. Please specify `DATA` environment argument or as `--data` argument", + "No data provided. Please specify `DATA` environment argument or as " + "`--data` argument", ) try: data = ast.literal_eval(data) diff --git a/node-hub/pyarrow-sender/pyproject.toml b/node-hub/pyarrow-sender/pyproject.toml index e3d8f9bc4..24e3157d5 100644 --- a/node-hub/pyarrow-sender/pyproject.toml +++ b/node-hub/pyarrow-sender/pyproject.toml @@ -29,4 +29,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/pyarrow-sender/tests/test_pyarrow_sender.py b/node-hub/pyarrow-sender/tests/test_pyarrow_sender.py index bfc7e2924..9fc8dd24f 100644 --- a/node-hub/pyarrow-sender/tests/test_pyarrow_sender.py +++ b/node-hub/pyarrow-sender/tests/test_pyarrow_sender.py @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/replay-client/pyproject.toml b/node-hub/replay-client/pyproject.toml index 4d1d0be62..43f4af14b 100644 --- a/node-hub/replay-client/pyproject.toml +++ b/node-hub/replay-client/pyproject.toml @@ -32,4 +32,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/replay-client/replay_client/main.py b/node-hub/replay-client/replay_client/main.py index 7186bd773..e906d9dab 100644 --- a/node-hub/replay-client/replay_client/main.py +++ b/node-hub/replay-client/replay_client/main.py @@ -1,6 +1,7 @@ -"""Replay Client: This node is used to represent a leader robot and send a sequence of goals to the dataflow,. +"""Implement the Replay Client. -reading a dataset of actions and joints from a specific episode. +This node is used to represent a leader robot and send a sequence of goals to the +dataflow, reading a dataset of actions and joints from a specific episode. """ import argparse @@ -78,7 +79,10 @@ def pull_position(self, node, metadata) -> bool: def main(): """Handle dynamic nodes, ask for the name of the node in the dataflow.""" parser = argparse.ArgumentParser( - description="Replay Client: This node is used to replay a sequence of goals for a followee robot.", + description=( + "Replay Client: This node is used to replay a sequence of goals for a " + "followee robot." + ), ) parser.add_argument( diff --git a/node-hub/replay-client/tests/test_replay_client.py b/node-hub/replay-client/tests/test_replay_client.py index d612f13d8..d67b36e8b 100644 --- a/node-hub/replay-client/tests/test_replay_client.py +++ b/node-hub/replay-client/tests/test_replay_client.py @@ -9,6 +9,7 @@ def test_pass(): # def test_import_main(): # from replay_client.main import main -# Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. +# Check that everything is working, and catch dora Runtime Exception as we're not +# running in a dora dataflow. # with pytest.raises(RuntimeError): # main() diff --git a/node-hub/terminal-input/pyproject.toml b/node-hub/terminal-input/pyproject.toml index 78d9503b6..e57e9ef18 100644 --- a/node-hub/terminal-input/pyproject.toml +++ b/node-hub/terminal-input/pyproject.toml @@ -29,4 +29,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/terminal-input/terminal_input/main.py b/node-hub/terminal-input/terminal_input/main.py index 86c305b54..baf72e818 100644 --- a/node-hub/terminal-input/terminal_input/main.py +++ b/node-hub/terminal-input/terminal_input/main.py @@ -12,7 +12,8 @@ def main(): - # Handle dynamic nodes, ask for the name of the node in the dataflow, and the same values as the ENV variables. + # 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") @@ -60,7 +61,12 @@ def main(): print("Passing input as string") if isinstance(data, list): data = pa.array(data) # initialize pyarrow array - elif isinstance(data, str) or isinstance(data, int) or isinstance(data, float) or isinstance(data, dict): + elif ( + isinstance(data, str) + or isinstance(data, int) + or isinstance(data, float) + or isinstance(data, dict) + ): data = pa.array([data]) else: data = pa.array(data) # initialize pyarrow array @@ -78,7 +84,12 @@ def main(): print("Passing input as string") if isinstance(data, list): data = pa.array(data) # initialize pyarrow array - elif isinstance(data, str) or isinstance(data, int) or isinstance(data, float) or isinstance(data, dict): + elif ( + isinstance(data, str) + or isinstance(data, int) + or isinstance(data, float) + or isinstance(data, dict) + ): data = pa.array([data]) else: data = pa.array(data) # initialize pyarrow array diff --git a/node-hub/terminal-input/tests/test_terminal_input.py b/node-hub/terminal-input/tests/test_terminal_input.py index f2913c0e6..61be0699a 100644 --- a/node-hub/terminal-input/tests/test_terminal_input.py +++ b/node-hub/terminal-input/tests/test_terminal_input.py @@ -7,6 +7,7 @@ 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. + # Check that everything is working, and catch dora Runtime Exception as we're not + # running in a dora dataflow. with pytest.raises(RuntimeError): main() diff --git a/node-hub/video-encoder/pyproject.toml b/node-hub/video-encoder/pyproject.toml index 6e559423e..7f4c6fdbb 100644 --- a/node-hub/video-encoder/pyproject.toml +++ b/node-hub/video-encoder/pyproject.toml @@ -34,4 +34,5 @@ extend-select = [ "NPY", # Ruff's NPY rule "N", # Ruff's N rule "I", # Ruff's I rule + "E", # Ruff's E rule ] diff --git a/node-hub/video-encoder/tests/test_video_encoder.py b/node-hub/video-encoder/tests/test_video_encoder.py index 6d3f7bedc..ae0f90c65 100644 --- a/node-hub/video-encoder/tests/test_video_encoder.py +++ b/node-hub/video-encoder/tests/test_video_encoder.py @@ -9,6 +9,7 @@ def test_pass(): # def test_import_main(): # from video_encoder.main import main -# Check that everything is working, and catch dora Runtime Exception as we're not running in a dora dataflow. +# Check that everything is working, and catch dora Runtime Exception as we're not +# running in a dora dataflow. # with pytest.raises(RuntimeError): # main() diff --git a/node-hub/video-encoder/video_encoder/main.py b/node-hub/video-encoder/video_encoder/main.py index 1f9355ed8..69e85f87b 100644 --- a/node-hub/video-encoder/video_encoder/main.py +++ b/node-hub/video-encoder/video_encoder/main.py @@ -1,4 +1,5 @@ """TODO : Doc String.""" + import argparse import os from pathlib import Path @@ -13,7 +14,10 @@ def main(): """Handle dynamic nodes, ask for the name of the node in the dataflow.""" parser = argparse.ArgumentParser( - description="Video Encoder: This node is used to record episodes of a robot interacting with the environment.", + description=( + "Video Encoder: This node is used to record episodes of a robot " + "interacting with the environment." + ), ) parser.add_argument( @@ -116,7 +120,10 @@ def main(): .option("y") .input(str(out_dir / "frame_%06d.png"), f="image2", r=fps) .output( - str(video_path), vcodec="libx264", g=2, pix_fmt="yuv444p", + str(video_path), + vcodec="libx264", + g=2, + pix_fmt="yuv444p", ) )