get response data correctly

This commit is contained in:
Laura Abro
2025-04-24 19:43:30 -03:00
parent 1e63c7a72c
commit 923c25b1ef
2 changed files with 5 additions and 5 deletions

View File

@ -46,7 +46,7 @@ def execute(runner, worker, data):
if result.get("success"):
runner.state["repo_url"] = (
f"https://github.com/{result['repo_owner']}/{result['repo_name']}"
f"https://github.com/{result['data']['repo_owner']}/{result['data']['repo_name']}"
)
return result

View File

@ -19,24 +19,24 @@ def execute(runner, worker, data):
print(f"✓ No repo url found for {worker.name} - continuing")
return {"success": True, "message": "No repo url found"}
url = f"{worker.url}/worker-task/{data['roundNumber']}"
url = f"{worker.url}/worker-task/{runner.current_round}"
response = requests.post(url, json=data)
result = response.json()
# Handle 409 gracefully - no eligible todos is an expected case
if response.status_code in [401, 409]:
if response.status_code == 409:
print(
f"{result.get('message', 'No eligible todos')} for {worker.name} - continuing"
)
return {"success": True, "message": result.get("message")}
if result.get("success") and "pr_url" in result:
if result.get("success") and "pr_url" in result["result"]["data"]:
round_key = str(runner.current_round)
round_state = runner.state["rounds"].setdefault(round_key, {})
# Initialize pr_urls if not exists
if "pr_urls" not in round_state:
round_state["pr_urls"] = {}
round_state["pr_urls"][worker.name] = result["pr_url"]
round_state["pr_urls"][worker.name] = result["result"]["data"]["pr_url"]
return result