Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions run_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@ def __init__(self):
self.created_by = os.getenv("CREATED_BY", "Github Action")
self.run_status_url = 'https://api.coval.dev/eval/run'

def get_run_status_api(self, run_id):
def get_run_status_api(self, run_id, get_metrics=False):
"""
This function gets the status of the run from the API.
"""
config = {"run_id": run_id}
if (get_metrics):
config["type"] = "metrics"

headers = {
"Content-Type": "application/json",
"x-api-key": self.api_key,
Expand All @@ -52,7 +55,7 @@ def get_run_status_api(self, run_id):
print(f"Error Response Headers: {json.dumps(dict(e.response.headers), indent=2)}")
print(f"Error Response Body: {e.response.text}")
return None

def _wait_for_run_to_complete(self, run_id, max_wait_time=600, check_interval=60):
"""
This function waits for the run to complete by periodically checking its status.
Expand Down Expand Up @@ -103,6 +106,9 @@ def run(self):

# Wait for the job to finish
self._wait_for_run_to_complete(run_id)
final_run_result = self.get_run_status_api(run_id, get_metrics=True)
averages = final_run_result.get('averages')
return averages

except requests.exceptions.RequestException as e:
print(f"Request Exception: {str(e)}")
Expand Down