Skip to content

Commit 54ee436

Browse files
committed
Fix params
1 parent 1efc45b commit 54ee436

File tree

1 file changed

+44
-72
lines changed

1 file changed

+44
-72
lines changed

index.js

Lines changed: 44 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -185,25 +185,10 @@ async function updateDeploymentMirrorTraffic(
185185
}
186186

187187
try {
188-
// const endpointName = core.getInput("endpoint_name");
189-
// const resourceGroup = core.getInput("resource_group");
190-
// const workspaceName = core.getInput("workspace_name");
191-
// const registryName = core.getInput("registry_name");
192-
// const registryResourceGroup = core.getInput("registry_resource_group");
193-
// const modelName = core.getInput("model_name");
194-
// const modelVersion = core.getInput("model_version");
195-
// const traffic = core.getInput("traffic");
196-
// const deploymentYamlFilePath = core.getInput("deployment_yaml_file_path");
197-
198-
const endpointName = "test-endpoint-github-actions";
199-
const resourceGroup = "dev-ats-rg";
200-
const workspaceName = "dev-ats-llm-ws";
201-
const registryName = "";
202-
const registryResourceGroup = "";
203-
const modelName = "sklearn-model";
204-
const modelVersion = "1";
205-
const traffic = '{ "blue": 100 }';
206-
const deploymentYamlFilePath = "deployment.yaml";
188+
const endpointName = core.getInput("endpoint_name");
189+
const resourceGroup = core.getInput("resource_group");
190+
const workspaceName = core.getInput("workspace_name");
191+
const traffic = core.getInput("traffic");
207192

208193
// Check if the required inputs are provided
209194
if (!endpointName || endpointName === "") {
@@ -218,23 +203,6 @@ try {
218203
throw new Error("Workspace name is required");
219204
}
220205

221-
if (!modelName || modelName === "") {
222-
throw new Error("Model name is required");
223-
}
224-
225-
if (!modelVersion || modelVersion === "") {
226-
throw new Error("Model version is required");
227-
}
228-
229-
if (!traffic || traffic === "") {
230-
throw new Error("Traffic is required");
231-
}
232-
233-
// Check if deployment YAML file exists
234-
if (!deploymentYamlFilePath || deploymentYamlFilePath === "") {
235-
throw new Error("Deployment YAML file path is required.");
236-
}
237-
238206
// Check if the resource group exists
239207
console.log(`🔹 Checking if resource group '${resourceGroup}' exists...`)
240208
;
@@ -269,54 +237,58 @@ try {
269237
console.log(`✅ Endpoint '${endpointName}' exists in resource group '${resourceGroup}' and workspace '${workspaceName}''${resourceGroup}'.`);
270238
}
271239

272-
// Parse the traffic input
273-
const trafficObj = JSON.parse(traffic);
240+
if (traffic !== undefined && traffic !== "") {
241+
console.log(`🔹 Updating traffic for endpoint '${endpointName}'...`);
274242

275-
// Get values for "mirror"
276-
const trafficEntry = trafficObj["mirror"];
243+
// Parse the traffic input
244+
const trafficObj = JSON.parse(traffic);
277245

278-
// Check if "mirror" is present in the traffic object
279-
if (trafficEntry) {
280-
// Iterate through the keys of the "mirror" object
281-
for (const key in trafficEntry) {
282-
console.log(`🔹 Updating deployment '${key}' with mirror traffic '${trafficObj[key]}%'...`);
246+
// Get values for "mirror"
247+
const trafficEntry = trafficObj["mirror"];
283248

284-
// Update the mirror traffic
285-
let updateMirrorTraffic = await updateDeploymentMirrorTraffic(
286-
resourceGroup, workspaceName, endpointName, key, trafficEntry[key]
287-
);
249+
// Check if "mirror" is present in the traffic object
250+
if (trafficEntry) {
251+
// Iterate through the keys of the "mirror" object
252+
for (const key in trafficEntry) {
253+
console.log(`🔹 Updating deployment '${key}' with mirror traffic '${trafficObj[key]}%'...`);
288254

289-
if (!updateMirrorTraffic) {
290-
console.log(`❌ Mirror traffic for '${key}' update failed.`);
291-
} else {
292-
console.log(`✅ Mirror traffic for '${key}' updated successfully.`);
255+
// Update the mirror traffic
256+
let updateMirrorTraffic = await updateDeploymentMirrorTraffic(
257+
resourceGroup, workspaceName, endpointName, key, trafficEntry[key]
258+
);
259+
260+
if (!updateMirrorTraffic) {
261+
console.log(`❌ Mirror traffic for '${key}' update failed.`);
262+
} else {
263+
console.log(`✅ Mirror traffic for '${key}' updated successfully.`);
264+
}
293265
}
266+
} else {
267+
console.log("🔹 No mirror traffic specified.");
294268
}
295-
} else {
296-
console.log("🔹 No mirror traffic specified.");
297-
}
298-
299-
// Get the keys of the traffic object except "mirror"
300-
const prodKeys = Object.keys(trafficObj).filter(key => key !== "mirror");
301269

302-
// Iterate through the keys of the traffic object and update each deployment
303-
for (const key of prodKeys) {
304-
console.log(`🔹 Updating deployment '${key}' with traffic '${trafficObj[key]}%'...`);
270+
// Get the keys of the traffic object except "mirror"
271+
const prodKeys = Object.keys(trafficObj).filter(key => key !== "mirror");
305272

306-
// Update the traffic for the deployment
307-
let updateTraffic = await updateDeploymentTraffic(
308-
resourceGroup, workspaceName, endpointName, key, trafficObj[key]
309-
);
273+
// Iterate through the keys of the traffic object and update each deployment
274+
for (const key of prodKeys) {
275+
console.log(`🔹 Updating deployment '${key}' with traffic '${trafficObj[key]}%'...`);
310276

311-
if (!updateTraffic) {
312-
console.log(`❌ Traffic for deployment '${key}' update failed.`);
313-
} else {
314-
console.log(
315-
`✅ Traffic for deployment '${key}' updated successfully.`
277+
// Update the traffic for the deployment
278+
let updateTraffic = await updateDeploymentTraffic(
279+
resourceGroup, workspaceName, endpointName, key, trafficObj[key]
316280
);
281+
282+
if (!updateTraffic) {
283+
console.log(`❌ Traffic for deployment '${key}' update failed.`);
284+
} else {
285+
console.log(
286+
`✅ Traffic for deployment '${key}' updated successfully.`
287+
);
288+
}
317289
}
290+
console.log("✅ Deployment traffic updated successfully.");
318291
}
319-
console.log("✅ Deployment traffic updated successfully.");
320292
} catch (error) {
321293
console.log(error.message);
322294
core.setFailed(`❌ Action failed: ${error.message}`);

0 commit comments

Comments
 (0)