Skip to content

Commit ac56fd8

Browse files
chore: use uv in workflow and inline requests calls (drop helper)
- Use astral-sh/setup-uv and uv run with Python 3.12 - Inline requests Session calls; remove urllib/json glue Co-authored-by: openhands <[email protected]>
1 parent dd76453 commit ac56fd8

File tree

2 files changed

+9
-23
lines changed

2 files changed

+9
-23
lines changed

.github/workflows/weekly-architecture-refresh.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ jobs:
2121
with:
2222
fetch-depth: 0
2323

24-
- name: Set up Python
25-
uses: actions/setup-python@v5
26-
with:
27-
python-version: '3.12'
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v7
2826

2927
- name: Run OpenHands conversation to refresh architecture docs
3028
run: |
31-
python scripts/openhands_api.py \
29+
uv run --python 3.12 python scripts/openhands_api.py \
3230
--prompt scripts/prompts/architecture_refresh.j2 \
3331
--repo OpenHands/docs \
3432
--base-url https://app.all-hands.dev

scripts/openhands_api.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,14 @@
2121
import argparse
2222
import os
2323
import sys
24-
import textwrap
2524
from dataclasses import dataclass
2625
from typing import Any
2726

28-
import json
29-
import time
3027
import requests
3128

3229

3330
DEFAULT_BASE_URL = "https://app.all-hands.dev"
34-
API_TIMEOUT = 30
31+
API_TIMEOUT = 30 # seconds
3532

3633

3734
@dataclass
@@ -40,19 +37,6 @@ class Conversation:
4037
status: str | None
4138

4239

43-
def _http_json(url: str, method: str, headers: dict[str, str], data: dict[str, Any] | None) -> dict[str, Any]:
44-
with requests.Session() as s:
45-
s.headers.update(headers)
46-
if method.upper() == "POST":
47-
r = s.post(url, json=data, timeout=API_TIMEOUT)
48-
elif method.upper() == "GET":
49-
r = s.get(url, timeout=API_TIMEOUT)
50-
else:
51-
r = s.request(method.upper(), url, json=data, timeout=API_TIMEOUT)
52-
r.raise_for_status()
53-
return r.json() if r.content else {}
54-
55-
5640
def create_conversation(base_url: str, api_key: str, initial_user_msg: str, repo: str | None = None) -> Conversation:
5741
url = base_url.rstrip("/") + "/api/conversations"
5842
headers = {
@@ -63,7 +47,11 @@ def create_conversation(base_url: str, api_key: str, initial_user_msg: str, repo
6347
payload: dict[str, Any] = {"initial_user_msg": initial_user_msg}
6448
if repo:
6549
payload["repository"] = repo
66-
data = _http_json(url, "POST", headers, payload)
50+
with requests.Session() as s:
51+
s.headers.update(headers)
52+
r = s.post(url, json=payload, timeout=API_TIMEOUT)
53+
r.raise_for_status()
54+
data = r.json()
6755
conv_id = data.get("conversation_id") or data.get("id") or ""
6856
status = data.get("status")
6957
if not conv_id:

0 commit comments

Comments
 (0)