-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-run-instructions.js
More file actions
31 lines (26 loc) · 929 Bytes
/
test-run-instructions.js
File metadata and controls
31 lines (26 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const { isTrainInstruction, parseInstruction, TRAIN } = require("./worker/instructions");
const { runContainer } = require("./worker/docker");
async function runIfInstruction(message) {
if (!isTrainInstruction(message)) {
console.log("Message is not a valid instruction.");
return;
}
try {
const { instruction, container_id, data_id } = parseInstruction(message);
if (instruction === TRAIN) {
console.log("Training instruction received.");
runContainer(container_id, data_id); // Run the container
} else {
console.log("Unsupported instruction:", instruction);
}
} catch (error) {
console.error("Error processing instruction:", error.message);
}
}
// Example usage
const message = "{train mnist_container mnist_data_cid0";
runIfInstruction(message);
// console.log(JSON.parse(`{
// "test_loss": 0.08014832437038422,
// "test_accuracy": 0.9739999771118164
// }`));