Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Output results in a CSV format #3625

Merged
merged 16 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
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
18 changes: 15 additions & 3 deletions .github/ci-scripts/job_runner.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# /// script
# requires-python = ">=3.12"
# dependencies = []
# dependencies = ["ray[default]"]
raunakab marked this conversation as resolved.
Show resolved Hide resolved
# ///

import argparse
import asyncio
import csv
import json
from dataclasses import dataclass
import os
from dataclasses import asdict, dataclass
from datetime import datetime, timedelta
from pathlib import Path
from typing import Optional
Expand Down Expand Up @@ -45,6 +47,11 @@ def submit_job(
env_vars: str,
enable_ray_tracing: bool,
):
if "GHA_OUTPUT_DIR" not in os.environ:
raise RuntimeError("Output directory environment variable not found; don't know where to store outputs")
output_dir = Path(os.environ["GHA_OUTPUT_DIR"])
output_dir.mkdir(exist_ok=True, parents=True)

env_vars_dict = parse_env_var_str(env_vars)
if enable_ray_tracing:
env_vars_dict["DAFT_ENABLE_RAY_TRACING"] = "1"
Expand Down Expand Up @@ -85,7 +92,12 @@ def submit_job(
result = Result(query=index, duration=duration, error_msg=error_msg)
results.append(result)

print(f"{results=}")
output_file = output_dir / "out.csv"
with open(output_file, mode="w", newline="") as csv_file:
writer = csv.DictWriter(csv_file, fieldnames=results[0].__dataclass_fields__.keys())
writer.writeheader()
for result in results:
writer.writerow(asdict(result))


if __name__ == "__main__":
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/run-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ jobs:
uv v
source .venv/bin/activate
uv pip install ray[default] boto3
GHA_OUTPUT_DIR=/tmp/outputs
mkdir -p $GHA_OUTPUT_DIR
echo "Output dir is set to $GHA_OUTPUT_DIR"
echo "GHA_OUTPUT_DIR=$GHA_OUTPUT_DIR" >> $GITHUB_ENV
- name: Dynamically update ray config file
run: |
source .venv/bin/activate
Expand Down Expand Up @@ -121,6 +125,7 @@ jobs:
echo 'Invalid command submitted; command cannot be empty'
exit 1
fi
echo "Output dir: $GHA_OUTPUT_DIR"
python .github/ci-scripts/job_runner.py \
--working-dir='${{ inputs.working_dir }}' \
--entrypoint-script='${{ inputs.entrypoint_script }}' \
Expand Down Expand Up @@ -157,6 +162,12 @@ jobs:
run: |
source .venv/bin/activate
ray down .github/assets/ray.yaml -y
- name: Upload output dir
if: always()
raunakab marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/upload-artifact@v4
with:
name: outputs
path: ${{ env.GHA_OUTPUT_DIR }}
- name: Upload log files
if: always()
uses: actions/upload-artifact@v4
Expand Down
Loading