Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
537f5a5
NMR: reject open-shell and meta-GGA up front; run UHF singlets as RHF…
NCCU-Schultz-Lab Nov 12, 2026
b86805a
Thermo sigma from QuantUI's point group; ladder-robust detection (aud…
NCCU-Schultz-Lab Nov 12, 2026
3e8c2bf
Exported script: UHF/UKS HOMO-LUMO gap and one-electron UHF crash (au…
NCCU-Schultz-Lab Nov 12, 2026
d97db97
Carry dispersion and SCF-rescue provenance on Frequency/NMR results (…
NCCU-Schultz-Lab Nov 12, 2026
369082e
Check displaced-SCF convergence in the IR/Raman FD loops (audit SCF-8…
NCCU-Schultz-Lab Nov 12, 2026
1f4cb35
CPU Raman FD loop: no GPU offload, host copy of dm0 (audit SCF-9)
NCCU-Schultz-Lab Nov 12, 2026
22684d1
perturb_along_mode: normalise the mode so the step is the recorded 0.…
NCCU-Schultz-Lab Nov 12, 2026
cb29392
IRC: tell mirror-image ends apart in the same-minimum check (audit GE…
NCCU-Schultz-Lab Nov 12, 2026
f5db0e5
PES scan: keep angle scans inside (0, 180) and bend a linear start (a…
NCCU-Schultz-Lab Nov 12, 2026
ee84a95
PES scan: rotate the whole moving group in angle/dihedral scans (audi…
NCCU-Schultz-Lab Nov 12, 2026
792c1b1
Symmetry: pair C3v e levels robustly when relabelling from Cs (audit …
NCCU-Schultz-Lab Nov 12, 2026
f450ff1
Preopt: pass the molecular charge and spin to GFN-FF (audit GEOM-6)
NCCU-Schultz-Lab Nov 12, 2026
ca610c1
Symmetry: keep a genuine C3v a2 level instead of dropping to Cs (audi…
NCCU-Schultz-Lab Nov 12, 2026
949c3c7
Upload: trust the MOL/SDF/MOL2 3-D flag, embed every 2-D drawing (aud…
NCCU-Schultz-Lab Nov 12, 2026
3bf4415
Upload: MOL/SDF/MOL2 keep setup charge/multiplicity unless the file s…
NCCU-Schultz-Lab Nov 12, 2026
6cd160c
Calibration: log gpu_used / gpu_name / density_fit in perf records (a…
NCCU-Schultz-Lab Nov 12, 2026
031b959
Checkpoint: restart listing counts Frequency item sets and Reorg legs…
NCCU-Schultz-Lab Nov 12, 2026
85dfb6f
Search: answer bundled-library names offline first; whole-word fuzzy …
NCCU-Schultz-Lab Nov 12, 2026
0154fff
Validation: reject non-finite coords, impossible spin, truncated XYZ …
NCCU-Schultz-Lab Nov 12, 2026
b146423
Guards: refuse a charge that leaves no electrons (audit DATA-8 follow…
NCCU-Schultz-Lab Nov 12, 2026
1cd9321
Vib viewer: keep the single viewer across theme toggles; key cache on…
NCCU-Schultz-Lab Nov 12, 2026
fd4b1af
Orbitals: spin-aware HOMO-LUMO gap and alpha/beta diagram for UHF/UKS…
NCCU-Schultz-Lab Nov 12, 2026
52c4067
Orbitals: 1-based MO numbers in the index input, gallery and errors (…
NCCU-Schultz-Lab Nov 12, 2026
5a11ef1
Isosurfaces: no writes into read-only results; overwrite cubes, don't…
NCCU-Schultz-Lab Nov 12, 2026
a1f207c
Plotly: load plotly.js once per page; in-app figures stop inlining it…
NCCU-Schultz-Lab Nov 12, 2026
7808594
Orbitals: one-electron UHF uses the alpha HOMO-LUMO gap (audit VIZ-4 …
NCCU-Schultz-Lab Nov 12, 2026
742cabb
Tests: keep the suite out of the real ~/.quantui (audit INFRA-1)
NCCU-Schultz-Lab Nov 12, 2026
32ea7f0
Tests: golden values for TD-DFT excitations and NMR shieldings (audit…
NCCU-Schultz-Lab Nov 12, 2026
617cf5a
Tests: build the packaging-test wheel once, offline, without .venv (a…
NCCU-Schultz-Lab Nov 12, 2026
3e79070
Pin dev-extra mypy to ~=1.10.0 like CI and pre-commit (audit INFRA-4)
NCCU-Schultz-Lab Nov 12, 2026
96107a7
Docs: make the Changelog page's snippet include resolve (audit INFRA-5)
NCCU-Schultz-Lab Nov 12, 2026
e1f3897
PNG export: show the real Kaleido/Chrome error (audit INFRA-6)
NCCU-Schultz-Lab Nov 12, 2026
5d5c9b4
Release workflow: tag/version check, no PyPI for pre-releases, read-o…
NCCU-Schultz-Lab Nov 12, 2026
97ebfb0
CI: run the viewer tests on Python 3.13 without PySCF (audit INFRA-9)
NCCU-Schultz-Lab Nov 12, 2026
b9f535a
History View Analysis: fix swapped log-panel arguments (audit UI-3/AP…
NCCU-Schultz-Lab Nov 12, 2026
96d5966
Theme: drop stray "}}" that invalidated six chrome CSS rules (audit U…
NCCU-Schultz-Lab Nov 12, 2026
d01d4ed
Formatters: escape result.json strings in result cards (audit UI-4)
NCCU-Schultz-Lab Nov 12, 2026
17f5410
Escape untrusted strings rendered in widgets.HTML (audit APP-12, DATA-9)
NCCU-Schultz-Lab Nov 12, 2026
92206b2
History cards: per-calc-type labels, tolerate old schemas (audit UI-8)
NCCU-Schultz-Lab Nov 12, 2026
06d6298
Measure/Edit/PES highlights: one JS hook per viewer slot (audit UI-6)
NCCU-Schultz-Lab Nov 12, 2026
79c1f46
Theme: tokens for light-only text colours, AA faint/subtle text (audi…
NCCU-Schultz-Lab Nov 12, 2026
60ed448
Escape export/download error text in status HTML (audit APP-12 follow…
NCCU-Schultz-Lab Nov 12, 2026
4a02ae9
Report a failed result save instead of swallowing it (audit APP-5)
NCCU-Schultz-Lab Nov 12, 2026
9f687cb
Keep a finished result when Cancel arrives late (audit APP-10)
NCCU-Schultz-Lab Nov 12, 2026
1fe4b31
Make pre-optimization fallbacks honest; seed before pre-opt (audit AP…
NCCU-Schultz-Lab Nov 12, 2026
08be411
Calibration: always reset the panel; exclude Run (audit APP-13)
NCCU-Schultz-Lab Nov 12, 2026
7e2979d
Structure exports follow the run's molecule and folder (audit APP-8, …
NCCU-Schultz-Lab Nov 12, 2026
74e9c0d
Reset Edit Structure state on molecule loads; renumber freezes (audit…
NCCU-Schultz-Lab Nov 12, 2026
744e583
Export provenance from the displayed result, not the dropdowns (audit…
NCCU-Schultz-Lab Nov 12, 2026
2e5005c
Script export follows the run's molecule and folder too (audit UI-5)
NCCU-Schultz-Lab Nov 12, 2026
cee65e0
Docs: state the new plotly embedding rule for agents (audit VIZ-2)
NCCU-Schultz-Lab Nov 12, 2026
2c297f8
SLURM monitor: never leave Run locked; atomic job records (audit HPC-3)
NCCU-Schultz-Lab Nov 12, 2026
de8899a
Track a requeued SLURM job to its newest attempt dir (audit HPC-6)
NCCU-Schultz-Lab Nov 12, 2026
1a0b1df
SLURM: give up on a job Slurm no longer knows (audit HPC-2)
NCCU-Schultz-Lab Nov 12, 2026
96fe3f3
Never overwrite a job record by reusing its request id (audit HPC-4)
NCCU-Schultz-Lab Nov 12, 2026
ffb0980
SLURM ingest: keep the geometry for every calc type (audit HPC-5)
NCCU-Schultz-Lab Nov 12, 2026
a4d6f97
quantui-batch --from: keep the source solvent; refuse unconverged sou…
NCCU-Schultz-Lab Nov 12, 2026
3bb5327
Every Voila/Jupyter launch gets a per-run token (audit HPC-8)
NCCU-Schultz-Lab Nov 12, 2026
2a64312
Tests: gallery captions are 1-based MO numbers (audit VIZ-5 follow-up)
NCCU-Schultz-Lab Nov 12, 2026
0c24e7e
Pre-opt preview: don't shadow the html module (CI mypy)
NCCU-Schultz-Lab Nov 12, 2026
2080d23
Fix Windows CI: PySCF guards, staging-root isolation, POSIX-only bash…
NCCU-Schultz-Lab Nov 12, 2026
d183a4c
Tests: pin only the occupied NH3 labels in the noisy-geometry test
NCCU-Schultz-Lab Nov 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,13 @@ Source of truth: `_PANEL_META` / `_PANEL_REGISTRY` in `app.py`.
(`_show_orbital_diagram`, `_show_vib_animation`, `_show_ir_spectrum`,
`_show_pes_scan_result`) return `bool` and must not call `_activate_ana_panel()`.

8. **Never use `include_plotlyjs="cdn"` in widget HTML.** CDN requests fail
silently in offline classroom deployments — the figure div stays blank with no
error anywhere. Use `include_plotlyjs="require"` (Voilà/RequireJS path) or
`include_plotlyjs=True` (inline bundle, works everywhere). This rule is enforced
by `tests/test_code_quality.py::test_no_cdn_plotlyjs`.
8. **Render in-app Plotly figures with `quantui.plotly_embed.figure_html`.**
It loads the installed package's plotly.js once per page and embeds each
figure with `include_plotlyjs=False`. Never use `"cdn"` (fails silently
offline) or `"require"` (plotly ≥ 6 has no such mode: it inlines the full
~4.8 MB bundle per figure). Standalone exported HTML files keep
`include_plotlyjs=True` so they work on their own. Enforced by
`tests/test_code_quality.py`.

9. **All `.observe()` callbacks must be wrapped with `_safe_cb`.** Exceptions in
raw `.observe()` handlers disappear into the kernel console — invisible in Voilà.
Expand Down
4 changes: 3 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ updates:
- dependency-name: pyscf
update-types: ["version-update:semver-major"]

# GitHub Actions pinned to SHA via Dependabot — keeps runners current
# GitHub Actions are referenced by version tag (e.g. actions/checkout@v7,
# pypa/gh-action-pypi-publish@release/v1), NOT pinned to commit SHAs;
# Dependabot bumps those tags weekly.
- package-ecosystem: github-actions
directory: /
schedule:
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ on:
pull_request:
branches: [main]

# Least privilege: every job here only checks out and tests the code.
# (Caches and artifacts use the runner's own token, not GITHUB_TOKEN, and
# Codecov uploads with its own token.)
permissions:
contents: read

jobs:
# ── Linux: full suite including PySCF-dependent tests ─────────────────────
test-linux:
Expand Down Expand Up @@ -51,6 +57,35 @@ jobs:
files: coverage.xml
fail_ci_if_error: false

# ── Browser viewer: Python 3.13, no PySCF ─────────────────────────────────
# The browser Viewer (packaging/viewer/browser/build.sh, deployed by
# pages.yml) runs QuantUI on Pyodide's Python 3.13, outside the 3.9-3.11
# matrix above, and without PySCF. This job runs the viewer tests in that
# shape: core install only (no [pyscf] extra), on 3.13 (audit INFRA-9).
test-viewer-py313:
name: Viewer tests (Python 3.13, no PySCF)
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v7

- name: Set up Python 3.13
uses: actions/setup-python@v7
with:
python-version: "3.13"
cache: pip

- name: Install QuantUI (core only) and pytest
run: |
python -m pip install --upgrade pip
pip install -e . "pytest>=7.0.0" "pytest-xdist>=3.0.0" "pytest-mock>=3.10.0"

- name: Confirm PySCF is not installed
run: python -c "import importlib.util, sys; sys.exit(importlib.util.find_spec('pyscf') is not None)"

- name: Run viewer tests
run: pytest tests/test_app_viewer.py tests/test_viewer_audit.py --no-header -q -n0

# ── Windows: non-PySCF suite ───────────────────────────────────────────────
test-windows:
name: Tests (windows-latest, Python 3.11)
Expand Down
32 changes: 29 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ on:
types: [published]
workflow_dispatch: {}

# Least privilege by default: the build job only needs to read the repo. The
# publish jobs set their own `permissions:` (id-token for OIDC), which
# replaces this block for those jobs.
permissions:
contents: read

jobs:
# ── Build once, reuse the same artifact everywhere ───────────────────────
# Building only once (rather than in each publish job) guarantees the exact
Expand Down Expand Up @@ -53,6 +59,25 @@ jobs:
/tmp/wheel-check/bin/pip install --quiet dist/*.whl
/tmp/wheel-check/bin/python -c "import quantui; print(quantui.__version__)"

- name: Check the release tag matches the package version
# A Release tagged v0.12.0 on a tree still saying 0.11.1 would build
# and "succeed" on TestPyPI (skip-existing hides the duplicate) and
# only fail, or worse publish the wrong version, at the PyPI step.
# Compares the tag with both pyproject.toml and the __version__ of
# the wheel just built. Release events only: a workflow_dispatch
# rehearsal has no tag.
if: github.event_name == 'release'
env:
TAG: ${{ github.event.release.tag_name }}
run: |
PYPROJECT_VERSION=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
WHEEL_VERSION=$(/tmp/wheel-check/bin/python -c "import quantui; print(quantui.__version__)")
echo "tag=$TAG pyproject=$PYPROJECT_VERSION quantui.__version__=$WHEEL_VERSION"
if [ "$TAG" != "v$PYPROJECT_VERSION" ] || [ "$TAG" != "v$WHEEL_VERSION" ]; then
echo "::error::Release tag '$TAG' does not match v<version> (pyproject.toml: $PYPROJECT_VERSION, quantui.__version__: $WHEEL_VERSION). Bump the version or fix the tag."
exit 1
fi

- uses: actions/upload-artifact@v7
with:
name: dist
Expand Down Expand Up @@ -86,14 +111,15 @@ jobs:
# version. Skip rather than fail the job in that case.
skip-existing: true

# ── PyPI — only for an actual published Release ──────────────────────────
# ── PyPI — only for an actual published, non-pre-release Release ─────────
# workflow_dispatch intentionally has no path to this job: a manual
# rehearsal run must NEVER be able to publish to production PyPI, so the
# `if` below excludes it rather than relying on environment protection
# alone as the only safeguard.
# alone as the only safeguard. A GitHub *pre-release* also stops after
# TestPyPI: marking a Release as pre-release must not ship it to students.
publish-pypi:
name: Publish to PyPI
if: github.event_name == 'release'
if: github.event_name == 'release' && !github.event.release.prerelease
needs: [build, publish-testpypi]
runs-on: ubuntu-latest
environment:
Expand Down
6 changes: 4 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ That line **is** the cloud/local boundary:
- **All UI logic lives in the package** — `QuantUIApp` in `quantui/app.py` plus
its `quantui/app_*.py` companion modules; the notebook is a 3-cell launcher
only (DEC-002).
- **Plotly embedding is `include_plotlyjs="require"` in the app (inline for
standalone exports), never `"cdn"`** (DEC-010, guarded by
- **In-app Plotly figures go through `quantui.plotly_embed.figure_html`
(plotly.js loaded once per page from the installed package,
`include_plotlyjs=False`); standalone exports inline it; never `"cdn"` or
`"require"`** (DEC-010 as amended 2026-11-12, guarded by
`tests/test_code_quality.py`).
- **Analysis panels are always visible; content is swapped, not containers
shown/hidden** (DEC-009).
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,12 @@ no rebuild.

| Platform | File | Action |
| --- | --- | --- |
| Windows | [`launchers/launch-native.bat`](https://github.com/The-Schultz-Lab/QuantUI/blob/main/launchers/launch-native.bat) | Activates the `quantui` conda env inside WSL Ubuntu, runs Voilà, and opens `http://localhost:8867` |
| Windows | [`launchers/launch-native.bat`](https://github.com/The-Schultz-Lab/QuantUI/blob/main/launchers/launch-native.bat) | Activates the `quantui` conda env inside WSL Ubuntu, runs Voilà, and opens `http://localhost:8867/?token=…` (a new login token each launch) |
| macOS | [`launchers/launch-native.command`](https://github.com/The-Schultz-Lab/QuantUI/blob/main/launchers/launch-native.command) | Activates the local `quantui` conda env directly (no WSL needed) and does the same |
| Linux / WSL | [`launchers/launch-native.sh`](https://github.com/The-Schultz-Lab/QuantUI/blob/main/launchers/launch-native.sh) | Run `./launchers/launch-native.sh` from a Linux or WSL terminal; activates `quantui` and does the same |

All launchers reuse port `8867`, so you can keep the same browser tab pinned
across platforms. They **auto-detect your conda installation** — miniforge
All launchers reuse port `8867` and open the app with a fresh per-launch login
token, so other users on the machine cannot reach your session. They **auto-detect your conda installation** — miniforge
(recommended), miniconda, or anaconda, in your home directory or a system
prefix — so no path editing is needed regardless of which you installed.

Expand Down
11 changes: 7 additions & 4 deletions apptainer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ automatically:
| `launchers/launch-dev.bat` | Development mode — uses local `notebooks/` (no rebuild needed for notebook edits) |

Double-click either file. The browser opens automatically at
[http://localhost:8866](http://localhost:8866).
`http://localhost:8866/?token=...` (a fresh login token each launch).

### Linux / WSL — command line

Expand All @@ -153,7 +153,9 @@ Launches the notebook as a clean widget-only interface. Students see no code.
apptainer run quantui.sif app
```

Then open a browser at [http://localhost:8866](http://localhost:8866).
Then open the URL it prints, `http://127.0.0.1:8866/?token=...`. The token
is new on every launch (set `QUANTUI_APP_TOKEN` to choose it); it keeps other
users on the same machine out of your session.

#### JupyterLab mode — for exploration or development

Expand All @@ -171,12 +173,13 @@ Note: changes to `quantui/` Python files still require a rebuild.

```bash
cd /path/to/QuantUI
TOKEN=$(python3 -c 'import secrets; print(secrets.token_urlsafe(24))')
apptainer exec quantui.sif voila notebooks/molecule_computations.ipynb \
--no-browser --port=8866 \
--no-browser --port=8866 --Voila.ip=127.0.0.1 "--Voila.token=$TOKEN" \
--ServerApp.disable_check_xsrf=True
```

Then open [http://localhost:8866](http://localhost:8866).
Then open `http://127.0.0.1:8866/?token=$TOKEN` (`echo` it to see it).

#### Results directory

Expand Down
12 changes: 11 additions & 1 deletion apptainer/quantui.def
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,18 @@ EOF
MODE="${1:-lab}"
shift 2>/dev/null || true
if [ "$MODE" = "app" ]; then
# Loopback only, with a per-run token (QUANTUI_APP_TOKEN when a launcher
# sets it), so other users on the host cannot drive the session.
# Standalone Voila reads no token from the environment, hence the option.
TOKEN="${QUANTUI_APP_TOKEN:-$(python -c 'import secrets; print(secrets.token_urlsafe(24))')}"
PORT=8866
for a in "$@"; do
case "$a" in --port=*) PORT="${a#--port=}" ;; esac
done
echo "QuantUI: open http://127.0.0.1:${PORT}/?token=${TOKEN}"
exec voila /opt/quantui/notebooks/molecule_computations.ipynb \
--no-browser --port=8866 "${@}"
--no-browser --port=8866 --Voila.ip=127.0.0.1 \
"--Voila.token=${TOKEN}" "${@}"
else
exec jupyter lab --ip=0.0.0.0 --no-browser --allow-root "${@}"
fi
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--8<-- "../CHANGELOG.md"
--8<-- "CHANGELOG.md"
16 changes: 16 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@ For everything else, use WSL or Apptainer ([Platform Support](platforms.md)).
| `pyfock-gpu-cuda12x` / `pyfock-gpu-cuda13x` | CuPy for PyFock's GPU path |
| `dev` | Tests and linters (pytest, ruff, black, mypy, pre-commit) |

## PNG plot export

Saving a spectrum or diagram as **PNG** uses Plotly's
[Kaleido](https://github.com/plotly/Kaleido) engine (installed with QuantUI).
Kaleido 1.x does not bundle a browser: it drives a **Chrome or Chromium**
already on the machine. Without one, PNG export fails with
"Kaleido requires Google Chrome to be installed". Either install Chrome or
Chromium from your OS, or download a private copy with

```bash
plotly_get_chrome
```

HTML and CSV exports do not need a browser. The Apptainer image does not
include Chrome yet, so use HTML or CSV export there.

## Next steps

- [Tutorials](tutorials.md)
Expand Down
16 changes: 14 additions & 2 deletions launchers/launch-app.bat
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,26 @@ if not exist "%SIFDIR%quantui.sif" (
REM Convert the folder holding the .sif to a WSL path for portability
for /f "delims=" %%i in ('wsl wslpath -a "%SIFDIR%"') do set WSLPATH=%%i

REM Per-run login token: without one, any other local user or process could
REM drive the app. WSLENV hands QUANTUI_APP_TOKEN to the WSL side through the
REM environment, not a command line.
set "QUANTUI_APP_TOKEN="
for /f "delims=" %%t in ('powershell -NoProfile -Command "[guid]::NewGuid().Guid + [guid]::NewGuid().Guid"') do set "QUANTUI_APP_TOKEN=%%t"
if not defined QUANTUI_APP_TOKEN (
echo ERROR: could not create a login token ^(is PowerShell available?^)
pause
exit /b 1
)
if defined WSLENV (set "WSLENV=%WSLENV%:QUANTUI_APP_TOKEN") else (set "WSLENV=QUANTUI_APP_TOKEN")

REM Launch Voila in a new WSL window (stays open so you can see logs)
start "QuantUI" wsl -d Ubuntu -- bash -c "cd '%WSLPATH%' && apptainer run quantui.sif app"

REM Wait for Voila to start, then open the browser
echo Waiting for Voila to start...
timeout /t 6 /nobreak > nul
start http://localhost:8866
start http://localhost:8866/?token=%QUANTUI_APP_TOKEN%

echo.
echo App is running at http://localhost:8866
echo App is running at http://localhost:8866/?token=%QUANTUI_APP_TOKEN%
echo Close the WSL window to stop the server.
18 changes: 15 additions & 3 deletions launchers/launch-dev.bat
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,27 @@ echo.
REM Convert the repo root to a WSL path for portability
for /f "delims=" %%i in ('wsl wslpath -a "%REPO%"') do set WSLPATH=%%i

REM Per-run login token: without one, any other local user or process could
REM drive the app. WSLENV hands QUANTUI_APP_TOKEN to the WSL side through the
REM environment, not a command line.
set "QUANTUI_APP_TOKEN="
for /f "delims=" %%t in ('powershell -NoProfile -Command "[guid]::NewGuid().Guid + [guid]::NewGuid().Guid"') do set "QUANTUI_APP_TOKEN=%%t"
if not defined QUANTUI_APP_TOKEN (
echo ERROR: could not create a login token ^(is PowerShell available?^)
pause
exit /b 1
)
if defined WSLENV (set "WSLENV=%WSLENV%:QUANTUI_APP_TOKEN") else (set "WSLENV=QUANTUI_APP_TOKEN")

REM Uses the local notebook on disk instead of the baked-in copy.
REM Edits to notebooks/ take effect immediately — no container rebuild needed.
start "QuantUI [dev]" wsl -d Ubuntu -- bash -c "cd '%WSLPATH%' && apptainer exec --cleanenv quantui.sif voila notebooks/molecule_computations.ipynb --no-browser --port=8866 --ServerApp.disable_check_xsrf=True"
start "QuantUI [dev]" wsl -d Ubuntu -- bash -c "cd '%WSLPATH%' && apptainer exec --cleanenv quantui.sif voila notebooks/molecule_computations.ipynb --no-browser --port=8866 --Voila.ip=127.0.0.1 --Voila.token=$QUANTUI_APP_TOKEN --ServerApp.disable_check_xsrf=True"

echo Waiting for Voila to start...
timeout /t 6 /nobreak > nul
start http://localhost:8866
start http://localhost:8866/?token=%QUANTUI_APP_TOKEN%

echo.
echo Dev server running at http://localhost:8866
echo Dev server running at http://localhost:8866/?token=%QUANTUI_APP_TOKEN%
echo Edit notebooks/ and refresh the browser — no rebuild needed.
echo Close the WSL window to stop.
16 changes: 14 additions & 2 deletions launchers/launch-native-jupyter.bat
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ REM Clears quantui/__pycache__ on every launch to prevent stale .pyc bytecode
REM (WSL2 DrvFs does not reliably propagate Windows-side mtime changes, so Python
REM may load pre-edit bytecode even after source changes).
REM PYTHONDONTWRITEBYTECODE=1 prevents a new stale cache from accumulating.
REM Per-run login token: without one, any other local user or process could
REM drive the app. WSLENV hands QUANTUI_APP_TOKEN to the WSL side through the
REM environment, not a command line.
set "QUANTUI_APP_TOKEN="
for /f "delims=" %%t in ('powershell -NoProfile -Command "[guid]::NewGuid().Guid + [guid]::NewGuid().Guid"') do set "QUANTUI_APP_TOKEN=%%t"
if not defined QUANTUI_APP_TOKEN (
echo ERROR: could not create a login token ^(is PowerShell available?^)
pause
exit /b 1
)
if defined WSLENV (set "WSLENV=%WSLENV%:QUANTUI_APP_TOKEN") else (set "WSLENV=QUANTUI_APP_TOKEN")

start "QuantUI [native-jupyter]" wsl -d Ubuntu --cd "%WSLPATH%" -- bash ./launchers/launch-native-jupyter.sh

echo Waiting for JupyterLab to start on localhost:8868...
Expand All @@ -57,13 +69,13 @@ goto done

:open_browser
set OPENED=1
start http://127.0.0.1:8868/lab/tree/notebooks/molecule_computations.ipynb
start http://127.0.0.1:8868/lab/tree/notebooks/molecule_computations.ipynb?token=%QUANTUI_APP_TOKEN%

:done

echo.
if "%OPENED%"=="1" (
echo Native JupyterLab server running at http://127.0.0.1:8868/lab
echo Native JupyterLab server running at http://127.0.0.1:8868/lab?token=%QUANTUI_APP_TOKEN%
echo All local quantui/*.py changes are live -- no rebuild needed.
echo Close the WSL window to stop.
) else (
Expand Down
13 changes: 10 additions & 3 deletions launchers/launch-native-jupyter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,17 @@ fi
rm -rf quantui/__pycache__
export PYTHONDONTWRITEBYTECODE=1

# A login token, never an empty one: an open JupyterLab lets any local user
# or process run code as you. JupyterLab reads JUPYTER_TOKEN from the
# environment, so the token stays off the command line. launch-native-
# jupyter.bat passes its own (QUANTUI_APP_TOKEN) so it can open the URL.
JUPYTER_TOKEN="${QUANTUI_APP_TOKEN:-${JUPYTER_TOKEN:-$(python -c 'import secrets; print(secrets.token_urlsafe(24))')}}"
export JUPYTER_TOKEN
echo "QuantUI JupyterLab: http://127.0.0.1:8868/lab/tree/notebooks/molecule_computations.ipynb?token=${JUPYTER_TOKEN}"

exec jupyter lab notebooks/molecule_computations.ipynb \
--no-browser \
--ip=127.0.0.1 \
--port=8868 \
--ServerApp.port_retries=0 \
--ServerApp.root_dir="$(pwd)" \
--IdentityProvider.token='' \
--ServerApp.password=''
--ServerApp.root_dir="$(pwd)"
Loading
Loading