Update Python tools

This commit is contained in:
ajp_anton
2026-08-09 18:26:25 +00:00
parent 9c0ce2098f
commit 58b4f69d63
3 changed files with 19 additions and 7 deletions
+7 -3
View File
@@ -139,6 +139,7 @@ def create_app(settings: Settings | None = None) -> Flask:
"run.html",
run=run,
children=store.children(run.id),
output=read_run_output(run),
)
@app.post("/runs/<int:run_id>/cancel")
@@ -153,12 +154,15 @@ def create_app(settings: Settings | None = None) -> Flask:
run = store.get(run_id)
if run is None:
abort(404)
return {"output": read_run_output(run)}
def read_run_output(run) -> str:
if not run.log_path:
return {"output": ""}
return ""
try:
return {"output": Path(run.log_path).read_text(encoding="utf-8", errors="replace")}
return Path(run.log_path).read_text(encoding="utf-8", errors="replace")
except FileNotFoundError:
return {"output": ""}
return ""
@app.get("/runs/<int:run_id>/artifacts")
def run_artifacts(run_id: int):
+11 -3
View File
@@ -1,21 +1,29 @@
const output = document.querySelector("#run-output");
if (output) {
let refreshTimer;
const refresh = async () => {
const response = await fetch(output.dataset.outputUrl, { cache: "no-store" });
if (response.ok) {
output.textContent = (await response.json()).output;
const nextOutput = (await response.json()).output;
if (nextOutput !== output.textContent) {
output.textContent = nextOutput;
}
}
const status = document.querySelector("#run-status");
if (status) {
const stateResponse = await fetch(status.dataset.stateUrl, { cache: "no-store" });
if (stateResponse.ok) {
status.textContent = (await stateResponse.json()).status;
const state = await stateResponse.json();
status.textContent = state.status;
if (state.status !== "queued" && state.status !== "running") {
window.clearInterval(refreshTimer);
}
}
}
};
refresh();
window.setInterval(refresh, 2000);
refreshTimer = window.setInterval(refresh, 2000);
}
const refreshArtifacts = async (container) => {
+1 -1
View File
@@ -29,5 +29,5 @@
<ul></ul>
</section>
<h2>Output</h2>
<pre id="run-output" data-output-url="{{ url_for('run_output', run_id=run.id) }}"></pre>
<pre id="run-output" data-output-url="{{ url_for('run_output', run_id=run.id) }}">{{ output }}</pre>
{% endblock %}