From 752bf2e514fc62e4e9f3e3cf080471f3c6636343 Mon Sep 17 00:00:00 2001 From: Paul Nechifor Date: Sun, 15 Mar 2026 07:19:48 +0200 Subject: [PATCH] fix(old-scripts): remove --- bin/filter-errors-after-date | 77 -------------- bin/filter-errors-for-user | 63 ------------ bin/mypy-ros | 44 -------- bin/re-ignore-mypy.py | 150 ---------------------------- bin/robot-debugger | 36 ------- dimos/robot/utils/README.md | 38 ------- dimos/robot/utils/robot_debugger.py | 59 ----------- 7 files changed, 467 deletions(-) delete mode 100755 bin/filter-errors-after-date delete mode 100755 bin/filter-errors-for-user delete mode 100755 bin/mypy-ros delete mode 100755 bin/re-ignore-mypy.py delete mode 100755 bin/robot-debugger delete mode 100644 dimos/robot/utils/README.md delete mode 100644 dimos/robot/utils/robot_debugger.py diff --git a/bin/filter-errors-after-date b/bin/filter-errors-after-date deleted file mode 100755 index 03c7de0ca7..0000000000 --- a/bin/filter-errors-after-date +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env python3 - -# Used to filter errors to only show lines committed on or after a specific date -# Can be chained with filter-errors-for-user - -from datetime import datetime -import re -import subprocess -import sys - -_blame = {} - - -def _is_after_date(file, line_no, cutoff_date): - if file not in _blame: - _blame[file] = _get_git_blame_dates_for_file(file) - line_date = _blame[file].get(line_no) - if not line_date: - return False - return line_date >= cutoff_date - - -def _get_git_blame_dates_for_file(file_name): - try: - result = subprocess.run( - ["git", "blame", "--date=short", file_name], - capture_output=True, - text=True, - check=True, - ) - - blame_map = {} - # Each line looks like: ^abc123 (Author Name 2024-01-01 1) code - blame_pattern = re.compile(r"^[^\(]+\([^\)]+(\d{4}-\d{2}-\d{2})") - - for i, line in enumerate(result.stdout.split("\n")): - if not line: - continue - match = blame_pattern.match(line) - if match: - date_str = match.group(1) - blame_map[str(i + 1)] = date_str - - return blame_map - except subprocess.CalledProcessError: - return {} - - -def main(): - if len(sys.argv) != 2: - print("Usage: filter-errors-after-date ", file=sys.stderr) - print(" Example: filter-errors-after-date 2025-10-04", file=sys.stderr) - sys.exit(1) - - cutoff_date = sys.argv[1] - - try: - datetime.strptime(cutoff_date, "%Y-%m-%d") - except ValueError: - print(f"Error: Invalid date format '{cutoff_date}'. Use YYYY-MM-DD", file=sys.stderr) - sys.exit(1) - - for line in sys.stdin.readlines(): - split = re.findall(r"^([^:]+):(\d+):(.*)", line) - if not split or len(split[0]) != 3: - continue - - file, line_no = split[0][:2] - if not file.startswith("dimos/"): - continue - - if _is_after_date(file, line_no, cutoff_date): - print(":".join(split[0])) - - -if __name__ == "__main__": - main() diff --git a/bin/filter-errors-for-user b/bin/filter-errors-for-user deleted file mode 100755 index 045b30b293..0000000000 --- a/bin/filter-errors-for-user +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python3 - -# Used when running `./bin/mypy-strict --for-me` - -import re -import subprocess -import sys - -_blame = {} - - -def _is_for_user(file, line_no, user_email): - if file not in _blame: - _blame[file] = _get_git_blame_for_file(file) - return _blame[file][line_no] == user_email - - -def _get_git_blame_for_file(file_name): - try: - result = subprocess.run( - ["git", "blame", "--show-email", "-e", file_name], - capture_output=True, - text=True, - check=True, - ) - - blame_map = {} - # Each line looks like: ^abc123 ( 2024-01-01 12:00:00 +0000 1) code - blame_pattern = re.compile(r"^[^\(]+\(<([^>]+)>") - - for i, line in enumerate(result.stdout.split("\n")): - if not line: - continue - match = blame_pattern.match(line) - if match: - email = match.group(1) - blame_map[str(i + 1)] = email - - return blame_map - except subprocess.CalledProcessError: - return {} - - -def main(): - if len(sys.argv) != 2: - print("Usage: filter-errors-for-user ", file=sys.stderr) - sys.exit(1) - - user_email = sys.argv[1] - - for line in sys.stdin.readlines(): - split = re.findall(r"^([^:]+):(\d+):(.*)", line) - if not split or len(split[0]) != 3: - continue - file, line_no = split[0][:2] - if not file.startswith("dimos/"): - continue - if _is_for_user(file, line_no, user_email): - print(":".join(split[0])) - - -if __name__ == "__main__": - main() diff --git a/bin/mypy-ros b/bin/mypy-ros deleted file mode 100755 index d46d6a542e..0000000000 --- a/bin/mypy-ros +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" - -mypy_args=(--show-error-codes --hide-error-context --no-pretty) - -main() { - cd "$ROOT" - - if [ -z "$(docker images -q dimos-ros-dev)" ]; then - (cd docker/ros; docker build -t dimos-ros .) - docker build -t dimos-ros-python --build-arg FROM_IMAGE=dimos-ros -f docker/python/Dockerfile . - docker build -t dimos-ros-dev --build-arg FROM_IMAGE=dimos-ros-python -f docker/dev/Dockerfile . - fi - - sudo rm -fr .mypy_cache_docker - rm -fr .mypy_cache_local - - { - mypy_docker & - mypy_local & - wait - } | sort -u -} - -cleaned() { - grep ': error: ' | sort -} - -mypy_docker() { - docker run --rm -v $(pwd):/app -w /app dimos-ros-dev bash -c " - source /opt/ros/humble/setup.bash && - MYPYPATH=/opt/ros/humble/lib/python3.10/site-packages mypy ${mypy_args[*]} --cache-dir .mypy_cache_docker dimos - " | cleaned -} - -mypy_local() { - MYPYPATH=/opt/ros/jazzy/lib/python3.12/site-packages \ - mypy "${mypy_args[@]}" --cache-dir .mypy_cache_local dimos | cleaned -} - -main "$@" diff --git a/bin/re-ignore-mypy.py b/bin/re-ignore-mypy.py deleted file mode 100755 index 7d71bcd986..0000000000 --- a/bin/re-ignore-mypy.py +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright 2026 Dimensional Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from collections import defaultdict -from pathlib import Path -import re -import subprocess - - -def remove_type_ignore_comments(directory: Path) -> None: - # Pattern matches "# type: ignore" with optional error codes in brackets. - # Captures any trailing comment after `type: ignore`. - type_ignore_pattern = re.compile(r"(\s*)#\s*type:\s*ignore(?:\[[^\]]*\])?(\s*#.*)?") - - for py_file in directory.rglob("*.py"): - try: - content = py_file.read_text() - except Exception: - continue - - new_lines = [] - modified = False - - for line in content.splitlines(keepends=True): - match = type_ignore_pattern.search(line) - if match: - before = line[: match.start()] - trailing_comment = match.group(2) - - if trailing_comment: - new_line = before + match.group(1) + trailing_comment.lstrip() - else: - new_line = before - - if line.endswith("\n"): - new_line = new_line.rstrip() + "\n" - else: - new_line = new_line.rstrip() - new_lines.append(new_line) - modified = True - else: - new_lines.append(line) - - if modified: - try: - py_file.write_text("".join(new_lines)) - except Exception: - pass - - -def run_mypy(root: Path) -> str: - result = subprocess.run( - [str(root / "bin" / "mypy-ros")], - capture_output=True, - text=True, - cwd=root, - ) - return result.stdout + result.stderr - - -def parse_mypy_errors(output: str) -> dict[Path, dict[int, list[str]]]: - error_pattern = re.compile(r"^(.+):(\d+): error: .+\[([^\]]+)\]\s*$") - errors: dict[Path, dict[int, list[str]]] = defaultdict(lambda: defaultdict(list)) - - for line in output.splitlines(): - match = error_pattern.match(line) - if match: - file_path = Path(match.group(1)) - line_num = int(match.group(2)) - error_code = match.group(3) - if error_code not in errors[file_path][line_num]: - errors[file_path][line_num].append(error_code) - - return errors - - -def add_type_ignore_comments(root: Path, errors: dict[Path, dict[int, list[str]]]) -> None: - comment_pattern = re.compile(r"^([^#]*?)( #.*)$") - - for file_path, line_errors in errors.items(): - full_path = root / file_path - if not full_path.exists(): - continue - - try: - content = full_path.read_text() - except Exception: - continue - - lines = content.splitlines(keepends=True) - modified = False - - for line_num, error_codes in line_errors.items(): - if line_num < 1 or line_num > len(lines): - continue - - idx = line_num - 1 - line = lines[idx] - codes_str = ", ".join(sorted(error_codes)) - ignore_comment = f" # type: ignore[{codes_str}]" - - has_newline = line.endswith("\n") - line_content = line.rstrip("\n") - - comment_match = comment_pattern.match(line_content) - if comment_match: - code_part = comment_match.group(1) - existing_comment = comment_match.group(2) - new_line = code_part + ignore_comment + existing_comment - else: - new_line = line_content + ignore_comment - - if has_newline: - new_line += "\n" - - lines[idx] = new_line - modified = True - - if modified: - try: - full_path.write_text("".join(lines)) - except Exception: - pass - - -def main() -> None: - root = Path(__file__).parent.parent - dimos_dir = root / "dimos" - - remove_type_ignore_comments(dimos_dir) - mypy_output = run_mypy(root) - errors = parse_mypy_errors(mypy_output) - add_type_ignore_comments(root, errors) - - -if __name__ == "__main__": - main() diff --git a/bin/robot-debugger b/bin/robot-debugger deleted file mode 100755 index 165a546a0c..0000000000 --- a/bin/robot-debugger +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash - -# Control the robot with a python shell (for debugging). -# -# You have to start the robot run file with: -# -# ROBOT_DEBUGGER=true python -# -# And now start this script -# -# $ ./bin/robot-debugger -# >>> robot.explore() -# True -# >>> - - -exec python -i <(cat < 0: - print("\nConnected.") - break - except ConnectionRefusedError: - print("Not started yet. Trying again...") - time.sleep(2) -else: - print("Failed to connect. Is it started?") - exit(1) - -robot = c.root.robot() -EOF -) diff --git a/dimos/robot/utils/README.md b/dimos/robot/utils/README.md deleted file mode 100644 index 5a84b20c4a..0000000000 --- a/dimos/robot/utils/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# Robot Utils - -## RobotDebugger - -The `RobotDebugger` provides a way to debug a running robot through the python shell. - -Requirements: - -```bash -pip install rpyc -``` - -### Usage - -1. **Add to your robot application:** - ```python - from dimos.robot.utils.robot_debugger import RobotDebugger - - # In your robot application's context manager or main loop: - with RobotDebugger(robot): - # Your robot code here - pass - - # Or better, with an exit stack. - exit_stack.enter_context(RobotDebugger(robot)) - ``` - -2. **Start your robot with debugging enabled:** - ```bash - ROBOT_DEBUGGER=true python your_robot_script.py - ``` - -3. **Open the python shell:** - ```bash - ./bin/robot-debugger - >>> robot.explore() - True - ``` diff --git a/dimos/robot/utils/robot_debugger.py b/dimos/robot/utils/robot_debugger.py deleted file mode 100644 index c7f3cd7291..0000000000 --- a/dimos/robot/utils/robot_debugger.py +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright 2025-2026 Dimensional Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import os - -from dimos.core.resource import Resource -from dimos.utils.logging_config import setup_logger - -logger = setup_logger() - - -class RobotDebugger(Resource): - def __init__(self, robot) -> None: # type: ignore[no-untyped-def] - self._robot = robot - self._threaded_server = None - - def start(self) -> None: - if not os.getenv("ROBOT_DEBUGGER"): - return - - try: - import rpyc # type: ignore[import-not-found] - from rpyc.utils.server import ThreadedServer # type: ignore[import-not-found] - except ImportError: - return - - logger.info( - "Starting the robot debugger. You can open a python shell with `./bin/robot-debugger`" - ) - - robot = self._robot - - class RobotService(rpyc.Service): # type: ignore[misc] - def exposed_robot(self): # type: ignore[no-untyped-def] - return robot - - self._threaded_server = ThreadedServer( - RobotService, - port=18861, - protocol_config={ - "allow_all_attrs": True, - }, - ) - self._threaded_server.start() # type: ignore[attr-defined] - - def stop(self) -> None: - if self._threaded_server: - self._threaded_server.close()