Skip to content

ODM: stop duplicate tasks, make them identifiable, and make results recoverable - #84

Merged
muratmaga merged 7 commits into
masterfrom
odm-prevent-duplicate-tasks
Jul 15, 2026
Merged

muratmaga merged 7 commits into
masterfrom
odm-prevent-duplicate-tasks

Conversation

@muratmaga

@muratmaga muratmaga commented Jul 15, 2026 •

Copy link
Copy Markdown
Collaborator

Why

A user queued ~a dozen identical reconstructions without meaning to, saw only Status: Queued, Progress: 0% for two hours, and reported it as a hang (MorphoCloud/Instances#139). The support answer was "open Firefox at localhost:3002 and cancel them" — a URL the module never mentions.

Fixing that surfaced a family of related problems: you couldn't tell tasks apart, couldn't get results back if Slicer stopped watching, and couldn't tell which photos a task came from.

What changed

Stops the pile-up

  • Run is disabled whenever a task is tracked (_updateTaskButtons() is the single source of truth), plus a hard guard in _runWebODMTask. Previously every click created another task and overwrote self.webodmTask, orphaning the last one.
  • node.info() before creating: it's the first call that proves the node is reachable (Node.__init__ does no I/O) and it exposes task_queue_count, so we can ask before piling on.
  • Queue depth in the status line (count - 1; NodeODM counts your own task).

Makes the work visible

  • Upload progress dialog via pyodm's progress_callback — the upload runs on the UI thread and used to freeze Slicer silently while the button promised "(non-blocking)".
  • Cancel Task (Task.cancel()); Stop Monitoring now says the task keeps running.
  • A clickable Node Dashboard link that tracks the IP/port fields.

Makes tasks identifiable

  • Tasks are named after the dataset: name: defaults to the images folder's basename and follows the folder selector until you type your own. UWBM_82409_<settings-hash>_<timestamp> says which photos, which settings, when. Previously every task was SlicerReconstruction_<hash> — a pure function of the settings, so two runs collided on the node and on disk, the second download landing on the first.
  • WebODM_<name>.json record per job, holding the node's task UUID, node URL, image count, images folder and options. An images folder becomes self-describing.
  • The results folder is created at download time, not at submit — it used to leave empty folders that looked like output.

Makes results recoverable

  • Reconnect to Task on Node… lists what the node has (GET /task/list + Task.info()), cross-references the local records to tag which are yours, and resumes monitoring via Node.get_task(uuid). Reconnecting to a finished task downloads it immediately. The module already carried commented-out Save/Restore Task buttons scoped for this.

Other

  • matcher-type defaults to flann, ODM's own default, which the tooltip already documented. bruteforce was preselected, and since turntable images carry no GPS EXIF OpenSfM falls back to all-pairs matching — every run was doing exhaustive matching over every pair.
  • 38 strings wrote \\n, rendering a literal \n in dialogs instead of a line break; the other 37 in the same file already used \n.

Testing

Driven on a real MorphoCloud instance against a live GPU NodeODM: upload progress, the queue prompt, Run correctly refusing while monitoring, and Reconnect attaching to a live task all confirmed by the author. Widget behaviour (button states, picker contents/ordering, naming, sanitising, record round-trip, Import folder selection) exercised in a live Slicer with a stubbed node.

Not yet driven end-to-end on Linux: Cancel against a real task, and the task-record/naming work, which postdates the author's session.

Known, deliberately not in this PR

  • rerun combo does nothing. It ships rerun=openmvs on every task, but NodeODM discards it — odmInfo.js:83-88 excludes --rerun when building its accepted-option list, and unknown options are never read. Inert, not harmful (checked on master and v2.1.0). Suggest deleting the combo.
  • matcher-neighbors is GPS-only and inert on no-GPS turntable sets; both 16 and the default 0 end in all-pairs. --matcher-order is the filename-order knob, but it doesn't wrap (no loop closure on a 360° set) and ODM ignores it on georeferenced/GCP runs.
  • Failure reporting is thin: "Task failed or canceled" doesn't say which or why, and TaskInfo.last_error is never shown.
  • A record is written for a task that later fails, with nothing marking it as failed.
  • download_assets blocks the UI thread with no progress, as the upload used to.

🤖 Generated with Claude Code

A user queued about a dozen identical reconstructions without meaning to,
then saw only "Status: Queued, Progress: 0%" for two hours and reported it
as a hang (MorphoCloud/Instances#139). The module made all of that easy:

- The Run button was never disabled, so every click created another task on
  the node -- and each one overwrote self.webodmTask, so Slicer forgot the
  task it had just made while it kept running server-side.
- create_task uploads every image on the UI thread with no progress_callback,
  freezing Slicer for minutes, while the button and its popup both claimed
  the operation was "(non-blocking)".
- The status line never mentioned the node queue, so a task waiting behind
  eleven others was indistinguishable from a hang.
- Nothing could cancel a task from inside Slicer; the only remedy was a
  browser pointed at a URL the module never showed.

Changes:
- Hold the Run button disabled for the whole of onRunWebODMTask (split into
  a guard + _runWebODMTask so an early return still re-enables it).
- Query node.info() before creating: this is the first call that proves the
  node is reachable (Node.__init__ does no I/O), and it surfaces
  task_queue_count so we can ask before piling on.
- Drive a progress dialog from pyodm's progress_callback during upload.
- Report queue depth alongside a QUEUED status.
- Add a Cancel Task button (Task.cancel()), and make Stop Monitoring say
  plainly that the task keeps running.
- Add a clickable Node Dashboard link that tracks the IP/port fields.
- Drop the false "(non-blocking)" from the button and popup.

Also default matcher-type to flann, ODM's own default, which the tooltip
already documented. bruteforce was preselected and, since turntable images
carry no GPS EXIF, OpenSfM falls back to matching all pairs -- so every run
was doing exhaustive descriptor matching over every pair.

Separately, this file wrote "\\n" in 38 places, which renders as a literal
"\n" in the dialog rather than a line break; the other 37 strings in the
same file already used "\n". Repaired throughout.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@claude

claude Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Claude finished @muratmaga's task in 4m 0s —— View job


Review: PR #84 — ODM: stop the UI from silently queueing duplicate tasks

  • Gather context (diff, repo conventions)
  • Understand the request (code review)
  • Review ODM/ODM.py changes for correctness/security/edge cases
  • Post inline comments for specific findings
  • Post summary

Summary

Overall this is a solid, well-scoped fix for the observability half of the reported problem (upload freeze, opaque "Queued, 0%" status, no cancel path, \\n escaping bug, matcher-type default). One correctness gap remains around the PR's headline claim.

Main finding (posted inline on ODM/ODM.py:767-773): the duplicate-task scenario from the linked issue is still reachable. launchWebODMTaskButton is only held disabled for the duration of _runWebODMTask() (onRunWebODMTask, lines 760-771). Once a task is created and monitoring starts, the button is unconditionally re-enabled — while self.webodmTask/self.webodmTimer are still actively tracking that task. _runWebODMTask() never checks the local self.webodmTask before proceeding; it only asks the server for task_queue_count (line 831) via a dismissible confirm dialog. So a second "Run" click while a task is already being monitored both queues another task on the node and overwrites self.webodmTask/self.webodmTimer, silently dropping Slicer's ability to monitor or Cancel the still-running previous task — the exact "each click ... overwrites self.webodmTask" failure mode described in the PR's own "Why" section. A simple local guard (if self.webodmTask is not None: warn and return) would close this, with the button only re-enabling once there's no locally-tracked in-flight task (Stop Monitoring / Cancel / Completed / Failed).

Minor/non-blocking observations (not filed inline, lower confidence):

  • checkWebODMTaskStatus's queue-depth message (line ~1020) likely off-by-one: task_queue_count fetched while this task is itself QUEUED probably includes the task being polled, so "N task(s) running or queued ... yours is waiting its turn" may overstate how many jobs are actually ahead of it by one.
  • queuedTaskCount() (line 988) opens a brand-new pyodm.Node connection and issues an extra node.info() HTTP call on every 5-second poll tick while status is queued, on top of the existing webodmTask.info() call — works, but doubles network calls during the queued-wait period.

No security issues found (no new subprocess/user-input handling introduced). The \n escaping repair and matcher-type default change both look correct and match the PR's stated rationale.

Comment thread ODM/ODM.py Resolved
Addresses the review on #84: the duplicate-task path was still reachable.
Run was only held disabled for the duration of _runWebODMTask, so once a
task was created and monitoring began the button came straight back --
and a second click would create another task on the node and overwrite
self.webodmTask/self.webodmTimer, orphaning the first. That is exactly the
behaviour the PR claimed to fix, and it is the likelier route to the dozen
queued jobs in MorphoCloud/Instances#139: the user sees "Queued, 0%",
concludes it is stuck, and clicks Run again.

- Add _updateTaskButtons() as the single source of truth: Run is enabled
  only when no task is tracked; Stop Monitoring and Cancel only when one is.
  All four teardown paths (stop, cancel, completed, failed) go through it.
- Add a hard guard at the top of _runWebODMTask: refuse to start when
  self.webodmTask is not None, rather than relying on the server-side
  queue-count prompt, which is dismissible and does not prevent the
  local overwrite.

Also fix the off-by-one the review flagged in the queued status line.
NodeODM's getQueueCount() counts QUEUED+RUNNING including this task
(libs/TaskManager.js:305-316), so report count-1 as the number ahead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@claude

claude Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Claude finished @muratmaga's task in 1m 9s —— View job


Review: PR #84 (update) — fix in ce3f260 verified

  • Gather context (diff since last review: dd072e2 → ce3f260)
  • Review the fix for the duplicate-task guard
  • Check for regressions across all task-lifecycle paths
  • Post findings

Summary

The blocking finding from the previous review is resolved. ce3f260 adds _updateTaskButtons() (ODM/ODM.py:760-769) as the single source of truth for button state — Run is enabled only when self.webodmTask is None, and Stop Monitoring/Cancel only when it isn't. All four teardown paths now route through it: onStopMonitoring (967), onCancelTaskClicked (1005), and both branches of checkWebODMTaskStatus on completion/failure (1067, 1073). Previously Run was unconditionally re-enabled in onRunWebODMTask's finally right after upload, even while the just-created task was still being actively monitored — that's now gone.

A hard local guard was also added at the top of _runWebODMTask (785-795): if self.webodmTask is not None, it warns and returns before touching the node or re-creating the task/timer. This is technically redundant with the button now being disabled while a task is tracked, but it's a correct belt-and-suspenders check for any path that could reach _runWebODMTask with the button not yet updated (e.g. a queued signal), and it directly matches what was requested.

I verified the invariant holds at construction time too: ODMManager.__init__ sets self.webodmTask = None (line 638), and the widget's initial setup() (lines 321/329/337) starts Run enabled and Stop/Cancel disabled — consistent with _updateTaskButtons()'s state, so there's no window where the initial UI disagrees with the tracked-task invariant.

As a bonus, this same commit also fixed the off-by-one I'd flagged as a minor/non-blocking note last round: queuedTaskCount()'s docstring now correctly states it counts QUEUED+RUNNING including this task, and checkWebODMTaskStatus (1043-1048) subtracts 1 before reporting "N task(s) ahead of yours."

Author's own verification log in the PR thread (Run→monitored, second click while monitoring → warned + no extra task created, Cancel/Stop Monitoring both restore Run) matches the code paths above.

No new issues found in this delta. The remaining minor point from the previous review — queuedTaskCount() opening a fresh pyodm.Node connection and calling node.info() on every 5s poll tick while queued, in addition to the existing webodmTask.info() call — is unchanged and still just a minor efficiency note, not a correctness issue.

@muratmaga

Copy link
Copy Markdown
Collaborator Author

Review reconciliation (ce3f260)

All three findings addressed — two fixed, one declined with reasoning.

1. Duplicate task still reachable — FIXED (ce3f260). Correct, and it was the main scenario rather than an edge case; details in the inline reply. Run is now gated on self.webodmTask is None via a single _updateTaskButtons() helper, plus a hard guard in _runWebODMTask. Verified in a live Slicer: a second click while monitoring creates no task, keeps tracking the original, and warns.

2. Queue-depth off-by-one — FIXED (ce3f260). Confirmed against the source: TaskManager.js:305-316 counts QUEUED + RUNNING, which includes the task being polled. Now reports count - 1 and says "N task(s) ahead of yours" rather than the ambiguous "N on this node". The pre-create prompt is unaffected — it runs before our task exists, so its count is genuinely "already there".

3. Extra node.info() per poll tick — declining, by design. It's one small JSON GET every 5s, and only while status is QUEUED — it stops the moment processing starts. pyodm.Node.__init__ does no I/O, so the per-tick construction is free; the only cost is the request itself. That seems a fair price for the number that turns "stuck at 0% for two hours" into "9 tasks ahead of yours", which is the entire point of the PR. Happy to reconsider if it's a problem against a remote MorphoCloud node.

Still not exercised against a live NodeODM — ODM is Linux/Docker/GPU by design, so that check has to happen on Linux before merge.

Caught on a real node: when create_task fails, the "Creating NodeODM Task"
progress dialog stays on screen behind the error. slicer.util.errorDisplay
is modal, so raising it from the except block blocks before the finally that
closes the progress dialog ever runs.

Capture the exception, let the finally take the dialog down, then report.

Found while testing against a NodeODM started with --test, which rejected
feature-type=dspsift. That rejection is a test-mode artifact -- odmRunner's
getJsonOptions returns a mock (tests/odm_options.json) instead of asking ODM,
and that mock's feature-type enum predates dspsift -- but the stranded dialog
it exposed is real and would show on any task-creation error.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@claude

claude Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Claude finished @muratmaga's task in 50s —— View job


Claude finished @muratmaga's task —— View job

Review: PR #84 (update) — 564c7b7 verified

  • Gather context (diff since last review: ce3f260 → 564c7b7)
  • Review the new fix for dialog stacking on task-creation failure
  • Re-check button/task-tracking invariants aren't affected
  • Post findings

Summary

564c7b7 is a small, correct fix and the only change in this push (ODM/ODM.py:905-923).

The bug it fixes: in the previous version, slicer.util.errorDisplay(...) was called directly inside the except block, before the finally: progressDialog.close() ran. Since errorDisplay is modal, the upload progress dialog was still open and visible behind the error dialog when it appeared — the "stranded upload dialog" described in the commit message.

The fix: the exception is now captured into a local createError instead of being displayed immediately; finally closes progressDialog (and flushes it via processEvents()) unconditionally; only after the try/except/finally block completes does the code check createError and call errorDisplay. This guarantees the progress dialog is torn down before the modal error dialog appears, in both the success and failure paths.

Checked for regressions against the task-tracking invariant from the prior round: self.webodmTask = node.create_task(...) is only ever assigned if create_task returns successfully — if it raises, the assignment never happens and self.webodmTask stays None (it was already None, since _runWebODMTask guards on that at entry). So on the failure path, onRunWebODMTask's finally: self._updateTaskButtons() still correctly sees hasTask=False and re-enables Run. No interaction with the _updateTaskButtons() single-source-of-truth logic added in ce3f260.

No issues found in this delta. Combined with the fixes from the prior two rounds (duplicate-task guard, queue-depth off-by-one), I have no further blocking findings on this PR. The items the author flagged as declined-by-design (queuedTaskCount()'s extra poll-tick request) or explicitly out of scope (rerun combo, generateShortTaskName collisions, download_assets blocking) remain reasonable to leave for follow-up.

Still per the author: not exercised against a live NodeODM — that check should happen on Linux before merge.

Observed on a real node: two tasks with different UUIDs both showed
Name: SlicerReconstruction_15b1cf4b, and both mapped to one folder,
WebODM_SlicerReconstruction_15b1cf4b. The suffix is not the UUID -- it is
sha256(params)[:8], a pure function of the settings -- so any two runs with
the same settings are indistinguishable on the dashboard and collide on disk,
the second download landing on top of the first.

- generateShortTaskName appends a YYYYMMDD-HHMMSS stamp. The node name and
  the WebODM_<name> folder are then 1:1 and unique per run. The params hash
  stays so settings remain readable at a glance.
- Log the node task UUID and the download path when a task is created, so the
  console records the tie to the node's own identifier.
- Create the output folder at download time, not at task creation. It was
  created up front, so any task that was never downloaded (Stop Monitoring, a
  failure, a restart) left an empty WebODM_<name> folder that looked like
  output and sent Import Reconstructed Model hunting for an odm_texturing
  that was never coming.
- Sort the folder list in onImportModelClicked. os.listdir is in filesystem
  order, so `webodm_dirs[-1]` was an arbitrary folder despite being called
  latest_dir; with the timestamp suffix, sorting makes it genuinely the newest.

Does not address re-attaching to an abandoned task (Stop Monitoring is still
a one-way door). pyodm's Node.get_task(uuid) and NodeODM's GET /task/list
make that feasible; it wants its own PR, and the module already carries
commented-out Save/Restore Task buttons scoped for exactly that.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@claude

claude Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Claude finished @muratmaga's task in 1m 46s —— View job


Review: PR #84 (update) — 1ed3631 reviewed

  • Gather context (diff since last review: 564c7b7 → 1ed3631)
  • Review the new "identifiable run" changes for correctness/regressions
  • Post findings

Summary

1ed3631 makes two related changes to give each run a unique, identifiable output location: (1) generateShortTaskName now appends a YYYYMMDD-HHMMSS timestamp so repeated identical-parameter runs no longer collide on the same task name/output folder, and (2) webodmOutDir creation moved from task-creation time to download time (os.makedirs at ODM/ODM.py:1079), so a task that's stopped/failed/never downloaded no longer leaves a stray empty WebODM_<name> folder behind for Import Model to trip over.

Both of those are correct and well-motivated fixes for real problems.

One finding, posted inline on ODM/ODM.py:1108: the onImportModelClicked change to sorted(...) to find "the latest" output folder doesn't actually guarantee chronological order. The directory name is WebODM_{basePrefix}_{shortHash}_{stamp} — the timestamp is the last component, so a plain lexicographic sort of the whole name is dominated by basePrefix/shortHash, not the stamp. It only sorts correctly by time when every candidate folder shares the same prefix and hash (i.e. literal identical reruns — the case the timestamp fix targets). As soon as the dataset name or any parameter differs between two runs, sorted()[-1] can pick an older run over a newer one, silently importing a stale reconstruction. Suggested a fix using os.path.getmtime (or parsing the trailing stamp) instead of sorting the raw name.

No other issues found in this delta — uuid logging and the deferred os.makedirs at download time both look correct, and I didn't find any other call sites relying on webodmOutDir existing before download.

Combined with the fixes verified in the last three rounds (duplicate-task guard, queue-depth off-by-one, dialog-stacking on create failure), this is the only outstanding correctness finding on the PR. Per the author, the queue/upload/cancel/download behavior against a live NodeODM still needs verification on Linux before merge.

Comment thread ODM/ODM.py Resolved
… door

Slicer held exactly one task in self.webodmTask, and nothing could ever get it
back. Stop Monitoring, a Slicer restart, or a crash left the task running on
the node with no code path anywhere in the module able to download its results
-- the user's only recourse was the NodeODM dashboard. Naming the output folder
well says where results would have gone; it cannot fetch them.

The module already carried commented-out "Save Task"/"Restore Task" buttons and
stub handlers: the original author scoped this and never built it.

- "Reconnect to Task on Node..." lists what the node has (GET /task/list gives
  UUIDs only, so each is expanded via Task.info()), shows name/status/date/image
  count newest-first, and resumes monitoring the chosen one via
  Node.get_task(uuid).
- Results route to WebODM_<task name>, matching the naming scheme, so a
  reconnected task lands exactly where it would have originally. Tasks created
  outside Slicer have no name; those fall back to WebODM_task_<uuid8>.
- Reconnecting to an already-finished task downloads it immediately: the first
  poll is fired directly rather than waiting for the 5s tick.
- Reconnect is the inverse of the task controls, so it shares
  _updateTaskButtons(): available only when no task is tracked.

Tasks the node has forgotten are out of reach -- NodeODM's cleanup_tasks_after
defaults to 2880 minutes (48h). Noted in the button tooltip.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@claude

claude Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Claude finished @muratmaga's task in 2m 41s —— View job


Review: PR #84 (update) — 7df2b29 reviewed (Reconnect to Task)

  • Gather context (diff since last review: 1ed3631 → 7df2b29)
  • Review the new Reconnect-to-Task feature for correctness/regressions
  • Post findings

Summary

7df2b29 adds "Reconnect to Task on Node..." (onReconnectTaskClicked / attachToTask, ODM/ODM.py:1043-1149), letting Slicer re-attach to a task already on the node — the fix for "Stop Monitoring" being a one-way door. The plumbing itself is solid: it reuses _updateTaskButtons()/_stopMonitoringTimer() as the single source of truth (so it can't drift from the invariant fixed in ce3f260), guards on self.webodmTask is not None before doing anything, and correctly derives webodmOutDir from info.name to match the WebODM_<name> convention used at task creation.

Finding (posted inline on ODM/ODM.py:1108-1123): the picker can silently attach to the wrong task when two tasks render identical labels. describeTask labels each task as name | status | date(minute) | images_count. Before 1ed3631 added a timestamp to generateShortTaskName, task names were a pure hash of the params — so exactly the "dozen identical reconstructions" scenario this whole PR is about produces tasks with the same name, and therefore the same label here. Since PythonQt's QInputDialog.getItem only returns the selected string, labels.index(chosen) always resolves to the first matching row, so the user can't actually pick which of several identical-looking duplicates to reconnect to — the exact set of leftover tasks this feature is most likely to be used to clean up. Suggested fix: make each dialog row unique (e.g. prefix with index or a UUID fragment) and resolve the selection by index rather than by label lookup.

Minor/lower-confidence note (posted inline on ODM/ODM.py:1107): describeTask treats info.date_created as possibly falsy, but tasks.sort(key=lambda i: i.date_created, reverse=True) doesn't guard the same way — if any listed task has no creation date, the sort raises TypeError (can't compare None to datetime) and aborts the whole reconnect flow with a raw traceback instead of one of the friendly error dialogs used elsewhere in this method. Flagging since the code's own defensive handling elsewhere suggests this was anticipated as possible; I couldn't verify against pyodm's source whether TaskInfo.date_created can actually be None in practice (no network access to check), so treat this as worth a quick check rather than a confirmed bug.

No issues found with the timer/button lifecycle changes — they compose correctly with the guards added in ce3f260/564c7b7/1ed3631 from earlier rounds. As with the rest of this PR, the reconnect path (task listing, TaskInfo field names, actual node behavior) is unverified against a live NodeODM per the author's testing notes.

Comment thread ODM/ODM.py Resolved
Comment thread ODM/ODM.py Resolved
Every task was called SlicerReconstruction_<settings-hash>_<time>. None of that
says which photos went in, so two specimens uploaded with the same settings were
distinguishable only by a timestamp -- on the node, which has no idea what a
folder is, they were unidentifiable. The dataset identity already existed in the
input folder path; the module threw it away and substituted a constant.

- The 'name' field now defaults to the images folder's own name (UWBM_82409),
  sanitised for use in a folder name, and follows the folder selector until the
  user types their own (tracked via textEdited, which only fires for real typing).
  A task is now UWBM_82409_<hash>_<time>: which photos, which settings, when.

- Write a WebODM_<name>.json record beside where the results will land, holding
  the node's task UUID, node URL, image count, images folder and full options.
  The UUID is the only identifier unique by construction, but it lives only on
  the node, which forgets finished tasks after 48h; the record is what survives
  that, Stop Monitoring, and restarts. An images folder becomes self-describing:
  one .json per job submitted from it, next to the folder it will produce.

- Reconnect cross-references the node's task list against those records and marks
  which tasks came from this folder, and a matching record is authoritative for
  where results are downloaded.

- Guard against name collisions on disk. The stamp has one-second resolution, so
  two jobs submitted inside the same second produced one name -- the second job's
  record and results silently landing on the first's. Caught by a probe that
  submitted twice in the same second on its first run, so it is not theoretical
  for small datasets on a fast node. Names now get -2, -3 on collision.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@claude

claude Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Claude finished @muratmaga's task in 4m 27s —— View job


Review: PR #84 (update) — 8eada1c reviewed ("name tasks after the dataset, and record them on disk")

  • Gather context (diff since last review: 7df2b29 → 8eada1c)
  • Review the new task-naming / on-disk-record changes for correctness/regressions
  • Check interaction with prior findings (duplicate-label reconnect issue, stale-folder sort issue)
  • Post findings

Summary

8eada1c adds three things: the dataset name field now auto-tracks the images-folder basename (sanitized) until the user types their own; generateShortTaskName/uniqueTaskName dedupe against what's already on disk; and every created task now gets a WebODM_<name>.json record written beside the (eventually downloaded) results folder, which the Reconnect picker cross-references to tag tasks as "from this folder."

Main finding (posted inline on ODM/ODM.py:1356): this commit regresses Import Model. writeTaskRecord now writes WebODM_<name>.json into the same inputFolder that onImportModelClicked scans with d.startswith("WebODM_") and no os.path.isdir check. Since a task's record filename is literally its results-folder name plus .json, it always sorts lexicographically after that folder — so webodm_dirs[-1] picks the just-created .json record instead of the actual results directory, for essentially every task run through this code, whether or not the download completed. The fix is a one-line filter to require os.path.isdir(...) in that generator expression.

Minor/lower-confidence (posted inline on ODM/ODM.py:941): the new folder-derived dataset name is sanitized to safe filename characters, but a manually-typed dataset name (once the user edits the field and folder-tracking stops) is not — it flows unsanitized into the paths used for webodmOutDir/taskRecordPath/uniqueTaskName. Low severity (local desktop tool, same-user self-inflicted), but worth the same sanitizer for consistency.

No regressions found in the rest of the diff — the _datasetNameEdited flag correctly distinguishes textEdited (user typing) from programmatic setText, uniqueTaskName's collision loop terminates correctly, and attachToTask's new record-based folderKey lookup is consistent with what writeTaskRecord stores. The previously-flagged, still-open issues (raw-name lexicographic sort not guaranteeing chronological order once basePrefix/hash differ between runs; labels.index(chosen) ambiguity when two tasks render identical Reconnect-picker labels) are untouched by this commit — the new "from this folder" tag narrows but doesn't close the second one.

As with the rest of this PR, none of this has been exercised against a live NodeODM; per the author, that check still needs to happen on Linux before merge.

Comment thread ODM/ODM.py Resolved
Comment thread ODM/ODM.py Resolved
…ndings

Addresses the review of 8eada1c.

- Import Model was broken by 8eada1c, for every task. writeTaskRecord writes
  WebODM_<name>.json beside the results folder, onImportModelClicked matched on
  d.startswith("WebODM_") with no isdir check, and "WebODM_X.json" always sorts
  after "WebODM_X" -- so it picked the record file and went looking for
  odm_texturing inside a JSON file. Filter to directories.

- Order those folders by mtime rather than by name. The review was right that the
  earlier lexicographic sort only looked chronological while the prefix and hash
  were constant; a name now leads with the dataset name and a settings hash, so
  sorting by name reorders runs as soon as either differs. mtime is when the
  results actually landed.

- Sanitize a hand-typed dataset name. Only folder-derived names were cleaned, and
  folder-tracking stops the moment the user types their own -- so typed text was
  reaching webodmOutDir, taskRecordPath and uniqueTaskName unguarded.

- Lead the reconnect picker with the task's UUID. The picker returns the chosen
  string and we map it back with labels.index(), so two tasks rendering identical
  text would attach the wrong one; unnamed tasks sharing a status, date and image
  count do exactly that. UUIDs are unique by construction, and the UUID is also
  the first thing the dashboard shows, so it is what you match by eye.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@claude

claude Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Claude finished @muratmaga's task in 1m 31s —— View job


Review: PR #84 (update) — 86ed20f verified ("fix Import regression from the task records, and three review findings")

  • Gather context (diff since last review: 8eada1c → 86ed20f)
  • Verify the Import-regression fix
  • Verify fixes for the three flagged review findings
  • Check for regressions
  • Post findings

Summary

86ed20f addresses everything flagged in the last review round, and all four fixes check out:

  1. Import Model regression — fixed. onImportModelClicked's webodm_dirs scan (ODM/ODM.py:1374-1380) now filters to os.path.isdir(...) in addition to the "WebODM_" prefix, so writeTaskRecord's WebODM_<name>.json record file can no longer be picked instead of the actual results directory.

  2. Stale-sort (non-chronological) — fixed. The same block now sorts by os.path.getmtime(...) instead of the raw folder name, so webodm_dirs[-1] is genuinely the most-recently-landed results folder regardless of whether the dataset name or params differ between runs (previously lexicographic order was dominated by basePrefix/hash, not the trailing timestamp).

  3. Reconnect-picker label collisions — fixed, via a cleaner mechanism than I suggested. describeTask (line 1163) now leads each label with info.uuid[:8]. Since UUIDs are unique per task, this eliminates duplicate-label collisions at the source rather than requiring labels.index(chosen) to be replaced with index-based resolution — simpler and correct, and it also matches the NodeODM dashboard's own UUID-first display, so it doubles as an eyeball cross-reference.

  4. Unsanitized manually-typed dataset name — fixed. New sanitizeDatasetName() (line 477) is now the single sanitizer used both for folder-derived names (datasetNameFromFolder) and the free-typed datasetNameLineEdit text used as prefix in generateShortTaskName (line 951). Verified the regex/strip combination correctly neutralizes path separators either way (e.g. "../etc/passwd" → "etc_passwd", not something that escapes inputFolder).

No new regressions found: readTaskRecords (line 1154) already required fn.endswith(".json") in addition to the prefix, so it was never affected by the directory/record-file ambiguity that broke Import Model — only the Import Model scan had the gap, and that's now closed.

One previously-flagged item remains open (unchanged by this commit, still low-confidence/minor): onReconnectTaskClicked's tasks.sort(key=lambda i: i.date_created, reverse=True) (line 1241) still doesn't guard against a possible None date_created, while describeTask right next to it does (if info.date_created else "?"). If pyodm can actually return a task with no creation date, this sort raises TypeError and aborts the reconnect flow with a raw traceback. Not part of the "three findings" this commit targeted, and I still can't confirm from here whether TaskInfo.date_created can be None in practice — flagging again only so it doesn't get lost, not as a blocker.

Combined with everything verified across earlier rounds (duplicate-task guard, queue-depth off-by-one, dialog-stacking fix, task-naming/on-disk-record correctness), I have no blocking findings on the PR at this commit. Per the author, the queue/upload/cancel/reconnect/download behavior against a live NodeODM still needs verification on Linux before merge.

@muratmaga muratmaga changed the title ODM: stop the UI from silently queueing duplicate tasks ODM: stop duplicate tasks, make them identifiable, and make results recoverable Jul 15, 2026
@muratmaga

Copy link
Copy Markdown
Collaborator Author

Review reconciliation (86ed20f) — all findings closed

Fixed and verified by the review: the Import Model regression (isdir filter), the non-chronological sort (now mtime), the picker-label collisions (UUID-led labels), and the unsanitized typed dataset name (single sanitizeDatasetName).

date_created possibly None — dismissing, not reachable. The review couldn't confirm this from its side; the pyodm source settles it. TaskInfo.__init__ builds it as:

self.date_created = datetime.utcfromtimestamp(int(json['dateCreated'] / 1000.0))

A direct index, not .get(), and unconditionally wrapped in datetime.utcfromtimestamp. So an absent key raises KeyError during construction — which the per-task try/except in onReconnectTaskClicked already catches, skipping that task — and a present key always yields a datetime. There's no path that produces None, so tasks.sort(key=lambda i: i.date_created) cannot raise TypeError.

The inconsistency the review spotted is real but backwards: describeTask's if info.date_created else "?" is the dead code, not the sort. Leaving it — it's harmless, and removing it is churn on a branch that's otherwise done.

Testing status. Driven against a live GPU NodeODM on a MorphoCloud instance: upload progress, the queue prompt, Run correctly refusing while a task is monitored, and Reconnect attaching to a live task. Not driven on Linux: Cancel against a real task, and the naming/record work, which postdates that session. Widget-level behaviour for all of it was exercised in a live Slicer against a stubbed node.

@muratmaga
muratmaga merged commit 89a5603 into master Jul 15, 2026
1 check passed
@muratmaga
muratmaga deleted the odm-prevent-duplicate-tasks branch July 15, 2026 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant