From 0f30eb83c87587f1b1b1e79b0a6536e148533039 Mon Sep 17 00:00:00 2001 From: openhands Date: Sun, 29 Dec 2024 01:14:09 +0000 Subject: [PATCH 1/4] Fix issue #5890: Add an automatic check of version consistency in documentation --- .github/scripts/check_version_consistency.py | 61 ++++++++++++++++++++ .github/workflows/lint.yml | 13 +++++ 2 files changed, 74 insertions(+) create mode 100644 .github/scripts/check_version_consistency.py diff --git a/.github/scripts/check_version_consistency.py b/.github/scripts/check_version_consistency.py new file mode 100644 index 000000000000..5e859eb30df5 --- /dev/null +++ b/.github/scripts/check_version_consistency.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 +import os +import re +import sys +from typing import Set, Tuple + +def find_version_references(directory: str) -> Tuple[Set[str], Set[str]]: + openhands_versions = set() + runtime_versions = set() + + version_pattern_openhands = re.compile(r'openhands:0\.(\d{2})') + version_pattern_runtime = re.compile(r'runtime:0\.(\d{2})') + + for root, _, files in os.walk(directory): + # Skip .git directory + if '.git' in root: + continue + + for file in files: + if file.endswith(('.md', '.yml', '.yaml', '.txt', '.html', '.py', '.js', '.ts')): + file_path = os.path.join(root, file) + try: + with open(file_path, 'r', encoding='utf-8') as f: + content = f.read() + + # Find all openhands version references + matches = version_pattern_openhands.findall(content) + openhands_versions.update(matches) + + # Find all runtime version references + matches = version_pattern_runtime.findall(content) + runtime_versions.update(matches) + except Exception as e: + print(f"Error reading {file_path}: {e}", file=sys.stderr) + + return openhands_versions, runtime_versions + +def main(): + repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) + openhands_versions, runtime_versions = find_version_references(repo_root) + + exit_code = 0 + + if len(openhands_versions) > 1: + print("Error: Multiple openhands versions found:", file=sys.stderr) + print("Found versions:", sorted(openhands_versions), file=sys.stderr) + exit_code = 1 + elif len(openhands_versions) == 0: + print("Warning: No openhands version references found", file=sys.stderr) + + if len(runtime_versions) > 1: + print("Error: Multiple runtime versions found:", file=sys.stderr) + print("Found versions:", sorted(runtime_versions), file=sys.stderr) + exit_code = 1 + elif len(runtime_versions) == 0: + print("Warning: No runtime version references found", file=sys.stderr) + + sys.exit(exit_code) + +if __name__ == '__main__': + main() diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1bfc8c91c6a4..789a938e1d7e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -53,3 +53,16 @@ jobs: run: pip install pre-commit==3.7.0 - name: Run pre-commit hooks run: pre-commit run --files openhands/**/* evaluation/**/* tests/**/* --show-diff-on-failure --config ./dev_config/python/.pre-commit-config.yaml + + # Check version consistency across documentation + check-version-consistency: + name: Check version consistency + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up python + uses: actions/setup-python@v5 + with: + python-version: 3.12 + - name: Run version consistency check + run: .github/scripts/check_version_consistency.py From 6f47919819b5a6a159cb7a1211d857eeb2b42485 Mon Sep 17 00:00:00 2001 From: openhands Date: Sun, 29 Dec 2024 02:03:46 +0000 Subject: [PATCH 2/4] Fix pr #5891: Fix issue #5890: Add an automatic check of version consistency in documentation --- .../current/usage/how-to/cli-mode.md | 4 ++-- .../current/usage/how-to/headless-mode.md | 4 ++-- .../current/usage/installation.mdx | 6 +++--- .../current/usage/runtimes.md | 2 +- .../current/usage/how-to/cli-mode.md | 4 ++-- .../current/usage/how-to/headless-mode.md | 4 ++-- .../current/usage/installation.mdx | 6 +++--- .../current/usage/runtimes.md | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/how-to/cli-mode.md b/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/how-to/cli-mode.md index b00df2c1f2a2..9156d7ac46ff 100644 --- a/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/how-to/cli-mode.md +++ b/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/how-to/cli-mode.md @@ -52,7 +52,7 @@ LLM_API_KEY="sk_test_12345" ```bash docker run -it \ --pull=always \ - -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.16-nikolaik \ + -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.17-nikolaik \ -e SANDBOX_USER_ID=$(id -u) \ -e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \ -e LLM_API_KEY=$LLM_API_KEY \ @@ -61,7 +61,7 @@ docker run -it \ -v /var/run/docker.sock:/var/run/docker.sock \ --add-host host.docker.internal:host-gateway \ --name openhands-app-$(date +%Y%m%d%H%M%S) \ - docker.all-hands.dev/all-hands-ai/openhands:0.16 \ + docker.all-hands.dev/all-hands-ai/openhands:0.17 \ python -m openhands.core.cli ``` diff --git a/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/how-to/headless-mode.md b/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/how-to/headless-mode.md index a1610bb11562..9d1172770549 100644 --- a/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/how-to/headless-mode.md +++ b/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/how-to/headless-mode.md @@ -46,7 +46,7 @@ LLM_API_KEY="sk_test_12345" ```bash docker run -it \ --pull=always \ - -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.16-nikolaik \ + -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.17-nikolaik \ -e SANDBOX_USER_ID=$(id -u) \ -e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \ -e LLM_API_KEY=$LLM_API_KEY \ @@ -56,6 +56,6 @@ docker run -it \ -v /var/run/docker.sock:/var/run/docker.sock \ --add-host host.docker.internal:host-gateway \ --name openhands-app-$(date +%Y%m%d%H%M%S) \ - docker.all-hands.dev/all-hands-ai/openhands:0.16 \ + docker.all-hands.dev/all-hands-ai/openhands:0.17 \ python -m openhands.core.main -t "write a bash script that prints hi" --no-auto-continue ``` diff --git a/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/installation.mdx b/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/installation.mdx index 87b7afb07cd2..ddfef195b661 100644 --- a/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/installation.mdx +++ b/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/installation.mdx @@ -13,16 +13,16 @@ La façon la plus simple d'exécuter OpenHands est avec Docker. ```bash -docker pull docker.all-hands.dev/all-hands-ai/runtime:0.16-nikolaik +docker pull docker.all-hands.dev/all-hands-ai/runtime:0.17-nikolaik docker run -it --rm --pull=always \ - -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.16-nikolaik \ + -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.17-nikolaik \ -e LOG_ALL_EVENTS=true \ -v /var/run/docker.sock:/var/run/docker.sock \ -p 3000:3000 \ --add-host host.docker.internal:host-gateway \ --name openhands-app \ - docker.all-hands.dev/all-hands-ai/openhands:0.16 + docker.all-hands.dev/all-hands-ai/openhands:0.17 ``` Vous pouvez également exécuter OpenHands en mode [headless scriptable](https://docs.all-hands.dev/modules/usage/how-to/headless-mode), en tant que [CLI interactive](https://docs.all-hands.dev/modules/usage/how-to/cli-mode), ou en utilisant l'[Action GitHub OpenHands](https://docs.all-hands.dev/modules/usage/how-to/github-action). diff --git a/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/runtimes.md b/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/runtimes.md index d12524fc012c..67d054c4791f 100644 --- a/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/runtimes.md +++ b/docs/i18n/fr/docusaurus-plugin-content-docs/current/usage/runtimes.md @@ -13,7 +13,7 @@ C'est le Runtime par défaut qui est utilisé lorsque vous démarrez OpenHands. ``` docker run # ... - -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.16-nikolaik \ + -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.17-nikolaik \ -v /var/run/docker.sock:/var/run/docker.sock \ # ... ``` diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/how-to/cli-mode.md b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/how-to/cli-mode.md index cf0bbdd10dd6..e6760ee2d63b 100644 --- a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/how-to/cli-mode.md +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/how-to/cli-mode.md @@ -50,7 +50,7 @@ LLM_API_KEY="sk_test_12345" ```bash docker run -it \ --pull=always \ - -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.16-nikolaik \ + -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.17-nikolaik \ -e SANDBOX_USER_ID=$(id -u) \ -e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \ -e LLM_API_KEY=$LLM_API_KEY \ @@ -59,7 +59,7 @@ docker run -it \ -v /var/run/docker.sock:/var/run/docker.sock \ --add-host host.docker.internal:host-gateway \ --name openhands-app-$(date +%Y%m%d%H%M%S) \ - docker.all-hands.dev/all-hands-ai/openhands:0.16 \ + docker.all-hands.dev/all-hands-ai/openhands:0.17 \ python -m openhands.core.cli ``` diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/how-to/headless-mode.md b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/how-to/headless-mode.md index 6a95fa0fe5a5..c38831e4a462 100644 --- a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/how-to/headless-mode.md +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/how-to/headless-mode.md @@ -47,7 +47,7 @@ LLM_API_KEY="sk_test_12345" ```bash docker run -it \ --pull=always \ - -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.16-nikolaik \ + -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.17-nikolaik \ -e SANDBOX_USER_ID=$(id -u) \ -e WORKSPACE_MOUNT_PATH=$WORKSPACE_BASE \ -e LLM_API_KEY=$LLM_API_KEY \ @@ -57,6 +57,6 @@ docker run -it \ -v /var/run/docker.sock:/var/run/docker.sock \ --add-host host.docker.internal:host-gateway \ --name openhands-app-$(date +%Y%m%d%H%M%S) \ - docker.all-hands.dev/all-hands-ai/openhands:0.16 \ + docker.all-hands.dev/all-hands-ai/openhands:0.17 \ python -m openhands.core.main -t "write a bash script that prints hi" --no-auto-continue ``` diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/installation.mdx b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/installation.mdx index 432eaeeff0e4..6de97bfc3bc5 100644 --- a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/installation.mdx +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/installation.mdx @@ -11,16 +11,16 @@ 在 Docker 中运行 OpenHands 是最简单的方式。 ```bash -docker pull docker.all-hands.dev/all-hands-ai/runtime:0.16-nikolaik +docker pull docker.all-hands.dev/all-hands-ai/runtime:0.17-nikolaik docker run -it --rm --pull=always \ - -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.16-nikolaik \ + -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.17-nikolaik \ -e LOG_ALL_EVENTS=true \ -v /var/run/docker.sock:/var/run/docker.sock \ -p 3000:3000 \ --add-host host.docker.internal:host-gateway \ --name openhands-app \ - docker.all-hands.dev/all-hands-ai/openhands:0.16 + docker.all-hands.dev/all-hands-ai/openhands:0.17 ``` 你也可以在可脚本化的[无头模式](https://docs.all-hands.dev/modules/usage/how-to/headless-mode)下运行 OpenHands,作为[交互式 CLI](https://docs.all-hands.dev/modules/usage/how-to/cli-mode),或使用 [OpenHands GitHub Action](https://docs.all-hands.dev/modules/usage/how-to/github-action)。 diff --git a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/runtimes.md b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/runtimes.md index d93207442a07..c6a7fc29053c 100644 --- a/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/runtimes.md +++ b/docs/i18n/zh-Hans/docusaurus-plugin-content-docs/current/usage/runtimes.md @@ -11,7 +11,7 @@ ``` docker run # ... - -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.16-nikolaik \ + -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.17-nikolaik \ -v /var/run/docker.sock:/var/run/docker.sock \ # ... ``` From eea6909de27be7bccedd9662846ecb68a897d907 Mon Sep 17 00:00:00 2001 From: Graham Neubig Date: Sat, 28 Dec 2024 21:31:23 -0500 Subject: [PATCH 3/4] Update permissions --- .github/scripts/check_version_consistency.py | 41 +++++++++++--------- 1 file changed, 23 insertions(+), 18 deletions(-) mode change 100644 => 100755 .github/scripts/check_version_consistency.py diff --git a/.github/scripts/check_version_consistency.py b/.github/scripts/check_version_consistency.py old mode 100644 new mode 100755 index 5e859eb30df5..18180d9e890e --- a/.github/scripts/check_version_consistency.py +++ b/.github/scripts/check_version_consistency.py @@ -4,58 +4,63 @@ import sys from typing import Set, Tuple + def find_version_references(directory: str) -> Tuple[Set[str], Set[str]]: openhands_versions = set() runtime_versions = set() - + version_pattern_openhands = re.compile(r'openhands:0\.(\d{2})') version_pattern_runtime = re.compile(r'runtime:0\.(\d{2})') - + for root, _, files in os.walk(directory): # Skip .git directory if '.git' in root: continue - + for file in files: - if file.endswith(('.md', '.yml', '.yaml', '.txt', '.html', '.py', '.js', '.ts')): + if file.endswith( + ('.md', '.yml', '.yaml', '.txt', '.html', '.py', '.js', '.ts') + ): file_path = os.path.join(root, file) try: with open(file_path, 'r', encoding='utf-8') as f: content = f.read() - + # Find all openhands version references matches = version_pattern_openhands.findall(content) openhands_versions.update(matches) - + # Find all runtime version references matches = version_pattern_runtime.findall(content) runtime_versions.update(matches) except Exception as e: - print(f"Error reading {file_path}: {e}", file=sys.stderr) - + print(f'Error reading {file_path}: {e}', file=sys.stderr) + return openhands_versions, runtime_versions + def main(): repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) openhands_versions, runtime_versions = find_version_references(repo_root) - + exit_code = 0 - + if len(openhands_versions) > 1: - print("Error: Multiple openhands versions found:", file=sys.stderr) - print("Found versions:", sorted(openhands_versions), file=sys.stderr) + print('Error: Multiple openhands versions found:', file=sys.stderr) + print('Found versions:', sorted(openhands_versions), file=sys.stderr) exit_code = 1 elif len(openhands_versions) == 0: - print("Warning: No openhands version references found", file=sys.stderr) - + print('Warning: No openhands version references found', file=sys.stderr) + if len(runtime_versions) > 1: - print("Error: Multiple runtime versions found:", file=sys.stderr) - print("Found versions:", sorted(runtime_versions), file=sys.stderr) + print('Error: Multiple runtime versions found:', file=sys.stderr) + print('Found versions:', sorted(runtime_versions), file=sys.stderr) exit_code = 1 elif len(runtime_versions) == 0: - print("Warning: No runtime version references found", file=sys.stderr) - + print('Warning: No runtime version references found', file=sys.stderr) + sys.exit(exit_code) + if __name__ == '__main__': main() From 6d67e338210f7bd25a57cb5bb43ba8b77dfd6c59 Mon Sep 17 00:00:00 2001 From: Graham Neubig Date: Sat, 28 Dec 2024 23:13:56 -0500 Subject: [PATCH 4/4] Update .github/scripts/check_version_consistency.py Co-authored-by: Boxuan Li --- .github/scripts/check_version_consistency.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/check_version_consistency.py b/.github/scripts/check_version_consistency.py index 18180d9e890e..daf78a8d2c1a 100755 --- a/.github/scripts/check_version_consistency.py +++ b/.github/scripts/check_version_consistency.py @@ -9,8 +9,8 @@ def find_version_references(directory: str) -> Tuple[Set[str], Set[str]]: openhands_versions = set() runtime_versions = set() - version_pattern_openhands = re.compile(r'openhands:0\.(\d{2})') - version_pattern_runtime = re.compile(r'runtime:0\.(\d{2})') + version_pattern_openhands = re.compile(r'openhands:(\d{1})\.(\d{2})') + version_pattern_runtime = re.compile(r'runtime:(\d{1})\.(\d{2})') for root, _, files in os.walk(directory): # Skip .git directory