Skip to content

Commit 91dea34

Browse files
committed
Update frontend
1 parent b66ff5f commit 91dea34

6 files changed

Lines changed: 582 additions & 95 deletions

File tree

autonima/webui/app.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class PipelineRunRequest(BaseModel):
107107

108108
class MetaRunRequest(BaseModel):
109109
output_folder: str
110+
source_run_id: Optional[str] = None
110111
estimator: str = "mkdadensity"
111112
estimator_args: str = "{}"
112113
corrector: str = "fdr"
@@ -465,6 +466,7 @@ async def start_meta_run(project_id: str, payload: MetaRunRequest):
465466
metadata = run_manager.start_meta_run(
466467
project=project,
467468
output_folder=payload.output_folder,
469+
source_run_id=payload.source_run_id,
468470
estimator=payload.estimator,
469471
estimator_args=payload.estimator_args,
470472
corrector=payload.corrector,

autonima/webui/progress.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,39 @@ def build_stage_status(
272272
parsing_data = _safe_read_json(outputs_dir / "coordinate_parsing_results.json")
273273
if parsing_data is not None:
274274
stages["parsing"]["status"] = "completed"
275+
if isinstance(parsing_data, dict):
276+
studies = parsing_data.get("studies", [])
277+
analyses_count = 0
278+
coordinates_count = 0
279+
for study in studies if isinstance(studies, list) else []:
280+
analyses = study.get("analyses", []) if isinstance(study, dict) else []
281+
if not isinstance(analyses, list):
282+
continue
283+
analyses_count += len(analyses)
284+
for analysis in analyses:
285+
points = analysis.get("points", []) if isinstance(analysis, dict) else []
286+
if isinstance(points, list):
287+
coordinates_count += len(points)
288+
counters["parsing"] = {
289+
"studies": len(studies) if isinstance(studies, list) else 0,
290+
"analyses": analyses_count,
291+
"coordinates": coordinates_count,
292+
}
293+
else:
294+
counters["parsing"] = {"status": "Done"}
275295

276296
annotation_data = _safe_read_json(outputs_dir / "annotation_results.json")
277297
if isinstance(annotation_data, list):
278298
stages["annotation"]["status"] = "completed"
279-
counters["annotation"] = {"decisions": len(annotation_data)}
299+
annotation_names = {
300+
str(item.get("annotation_name", "")).strip()
301+
for item in annotation_data
302+
if isinstance(item, dict) and str(item.get("annotation_name", "")).strip()
303+
}
304+
counters["annotation"] = {
305+
"decisions": len(annotation_data),
306+
"annotations": len(annotation_names),
307+
}
280308

281309
final_data = _safe_read_json(outputs_dir / "final_results.json")
282310
if isinstance(final_data, dict):
@@ -290,6 +318,7 @@ def build_stage_status(
290318
if stages["parsing"]["status"] != "completed":
291319
if not parsing_enabled:
292320
stages["parsing"]["status"] = "completed"
321+
counters["parsing"] = {"status": "Off"}
293322
elif run_status == "completed":
294323
# The run reached final outputs; parsing did not produce a results file
295324
# (e.g., no parseable tables). Treat this stage as complete rather than

autonima/webui/runs.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,27 +127,29 @@ def _maybe_create_execution_output(
127127
runtime_config_path: Path,
128128
resolved_output: Path,
129129
execution_mode: str,
130+
cache_source_output: Optional[Path] = None,
130131
) -> tuple[Path, Optional[str], Dict[str, Any]]:
131132
"""Default UI behavior: branch to a new output when signatures changed."""
132133
if execution_mode != "auto_new_on_change":
133134
return resolved_output, None, {}
135+
source_output = cache_source_output or resolved_output
134136
try:
135137
config = ConfigManager().load_from_file(runtime_config_path)
136-
config.output.directory = str(resolved_output)
137-
preview = preview_execution_changes(config, resolved_output)
138+
config.output.directory = str(source_output)
139+
preview = preview_execution_changes(config, source_output)
138140
except Exception:
139141
return resolved_output, None, {}
140142

141143
if not preview.get("changed_stages"):
142-
return resolved_output, None, preview
144+
return source_output, None, preview
143145

144146
execution_name = (
145147
time.strftime("%Y%m%d-%H%M%S")
146148
+ "-"
147149
+ str(preview.get("stage_hashes", {}).get("output", ""))[:8]
148150
)
149151
branched_output = resolved_output / "executions" / execution_name
150-
return branched_output, str(resolved_output), preview
152+
return branched_output, str(source_output), preview
151153

152154
def _build_meta_command(
153155
self,
@@ -318,11 +320,20 @@ def start_pipeline_run(
318320
cache_preview: Dict[str, Any] = {}
319321
branched_from: Optional[str] = None
320322
if not output_folder:
323+
previous_output_raw = str(project.get("last_output_folder") or "").strip()
324+
previous_output = (
325+
Path(previous_output_raw).expanduser().resolve()
326+
if previous_output_raw
327+
else None
328+
)
329+
if previous_output and not previous_output.exists():
330+
previous_output = None
321331
resolved_output, branched_from, cache_preview = (
322332
self._maybe_create_execution_output(
323333
runtime_config_path,
324334
resolved_output,
325335
execution_mode,
336+
cache_source_output=previous_output,
326337
)
327338
)
328339
if branched_from and not copy_valid_cache_from:
@@ -372,6 +383,7 @@ def start_meta_run(
372383
self,
373384
project: Dict[str, Any],
374385
output_folder: str,
386+
source_run_id: Optional[str],
375387
estimator: str,
376388
estimator_args: str,
377389
corrector: str,
@@ -390,6 +402,8 @@ def start_meta_run(
390402
mode="meta",
391403
output_folder=output_path,
392404
)
405+
metadata["source_run_id"] = source_run_id
406+
metadata["source_output_folder"] = output_path
393407

394408
cmd = self._build_meta_command(
395409
output_folder=output_path,
@@ -413,7 +427,7 @@ def start_meta_run(
413427
project["id"],
414428
{
415429
"run_ids": run_ids,
416-
"last_output_folder": output_path,
430+
"last_meta_output_folder": output_path,
417431
},
418432
)
419433

0 commit comments

Comments
 (0)