Skip to content

docs: fix quickstart mismatch, add logo, harden CI (closes #40, #41) - #42

Merged
bruAristimunha merged 4 commits into
developfrom
docs/quickstart-and-logo
Apr 28, 2026
Merged

bruAristimunha merged 4 commits into
developfrom
docs/quickstart-and-logo

Conversation

@bruAristimunha

@bruAristimunha bruAristimunha commented Apr 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Addresses #40 (quickstart on the published site didn't match docs/source/user_guide/quickstart.rst) and #41 (logo on the docs site). Also rolls in a CI hardening pass and a few cleanups surfaced by review.

#40 — Quickstart mismatch

Root cause: docs/source/index.rst had its own inline Quick Start using obsolete APIs (EEGobj.load, clean_flatlines, clean_channels) that shadowed the comprehensive user_guide/quickstart.rst. The home page rendered the inline duplicate, so editing quickstart.rst had no visible effect on eegprep.org/#quick-start.

Fix: remove the inline duplicate; link to :ref:quickstart`` plus a 5-line minimal example using the actual API (pop_loadset / `clean_artifacts` / `pop_saveset`). Drive-by: fix `NeuroTechX/eegprep` URL → `sccn/eegprep`.

For auto-rebuild: the workflow already triggered on push/PR to master/develop. Tightened it with a paths: filter (docs/**, src/**, pyproject.toml, this workflow) and added workflow_dispatch: for on-demand rebuilds. Deploy still gated on push-to-master.

#41 — Logo on the docs site

Vendored the README logo into docs/source/_static/logo.jpg (downsized to 512×504, ~57 KB) and wired it into the navbar via pydata-sphinx-theme's image_light / image_dark. The README's user-attachments URL is unstable for long-term Sphinx use, so vendoring is the right move.

Workflow hardening

  • Split docs.yml into build (contents: read) and deploy (contents: write, needs: build) jobs — least-privilege.
  • Switch install from .[all] to the lighter .[docs] extra (skips ~250 MB of torch on every doc build).
  • SHA-pin peaceiris/actions-gh-pages to 4f9cc6602d3f66b9c108549d475ec49e8ef4d45e (v4.0.0) for supply-chain hygiene.

Loosen torch floor

torch>=2.5.1 was unnecessarily tight (it locks to the version that added Python 3.13 wheels). The codebase only uses long-stable APIs (Conv2d, Module, Parameter, tensor, cat, LeakyReLU, Softmax). Lowered to torch>=2.0; pip naturally resolves to ≥2.1 on Py 3.12 and ≥2.5 on Py 3.13 because those are the first versions with matching cp wheels.

Drop redundant requirements files

requirements.txt and requirements-docs.txt had drifted from pyproject.toml (e.g. torch was >=1.10.0 in one and >=2.5.1 in the other). Deleted both; [project.dependencies] and [project.optional-dependencies] are now the single source of truth. Updated contributing.rst and development.rst to install via pip install -e ".[docs]".

Test plan

  • python -m sphinx -b html — clean build (only pre-existing docstring/autosummary warnings unchanged).
  • _static/logo.jpg resolves in built HTML; navbar light + dark variants render.
  • Home-page Quick Start link resolves to user_guide/quickstart.html#quickstart.
  • Workflow YAML parses; build is read-only, deploy needs build and is gated on push-to-master.
  • On merge to develop, confirm the docs CI runs (build job only — no deploy).
  • On merge to master, confirm eegprep.org/#quick-start reflects the canonical Quick Start.

Out of scope (follow-ups)

  • The asset is a JPEG with a white background — looks clean on light mode but shows a white card on dark navbar. A transparent PNG / SVG would be the proper fix.
  • test.yml targets main, while docs.yml targets master — branch-name inconsistency worth a separate cleanup.
  • Pre-existing docstring formatting warnings (e.g. in pop_load_frombids, eeg_interp, pop_epoch) still emit during the Sphinx build.

Closes #40 and #41.

- index.rst: drop the inline Quick Start that referenced obsolete
  EEGobj.load / clean_flatlines / clean_channels APIs and shadowed
  user_guide/quickstart.rst; link to the canonical guide instead.
  Fix wrong NeuroTechX/eegprep URL to sccn/eegprep.
- conf.py + _static/logo.jpg: wire the README logo into the navbar
  via pydata-sphinx-theme image_light/image_dark.
- workflows/docs.yml: scope triggers to docs-relevant paths, add
  workflow_dispatch, split into build (contents:read) and deploy
  (contents:write, needs build, gated on push to master), switch
  install from .[all] to the lighter .[docs] extra (avoids pulling
  torch on every doc build), and SHA-pin peaceiris/actions-gh-pages.
- pyproject.toml: loosen torch floor 2.5.1 -> 2.0; the codebase only
  uses stable APIs (Conv2d, Module, Parameter, tensor, cat) and pip
  resolves the right cp wheel per Python version.
- Delete redundant requirements.txt and requirements-docs.txt;
  pyproject [project.dependencies] and [project.optional-dependencies]
  are the source of truth. Update contributing.rst and
  development.rst to install via .[docs].
@claude

claude Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Code Review — PR #42: docs: fix quickstart mismatch, add logo, harden CI

Overall this is a well-scoped, well-motivated PR that addresses three distinct problems cleanly. The changes are largely safe and an improvement. Below is a breakdown by area.


CI / Workflow (docs.yml) ✅ Strong

Positives:

  • Build/deploy job split with least-privilege permissions is the right pattern — contents: read for build, contents: write only for deploy.
  • SHA-pinning peaceiris/actions-gh-pages to 4f9cc6602d3f66b9c108549d475ec49e8ef4d45e is good supply-chain hygiene.
  • paths: filters correctly prevent unnecessary runs.
  • workflow_dispatch: is a useful escape hatch.
  • Switching .[all] → .[docs] removes the large torch download from every doc build.

Issues:

  • Inconsistent action pinning: peaceiris/actions-gh-pages is SHA-pinned but actions/checkout@v4 and actions/setup-python@v5 still use floating major-version tags. If supply-chain hygiene is the goal (and it should be), all third-party actions should be SHA-pinned, not just one.

    # Recommended:
    uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683  # v4
    uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065  # v5
  • workflow_dispatch and deploy: When triggered manually, the deploy job's condition (github.event_name == 'push') correctly prevents deployment. This is fine, but the workflow_dispatch event also doesn't filter by branch, meaning it will trigger a docs build for any branch. Consider adding a note or gate if that's not desired.

  • No continue-on-error or failure annotation for the Sphinx build: If autodoc or any extension fails silently (exit 0), the CI will appear green. Consider adding SPHINXOPTS: "-W --keep-going" (treat warnings as errors) to catch regressions early.


runamica.py — AMICA subprocess improvements ⚠️ Mostly good, a few concerns

Positives:

  • The PMI_RANK=0/PMI_SIZE=1 fix for MPICH singleton init is well-reasoned and documented.
  • _amica_subprocess_kwargs() centralizes subprocess invocation correctly — _run_amica and the probe in is_amica_available() now share the same environment setup.
  • The smoke-test approach in is_amica_available() (run with a nonexistent param file, check for graceful failure) is pragmatic.
  • Magic return codes (174, 3221225781) are documented in the inline comment.

Issues:

  1. Thread-safety of _amica_works_cache: The module-level _amica_works_cache = None is not protected by a lock. If two threads call is_amica_available() concurrently (e.g., parallel test collection), the subprocess probe could run twice and the cache write is not atomic. For typical EEG use this is unlikely to matter, but it's a latent bug.

    import threading
    _amica_cache_lock = threading.Lock()
    _amica_works_cache = None
    
    def is_amica_available():
        global _amica_works_cache
        with _amica_cache_lock:
            if _amica_works_cache is not None:
                return _amica_works_cache
            # ... rest of probe logic
  2. Probe path portability: /nonexistent/eegprep/amica/probe.param is an absolute Unix path. On Windows, this is interpreted as a drive-relative path (e.g., C:\nonexistent\eegprep\...), which happens to still not exist — so the probe works. But it's fragile; consider:

    import tempfile, os
    probe_path = os.path.join(tempfile.gettempdir(), 'eegprep_amica_probe_nonexistent.param')
  3. _raise_stack closure per call: _amica_subprocess_kwargs() defines _raise_stack as a nested function on every invocation. Since this function is called twice per AMICA run (once for probe, once for actual), consider defining _raise_stack at module level or memoizing _amica_subprocess_kwargs().

  4. preexec_fn deprecation trajectory: Python 3.12 added deprecation warnings for preexec_fn in multiprocessing, but it's still fully supported in subprocess. No action needed now, but worth tracking for Python 3.14+.

  5. 512M stack size may be unexpected: OMP_STACKSIZE=512M and KMP_STACKSIZE=512M can cause out-of-memory on highly constrained systems. Since these use setdefault, users can override — but the defaults are undocumented in user-facing docs. A comment pointing to the docstring would help.


Documentation changes ✅ Clean

  • Removing the inline duplicate Quick Start from index.rst is exactly the right fix; linking to :ref:\quickstart`` removes the ambiguity that caused issue Quickstart #40.
  • The minimal 3-line example using pop_loadset / clean_artifacts / pop_saveset correctly reflects the actual public API.
  • Fixing the GitHub URL (NeuroTechX/eegprep → sccn/eegprep) is a necessary correction.
  • Updating contributing.rst and development.rst to use pip install -e ".[docs]" keeps instructions consistent with the deleted requirements-docs.txt.

Minor:

  • image_dark: logo.jpg and image_light: logo.jpg both point to the same JPEG with a white background. This is acknowledged in the PR description as a follow-up, but it's worth calling out: on the dark navbar the white card will be visually jarring for users. A transparent PNG or SVG should be prioritized soon after merge.

pyproject.toml — torch floor change ✅ Correct

Lowering torch>=2.5.1 → torch>=2.0 is well-justified. The codebase only uses stable, long-standing APIs. The explanation of platform-specific wheel availability (Py 3.12 → ≥2.1, Py 3.13 → ≥2.5) is accurate.


Deleting requirements.txt / requirements-docs.txt ✅ Safe here

The Dockerfile already installs via pyproject.toml (confirmed), so removing requirements.txt does not break the Docker build. The drift between files (e.g., torch>=1.10.0 in requirements.txt vs >=2.5.1 in pyproject.toml) was a real maintenance hazard. Single source of truth is the right call.


Test changes ✅ Clean refactor

Replacing the local _amica_binary_available() helpers in both test_eeg_amica.py and test_runamica.py with is_amica_available() is a straightforward deduplication. The new skip message ("AMICA binary not functional on this platform") is more informative than the old one.


Summary

Area Status Priority
SHA-pin checkout/setup-python actions Recommended Medium
Thread-safety of _amica_works_cache Bug (low-risk) Low
Probe path portability on Windows Code smell Low
Dark-mode logo (JPEG with white BG) Known follow-up Medium
Sphinx -W flag for CI Enhancement Low
All other changes Approved ✅ —

This is ready to merge with the understanding that the logo dark-mode issue and action SHA-pinning are tracked as follow-ups. The AMICA subprocess hardening is the most substantive code change and is well-implemented.


Reviewed by Claude

The vendored AMICA Fortran binary (built with Intel ifort + OpenMP)
crashes with 'forrtl: severe (174): SIGSEGV' on systems with the
default 8 MiB thread stack (Linux runners, some Windows builds).

Set OMP_STACKSIZE=512M and KMP_STACKSIZE=512M before invoking the
binary, and on POSIX raise RLIMIT_STACK to RLIM_INFINITY via
preexec_fn so the main thread inherits a large stack too.

Fixes the 11 AMICA test errors (test_eeg_amica.* and test_runamica.*)
on ubuntu-22.04 and windows-latest while keeping macOS green.
The vendored Linux AMICA binary (amica15ub) is statically linked but
compiled with -xCORE-AVX512 (uses zmm registers and vfmadd231ps),
which segfaults on the AMD EPYC CPUs that GitHub's ubuntu-22.04
runners now use. The Windows build (amica15mkl.exe) is dynamically
linked against the Intel Fortran runtime DLLs that aren't installed
on hosted Windows runners (STATUS_DLL_NOT_FOUND / 0xC0000135).

Replace the file-presence check with a smoke-test that launches the
binary against a bogus param file. A healthy binary exits gracefully
with a file-not-found code; a broken one returns 174 (Intel Fortran
severe), 0xC0000135 (Windows missing DLL), or is signal-killed.
Cache the result so the probe runs once per process.

Tests now skip cleanly on incompatible platforms, keep full coverage
on macOS, and surface a clear reason rather than a SIGSEGV trace.
Disassembling the segfault address shows the Linux AMICA binary
(amica15ub) is built with MPICH statically linked. The crash trace
walks tbk_trace_stack_impl -> for__issue_diagnostic -> MPIDI_CH3_Init,
i.e. AMICA segfaults during MPI_Init, not in user code or the AVX-512
hot loop as initially suspected.

Without an external launcher (mpiexec / hydra_pmi_proxy), MPICH falls
back to 'singleton init', which tries to fork a hydra process to act as
the PMI server. On stock Linux runners hydra isn't installed, the spawn
fails, and MPICH segfaults. macOS amica15mac is built without MPI so it
is unaffected.

Setting PMI_RANK=0 / PMI_SIZE=1 makes MPICH skip the singleton-init
dance and treat the process as rank 0 of an already-launched 1-proc
job, avoiding the spawn.
@bruAristimunha
bruAristimunha merged commit f8202ce into develop Apr 28, 2026
8 checks passed
@bruAristimunha
bruAristimunha deleted the docs/quickstart-and-logo branch April 28, 2026 20: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