Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Probe viewer generated files (created at build time)
apps/probe-viewer/public/data/
apps/probe-viewer/public/probes-manifest.json
apps/probe-viewer/public/probe.schema.json
apps/probe-viewer/node_modules/
apps/probe-viewer/dist/
apps/probe-viewer/.vite/
Expand Down
3 changes: 3 additions & 0 deletions apps/probe-viewer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ An interactive web-based visualization tool for browsing microelectrode probe de
- Read the probe JSON files from the manufacturer folders in this repository
- Generate `public/probes-manifest.json` with metadata for all probes
- Copy probe JSON files to `public/data/`
- Download the ProbeInterface JSON schema to `public/probe.schema.json`, used to
validate probe files a user loads from their own computer
- Start the Vite dev server

2. **Access the app:**
Expand Down Expand Up @@ -78,6 +80,7 @@ apps/probe-viewer/
│ └── hooks/ # Custom React hooks
├── public/
│ ├── probes-manifest.json # Generated probe catalog
│ ├── probe.schema.json # Downloaded ProbeInterface schema
│ └── data/ # Generated probe JSON files
└── index.html
```
Expand Down
29 changes: 29 additions & 0 deletions apps/probe-viewer/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
manifest is generated directly from the manufacturer folders at the repo root.
The manifest metadata is read straight from the ProbeInterface JSON, so this
script has no third-party dependencies.

It also downloads the ProbeInterface JSON schema into the app, so the viewer can
tell a user whether a file they load is spec-compliant. The schema is fetched
from the same upstream URL the data tests use (see tests.py), which keeps the
viewer's notion of "compliant" identical to the one CI enforces on this catalog.
"""

from __future__ import annotations
Expand All @@ -31,10 +36,17 @@
import shutil
import subprocess
import sys
import urllib.request
from dataclasses import asdict, dataclass
from pathlib import Path
from typing import Iterable

# The ProbeInterface JSON schema, from the same source tests.py validates against.
SCHEMA_URL = (
"https://raw.githubusercontent.com/SpikeInterface/probeinterface/main/"
"src/probeinterface/schema/probe.json.schema"
)


# ============================================================================
# Manifest generation
Expand Down Expand Up @@ -170,6 +182,20 @@ def generate_manifest(
return entries


def download_schema(destination_dir: Path) -> Path:
# Kept in step with tests.py, which validates this catalog against the same
# URL: the viewer must not call a file non-compliant that CI accepts. The
# released package is deliberately not used as the source -- its schema
# predates contact_sides and would reject the double-sided probes in this
# very catalog.
with urllib.request.urlopen(SCHEMA_URL) as response:
schema = response.read()

destination = destination_dir / "probe.schema.json"
destination.write_bytes(schema)
return destination


def write_manifest(entries: Iterable[ManifestEntry], destination: Path) -> None:
destination.parent.mkdir(parents=True, exist_ok=True)
payload = [entry.to_json() for entry in entries]
Expand Down Expand Up @@ -240,6 +266,9 @@ def main() -> None:
write_manifest(entries, manifest_path)
print(f"Wrote {len(entries)} entries to {manifest_path}")

schema_path = download_schema(public_dir)
print(f"Downloaded probe schema to {schema_path}")

if args.dev:
# Start dev server
print("Starting dev server...")
Expand Down
97 changes: 84 additions & 13 deletions apps/probe-viewer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/probe-viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"preview": "vite preview"
},
"dependencies": {
"ajv": "^8.20.0",
"react": "^19.1.1",
"react-dom": "^19.1.1",
"react-router-dom": "^7.9.4",
Expand Down
Loading
Loading