Skip to content

Commit

Permalink
Merge pull request #1481 from expectedparrot/fix_issue_1478
Browse files Browse the repository at this point in the history
Fix issue 1478 + increase coop request timeouts
  • Loading branch information
johnjosephhorton authored Jan 12, 2025
2 parents a4110ed + 4177e55 commit 8cf255c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 37 deletions.
34 changes: 2 additions & 32 deletions .github/workflows/coopr_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,13 @@ on:
push:
branches:
- '**'

workflow_dispatch:

jobs:
run-tasks:
build-and-test:
if: ${{ github.event_name == 'push' && contains(github.event.head_commit.message, 'coopr') || github.event_name == 'pull_request' }}
runs-on: self-hosted

steps:
- name: Checkout repository
uses: actions/checkout@v3

build-docker:
if: ${{ github.event_name == 'push' && contains(github.event.head_commit.message, 'coopr') || github.event_name == 'pull_request' }}
runs-on: self-hosted
needs: run-tasks

steps:
- name: Checkout repository
uses: actions/checkout@v3
Expand All @@ -50,31 +40,11 @@ jobs:
cd /home/stefan/expectedparrot/coopr
docker-compose build --no-cache backend && docker-compose up --wait
run-make-coop-test:
if: ${{ github.event_name == 'push' && contains(github.event.head_commit.message, 'coopr') || github.event_name == 'pull_request' }}
runs-on: self-hosted
needs: build-docker

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Determine last commit hash for EDSL
id: get_edsl_commit
run: |
if [ "${{ github.head_ref }}" != "" ]; then
# Pull Request: Get the last commit from the source branch
echo "EDSL_COMMIT=$(git rev-parse ${{ github.event.pull_request.head.sha }})" >> $GITHUB_ENV
else
# Push: Get the last commit directly
echo "EDSL_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
fi
- name: Fetch and checkout last commit in EDSL
run: |
cd /home/stefan/expectedparrot/edsl
git fetch origin
git checkout -f $EDSL_COMMIT || git checkout -f origin/main # Fallback to main if commit is unavailable
git checkout -f $COMMIT || git checkout -f origin/main # Fallback to main if commit is unavailable
- name: Run make coop-test
run: |
Expand Down
7 changes: 5 additions & 2 deletions edsl/coop/coop.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ def _send_server_request(
url = f"{self.api_url}/{uri}"
method = method.upper()
if payload is None:
timeout = 20
timeout = 40
elif (
method.upper() == "POST"
and "json_string" in payload
and payload.get("json_string") is not None
):
timeout = max(20, (len(payload.get("json_string", "")) // (1024 * 1024)))
timeout = max(40, (len(payload.get("json_string", "")) // (1024 * 1024)))
try:
if method in ["GET", "DELETE"]:
response = requests.request(
Expand Down Expand Up @@ -533,6 +533,7 @@ def remote_cache_create_many(
uri="api/v0/remote-cache/many",
method="POST",
payload=payload,
timeout=40,
)
self._resolve_server_response(response)
response_json = response.json()
Expand Down Expand Up @@ -563,6 +564,7 @@ def remote_cache_get(
uri="api/v0/remote-cache/get-many",
method="POST",
payload={"keys": exclude_keys},
timeout=40,
)
self._resolve_server_response(response)
return [
Expand All @@ -581,6 +583,7 @@ def remote_cache_get_diff(
uri="api/v0/remote-cache/get-diff",
method="POST",
payload={"keys": client_cacheentry_keys},
timeout=40,
)
self._resolve_server_response(response)
response_json = response.json()
Expand Down
6 changes: 3 additions & 3 deletions edsl/results/Results.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ def compute_job_cost(self, include_cached_responses_in_cost: bool = False) -> fl
"""
total_cost = 0
for result in self:
for key in result.raw_model_response:
for key in result["raw_model_response"]:
if key.endswith("_cost"):
result_cost = result.raw_model_response[key]
result_cost = result["raw_model_response"][key]

question_name = key.removesuffix("_cost")
cache_used = result.cache_used_dict[question_name]
cache_used = result["cache_used_dict"][question_name]

if isinstance(result_cost, (int, float)):
if include_cached_responses_in_cost:
Expand Down

0 comments on commit 8cf255c

Please sign in to comment.