-
Notifications
You must be signed in to change notification settings - Fork 458
Add run/artifact metadata to persisted evals records #45756
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
Changes from all commits
7a1ad5f
84ffbc0
998de2e
ad28f85
07f64eb
ab4e30f
ef9b0d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; | ||
| import fs from "fs"; | ||
| import { createRequire } from "module"; | ||
|
|
||
| const EVALS_DIR = "/tmp/gh-aw/evals"; | ||
| const EVALS_LOG_PATH = `${EVALS_DIR}/evals.log`; | ||
| const EVALS_OUTPUT_PATH = "/tmp/gh-aw/evals.jsonl"; | ||
| const require = createRequire(import.meta.url); | ||
| const { parseMain } = require("./run_evals.cjs"); | ||
|
|
||
| const mockCore = { | ||
| info: vi.fn(), | ||
| warning: vi.fn(), | ||
| setFailed: vi.fn(), | ||
| exportVariable: vi.fn(), | ||
| summary: { | ||
| addDetails: vi.fn().mockReturnThis(), | ||
| write: vi.fn().mockResolvedValue(), | ||
| }, | ||
| }; | ||
|
|
||
| global.core = mockCore; | ||
|
|
||
| describe("run_evals.cjs", () => { | ||
| beforeEach(() => { | ||
| vi.clearAllMocks(); | ||
| fs.mkdirSync(EVALS_DIR, { recursive: true }); | ||
| if (fs.existsSync(EVALS_LOG_PATH)) { | ||
| fs.unlinkSync(EVALS_LOG_PATH); | ||
| } | ||
| if (fs.existsSync(EVALS_OUTPUT_PATH)) { | ||
| fs.unlinkSync(EVALS_OUTPUT_PATH); | ||
| } | ||
|
pelikhan marked this conversation as resolved.
|
||
| }); | ||
|
pelikhan marked this conversation as resolved.
|
||
|
|
||
| afterEach(() => { | ||
| vi.unstubAllEnvs(); | ||
| if (fs.existsSync(EVALS_LOG_PATH)) { | ||
| fs.unlinkSync(EVALS_LOG_PATH); | ||
| } | ||
| if (fs.existsSync(EVALS_OUTPUT_PATH)) { | ||
| fs.unlinkSync(EVALS_OUTPUT_PATH); | ||
| } | ||
| }); | ||
|
|
||
| it("stores the workflow run id when writing eval records", async () => { | ||
| vi.stubEnv("GH_AW_EVALS_QUESTIONS", JSON.stringify([{ id: "labels-applied", question: "Did labels get applied?" }])); | ||
| vi.stubEnv("GH_AW_EVALS_MODEL", "small"); | ||
| vi.stubEnv("GITHUB_RUN_ID", "123456789"); | ||
| fs.writeFileSync(EVALS_LOG_PATH, "labels-applied: YES\n", "utf8"); | ||
|
|
||
| await parseMain(); | ||
|
|
||
| const lines = fs.readFileSync(EVALS_OUTPUT_PATH, "utf8").trim().split("\n"); | ||
| expect(lines).toHaveLength(1); | ||
| expect(JSON.parse(lines[0])).toEqual({ | ||
| id: "labels-applied", | ||
| question: "Did labels get applied?", | ||
| answer: "YES", | ||
| model: "small", | ||
| timestamp: expect.any(String), | ||
| runid: "123456789", | ||
| }); | ||
| }); | ||
|
|
||
| it('falls back to "unknown" when the workflow run id is absent', async () => { | ||
| vi.stubEnv("GH_AW_EVALS_QUESTIONS", JSON.stringify([{ id: "labels-applied", question: "Did labels get applied?" }])); | ||
| vi.stubEnv("GH_AW_EVALS_MODEL", "small"); | ||
| vi.stubEnv("GITHUB_RUN_ID", ""); | ||
| fs.writeFileSync(EVALS_LOG_PATH, "labels-applied: YES\n", "utf8"); | ||
|
|
||
| await parseMain(); | ||
|
|
||
| const [line] = fs.readFileSync(EVALS_OUTPUT_PATH, "utf8").trim().split("\n"); | ||
| expect(JSON.parse(line).runid).toBe("unknown"); | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.