Skip to content

Commit d2939a8

Browse files
committed
Fix(viewer picker): Read aws resubmit commands from metadata
1 parent cc82d76 commit d2939a8

3 files changed

Lines changed: 43 additions & 5 deletions

File tree

codeclash/viewer/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ def _load_game_metadata(folder_info: dict[str, Any]) -> dict[str, Any]:
395395
folder_info["models"] = metadata.models
396396
folder_info["game_name"] = metadata.game_name
397397
folder_info["created_timestamp"] = metadata.get_path("created_timestamp")
398+
folder_info["aws_command"] = metadata.get_path("aws.AWS_USER_PROVIDED_COMMAND")
398399
return folder_info
399400

400401

codeclash/viewer/static/js/picker.js

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,17 +324,53 @@ function fillTextareaWithAWSResubmitCommands() {
324324
return;
325325
}
326326

327-
hideModalWarning();
328-
const folderNames = Array.from(selectedCheckboxes).map((checkbox) => {
327+
// Get the row for each checkbox and extract AWS command from metadata
328+
const commandsWithInfo = Array.from(selectedCheckboxes).map((checkbox) => {
329+
const row = checkbox.closest(".game-row");
330+
const awsCommand = row ? row.getAttribute("data-aws-command") : "";
329331
const fullPath = checkbox.getAttribute("data-path");
330-
return fullPath.split("/").pop();
332+
333+
return {
334+
path: fullPath,
335+
awsCommand: awsCommand,
336+
hasCommand: awsCommand && awsCommand.trim() !== "",
337+
};
331338
});
332339

333-
const commands = folderNames.map((folderName) => {
334-
return `aws/run_job.py -- main.py --config-file configs/main/${folderName}.yaml`;
340+
// Separate folders with and without AWS commands
341+
const foldersWithCommands = commandsWithInfo.filter(
342+
(info) => info.hasCommand,
343+
);
344+
const foldersWithoutCommands = commandsWithInfo.filter(
345+
(info) => !info.hasCommand,
346+
);
347+
348+
if (foldersWithCommands.length === 0) {
349+
showModalWarning(
350+
"None of the selected folders have AWS command information in their metadata.",
351+
);
352+
document.getElementById("bulk-actions-textarea").value = "";
353+
return;
354+
}
355+
356+
// Generate commands for folders that have AWS command info
357+
const commands = foldersWithCommands.map((info) => {
358+
return `aws/run_job.py -- ${info.awsCommand}`;
335359
});
336360

337361
document.getElementById("bulk-actions-textarea").value = commands.join("\n");
362+
363+
// Show warning if some folders are missing AWS commands
364+
if (foldersWithoutCommands.length > 0) {
365+
const folderNames = foldersWithoutCommands
366+
.map((info) => info.path.split("/").pop())
367+
.join(", ");
368+
showModalWarning(
369+
`Warning: ${foldersWithoutCommands.length} folder(s) skipped due to missing AWS command in metadata: ${folderNames}`,
370+
);
371+
} else {
372+
hideModalWarning();
373+
}
338374
}
339375

340376
function copyFromModal() {

codeclash/viewer/templates/picker.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
data-path="{{ game.name }}"
9595
data-parent-folder="{{ game.parent_folder or '' }}"
9696
data-timestamp="{{ game.created_timestamp or '' }}"
97+
data-aws-command="{{ game.aws_command or '' }}"
9798
onclick="handleRowClick(event, '{{ game.name }}')">
9899

99100
<div class="checkbox-cell">

0 commit comments

Comments
 (0)