From 20cd71840a3a9edb042a8689cc606d62368daae0 Mon Sep 17 00:00:00 2001 From: salman Date: Sun, 25 Oct 2026 10:07:16 +0100 Subject: [PATCH] Add Electron run downloads with writable-folder fallback Offer HTTPS downloads for missing Fit/Plot inputs and independent-series runs that need fitting. Preserve reused and skipped results without downloading raw data. Prefer the configured Data directory and fall back to persistent per-user storage when it is read-only. Keep user XML unchanged and provide native/WSL search paths through MUSRFULLDATAPATH. Stream cancellable downloads into temporary files, validate lengths, publish without overwriting existing data, and remember exact filenames for offline reuse. Add regression coverage and document the desktop workflow. --- CHANGELOG.md | 15 +- docs/source/platforms.rst | 25 +++- docs/source/preferences.rst | 14 +- index.html | 1 + main.js | 67 ++++++++- muSRFitelec.js | 166 ++++++++++++++++++++- muSRFitlib.js | 58 +++++++- package.json | 3 +- preload.js | 20 +++ run-data-download.js | 221 ++++++++++++++++++++++++++++ tests/electron-run-data.test.js | 246 ++++++++++++++++++++++++++++++++ 11 files changed, 824 insertions(+), 12 deletions(-) create mode 100644 run-data-download.js create mode 100644 tests/electron-run-data.test.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 936d670..506b8c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,19 @@ release path documented in [`TODO.md`](TODO.md). ## 1.0.0-rc.5 (unreleased) +### Desktop run downloads +- Fit and Plot can retrieve missing selected runs from musruser.psi.ch over + HTTPS after a confirmation showing the file count, total size, and destination. + Independent series request data only for entries that need fitting. +- Downloads prefer the configured Data directory. Read-only instrument/year + folders fall back to a persistent personal `run-data` folder, whose location + is shown in Preferences. Data directory settings and user startup XML files + are preserved; local tools receive the additional search roots through + `MUSRFULLDATAPATH`, with Windows paths translated for WSL2. +- Transfers support cancellation, validate their lengths, and publish completed + files without replacing existing data. Exact filenames are remembered for + offline reuse across sessions, including historical campaign names. + ### Parameter ordering - The model catalogue now lists the physical parameters of a theory function first (asymmetry, then relaxation/lineshape, then precession frequency, then @@ -370,4 +383,4 @@ release path documented in [`TODO.md`](TODO.md). bounds, t0/background, FFT, and missing-data workflows. - Integration checks exercising real `musrfit`, `msr2data`, and `musrview`. - Editor-owned MSR titles are no longer replaced unexpectedly by `musrfit -t`. -- First scan-detection and built-in plot-template tasks shipped. \ No newline at end of file +- First scan-detection and built-in plot-template tasks shipped. diff --git a/docs/source/platforms.rst b/docs/source/platforms.rst index 30bd6cc..7f1c727 100644 --- a/docs/source/platforms.rst +++ b/docs/source/platforms.rst @@ -16,7 +16,7 @@ the command-line tools live. - Locally via the ``PATH``. - On the server behind the CGI endpoint. * - Data access - - Any local directory under the configured data root. + - Local data plus optional downloads of missing selected runs. - What the server data tree exposes. * - Preferences - Per-user, through **File / Preferences**. @@ -58,4 +58,25 @@ once per user (see ``packaging/wsl2/README.md``). The workflow chapters of this manual apply to both editions. Where a step is specific to one edition (handling files, Preferences), the text says so -explicitly. \ No newline at end of file +explicitly. + +Downloading missing runs +------------------------ + +Fit and Plot check selected main runs and ADDRUN members before preparing MSR +files. If files are missing, the desktop offers to download them over HTTPS +from ``musruser.psi.ch`` and continue. Independent series fits request data +only for entries that need fitting; reused results and explicit skips do not +trigger downloads. Runs absent from the server are still reported as missing. + +The writable Data directory is preferred. When it is read-only, a persistent +folder under the user's application data directory is used instead. Exact +filenames and formats are remembered across sessions, and incomplete downloads +are never published as run files. Expert MSRs with manually specified RUN +paths continue to use their existing file-resolution rules. + +Generated download RUN paths are relative to the stored data tree. muSRFlow +passes the matching search roots to its tools through ``MUSRFULLDATAPATH``, +including translated paths for Windows/WSL2. To run such an MSR from a terminal +outside muSRFlow, set that variable to the download root or add the root to +your own musrfit startup XML. diff --git a/docs/source/preferences.rst b/docs/source/preferences.rst index 9f480f4..4cb3eb9 100644 --- a/docs/source/preferences.rst +++ b/docs/source/preferences.rst @@ -13,6 +13,18 @@ Data directory The root of the instrument data tree (for example ``/psi.ch/group/lmu/public/data``). Run paths are resolved under it. + When Fit or Plot needs runs that are missing locally, the desktop can + download them from ``musruser.psi.ch`` after confirmation. Downloads go + into this directory when the instrument/year folder is writable. Otherwise + they go into ``run-data`` under your personal muSRFlow application data + directory. The hint under the Data directory shows that fallback path, + and the confirmation lists the actual destination and total size. + + Both locations remain available to subsequent fits, including offline. + Cancelling a transfer discards its incomplete file. Your selected Data + directory and startup XML are preserved; muSRFlow supplies the additional + search paths through ``MUSRFULLDATAPATH`` when launching its tools. + musrfit startup XML The ``musrfit_startup.xml`` used to resolve portable run names. Leave it as **auto-detect** and muSRFlow looks for the standard installation file; @@ -60,4 +72,4 @@ Output file suffixes Save stores the values for the next session; **Cancel** closes the dialog without changing anything. Directory changes take effect from the next -action that resolves or writes files. \ No newline at end of file +action that resolves or writes files. diff --git a/index.html b/index.html index a21288d..4393d8a 100644 --- a/index.html +++ b/index.html @@ -749,6 +749,7 @@ pairs of a multi-run (global) fit."> + Missing run files can be downloaded from musruser.psi.ch. Read-only directories use a personal data folder.