Skip to content

Commit

Permalink
Add logic in job_runner to write to file instead
Browse files Browse the repository at this point in the history
  • Loading branch information
raunakab committed Dec 19, 2024
1 parent b85099c commit be77c83
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions .github/ci-scripts/job_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

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,15 @@ 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, "w") as file:
file.write("asdf")

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

0 comments on commit be77c83

Please sign in to comment.