Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
64 changes: 0 additions & 64 deletions actions/setup/js/generate_aw_info.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/// <reference types="@actions/github-script" />

const fs = require("fs");
const path = require("path");
const { TMP_GH_AW_PATH } = require("./constants.cjs");
const { generateWorkflowOverview } = require("./generate_workflow_overview.cjs");
const { logStagedPreviewInfo } = require("./staged_preview.cjs");
Expand Down Expand Up @@ -160,7 +159,6 @@ async function main(core, ctx) {

// Write to /tmp/gh-aw directory to avoid inclusion in PR
fs.mkdirSync(TMP_GH_AW_PATH, { recursive: true });
writeMergedModelMultipliers(core, tokenWeights);
writeMergedModelsJSON(core);
const tmpPath = TMP_GH_AW_PATH + "/aw_info.json";
fs.writeFileSync(tmpPath, JSON.stringify(awInfo, null, 2));
Expand Down Expand Up @@ -192,49 +190,6 @@ async function main(core, ctx) {
}
}

/**
* Load and merge model multiplier data, then persist it to /tmp/gh-aw for downstream jobs.
* Base data is read from the setup action directory; custom workflow overrides (if any)
* are merged on top.
* @param {typeof import('@actions/core')} core
* @param {Record<string, unknown> | null} tokenWeights
*/
function writeMergedModelMultipliers(core, tokenWeights) {
const builtInPath = path.join(__dirname, "model_multipliers.json");
/** @type {Record<string, unknown>} */
let builtIn = {};
if (fs.existsSync(builtInPath)) {
try {
const parsed = JSON.parse(fs.readFileSync(builtInPath, "utf8"));
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
builtIn = parsed;
} else {
core.warning(`Built-in model_multipliers.json is not a JSON object: ${builtInPath}`);
}
} catch (error) {
core.warning(`Failed to parse built-in model_multipliers.json: ${String(error)}`);
}
} else {
core.warning(`Built-in model_multipliers.json not found at ${builtInPath}`);
}

const builtInTokenClassWeights = getPlainObjectOrEmpty(builtIn.token_class_weights);
const builtInMultipliers = getPlainObjectOrEmpty(builtIn.multipliers);

const customTokenClassWeights = getPlainObjectOrEmpty(tokenWeights?.token_class_weights);
const customMultipliers = getPlainObjectOrEmpty(tokenWeights?.multipliers);

const merged = {
...builtIn,
token_class_weights: { ...builtInTokenClassWeights, ...customTokenClassWeights },
multipliers: { ...builtInMultipliers, ...customMultipliers },
};

const mergedPath = `${TMP_GH_AW_PATH}/model_multipliers.json`;
fs.writeFileSync(mergedPath, JSON.stringify(merged, null, 2));
core.info(`Generated merged model multipliers at: ${mergedPath}`);
}

core.info("Generated aw_info.json at: " + tmpPath);
core.info(JSON.stringify(awInfo, null, 2));

Expand All @@ -247,22 +202,3 @@ async function main(core, ctx) {
}

module.exports = { main };

/**
* @param {unknown} value
* @returns {Record<string, unknown>}
*/
function getPlainObjectOrEmpty(value) {
if (isPlainObject(value)) {
return value;
}
return {};
}

/**
* @param {unknown} value
* @returns {value is Record<string, unknown>}
*/
function isPlainObject(value) {
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
}
19 changes: 1 addition & 18 deletions actions/setup/js/generate_aw_info.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const mockContext = {
describe("generate_aw_info.cjs", () => {
let main;
let awInfoPath;
let mergedMultipliersPath;

beforeEach(async () => {
vi.clearAllMocks();
Expand All @@ -41,7 +40,6 @@ describe("generate_aw_info.cjs", () => {
fs.mkdirSync("/tmp/gh-aw", { recursive: true });
}
awInfoPath = "/tmp/gh-aw/aw_info.json";
mergedMultipliersPath = "/tmp/gh-aw/model_multipliers.json";

// Set default env vars for compile-time values
process.env.GH_AW_INFO_ENGINE_ID = "copilot";
Expand Down Expand Up @@ -72,9 +70,6 @@ describe("generate_aw_info.cjs", () => {
if (fs.existsSync(awInfoPath)) {
fs.unlinkSync(awInfoPath);
}
if (fs.existsSync(mergedMultipliersPath)) {
fs.unlinkSync(mergedMultipliersPath);
}
// Clean up env vars
const keysToDelete = Object.keys(process.env).filter(k => k.startsWith("GH_AW_INFO_"));
for (const key of keysToDelete) {
Expand Down Expand Up @@ -105,24 +100,12 @@ describe("generate_aw_info.cjs", () => {
expect(awInfo.created_at).toBeTruthy();
});

it("should write merged model multipliers file", async () => {
await main(mockCore, mockContext);
expect(fs.existsSync(mergedMultipliersPath)).toBe(true);
const merged = JSON.parse(fs.readFileSync(mergedMultipliersPath, "utf8"));
expect(merged).toHaveProperty("token_class_weights");
expect(merged).toHaveProperty("multipliers");
expect(merged.multipliers).toHaveProperty("claude-sonnet-4.5");
});

it("should merge custom token weights into model multipliers file", async () => {
it("should persist custom token weights in aw_info.json", async () => {
process.env.GH_AW_INFO_TOKEN_WEIGHTS = JSON.stringify({
token_class_weights: { output: 8.0 },
multipliers: { "my-custom-model": 2.5 },
});
await main(mockCore, mockContext);
const merged = JSON.parse(fs.readFileSync(mergedMultipliersPath, "utf8"));
expect(merged.token_class_weights.output).toBe(8.0);
expect(merged.multipliers["my-custom-model"]).toBe(2.5);
const awInfo = JSON.parse(fs.readFileSync(awInfoPath, "utf8"));
expect(awInfo.token_weights.multipliers["my-custom-model"]).toBe(2.5);
});
Expand Down
212 changes: 0 additions & 212 deletions actions/setup/js/merge_awf_model_multipliers.cjs

This file was deleted.

Loading
Loading