Update Python tools
This commit is contained in:
@@ -144,8 +144,14 @@ class TaskCatalog:
|
|||||||
group_path,
|
group_path,
|
||||||
{path.name for path in task_paths},
|
{path.name for path in task_paths},
|
||||||
)
|
)
|
||||||
|
paths_by_filename = {path.name: path for path in task_paths}
|
||||||
|
ordered_filenames = [
|
||||||
|
*declarations_by_filename,
|
||||||
|
*(path.name for path in task_paths if path.name not in declarations_by_filename),
|
||||||
|
]
|
||||||
tasks = []
|
tasks = []
|
||||||
for path in task_paths:
|
for filename in ordered_filenames:
|
||||||
|
path = paths_by_filename[filename]
|
||||||
declaration = declarations_by_filename.get(path.name)
|
declaration = declarations_by_filename.get(path.name)
|
||||||
tasks.append(
|
tasks.append(
|
||||||
Task(
|
Task(
|
||||||
@@ -289,11 +295,10 @@ def parse_task_declaration(
|
|||||||
) -> TaskDeclaration:
|
) -> TaskDeclaration:
|
||||||
if (
|
if (
|
||||||
not isinstance(declaration, dict)
|
not isinstance(declaration, dict)
|
||||||
or not {"inputs"} <= set(declaration)
|
|
||||||
or set(declaration) - {"inputs", "wait_for_result", "download_artifacts"}
|
or set(declaration) - {"inputs", "wait_for_result", "download_artifacts"}
|
||||||
):
|
):
|
||||||
raise ValueError(f"{manifest_path} task {filename} has an invalid declaration.")
|
raise ValueError(f"{manifest_path} task {filename} has an invalid declaration.")
|
||||||
raw_inputs = declaration["inputs"]
|
raw_inputs = declaration.get("inputs", [])
|
||||||
if not isinstance(raw_inputs, list):
|
if not isinstance(raw_inputs, list):
|
||||||
raise ValueError(f"{manifest_path} task {filename} inputs must be a list.")
|
raise ValueError(f"{manifest_path} task {filename} inputs must be a list.")
|
||||||
fields = tuple(parse_input_field(manifest_path, filename, raw) for raw in raw_inputs)
|
fields = tuple(parse_input_field(manifest_path, filename, raw) for raw in raw_inputs)
|
||||||
|
|||||||
@@ -121,7 +121,12 @@ class RunManager:
|
|||||||
run = self.store.get(int(run_id_text))
|
run = self.store.get(int(run_id_text))
|
||||||
if kind == "uploads" and (run is None or run.status not in {"queued", "running"}):
|
if kind == "uploads" and (run is None or run.status not in {"queued", "running"}):
|
||||||
shutil.rmtree(path, ignore_errors=True)
|
shutil.rmtree(path, ignore_errors=True)
|
||||||
elif kind == "artifacts" and path.stat().st_mtime < cutoff:
|
elif kind == "artifacts":
|
||||||
|
try:
|
||||||
|
expired = path.stat().st_mtime < cutoff
|
||||||
|
except FileNotFoundError:
|
||||||
|
continue
|
||||||
|
if expired:
|
||||||
shutil.rmtree(path, ignore_errors=True)
|
shutil.rmtree(path, ignore_errors=True)
|
||||||
|
|
||||||
def run_background_task(self, task: BackgroundTask) -> None:
|
def run_background_task(self, task: BackgroundTask) -> None:
|
||||||
|
|||||||
@@ -126,12 +126,14 @@ for (const form of document.querySelectorAll("form[data-wait-for-result]")) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
// Disabled fields are omitted from FormData, so collect values first.
|
||||||
|
const formData = new FormData(form);
|
||||||
setWaiting(true);
|
setWaiting(true);
|
||||||
showResult("Running...", "running");
|
showResult("Running...", "running");
|
||||||
try {
|
try {
|
||||||
const response = await fetch(form.action, {
|
const response = await fetch(form.action, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: new FormData(form),
|
body: formData,
|
||||||
headers: { Accept: "application/json" },
|
headers: { Accept: "application/json" },
|
||||||
});
|
});
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|||||||
Reference in New Issue
Block a user