cellmap_flow.finetune.session.minio
The dashboard’s MinIO: the local S3 server annotation volumes are painted through.
Neuroglancer reads and writes a volume’s chunks straight from MinIO; the
volume on disk is mirrored up when it is served and pulled back by
session.sync. The server’s state – process, address, bucket, data
directory, sync thread – lives in the dict a MinioServer is given (the
dashboard’s minio_state), never here, so any number of them over the
same dict agree.
Attributes
Classes
Starts MinIO once, then serves annotation volumes through it. |
Functions
This machine's address on its outgoing interface, else 127.0.0.1. |
|
|
A free port whose next one is free too: MinIO's API and console. |
|
Where MinIO started for |
|
Poll MinIO's readiness endpoint until it answers 200, the process exits, or time runs out. |
|
An s3fs filesystem pointed at the MinIO |
|
|
Module Contents
- cellmap_flow.finetune.session.minio.logger
- cellmap_flow.finetune.session.minio.MC_ALIAS = 'myserver'
- cellmap_flow.finetune.session.minio.MINIO_READY_TIMEOUT = 30.0
- cellmap_flow.finetune.session.minio.MINIO_PROXY_URL_ENV = 'CELLMAP_FLOW_MINIO_PROXY_URL'
- cellmap_flow.finetune.session.minio.get_local_ip()
This machine’s address on its outgoing interface, else 127.0.0.1.
- cellmap_flow.finetune.session.minio.find_available_port(start_port=9000)
A free port whose next one is free too: MinIO’s API and console.
- cellmap_flow.finetune.session.minio.minio_root(output_base_dir) pathlib.Path
Where MinIO started for
output_base_dirkeeps its data.
- cellmap_flow.finetune.session.minio.wait_for_ready(ip, port, process, timeout=MINIO_READY_TIMEOUT) bool
Poll MinIO’s readiness endpoint until it answers 200, the process exits, or time runs out.
- cellmap_flow.finetune.session.minio.make_s3_filesystem(state)
An s3fs filesystem pointed at the MinIO
statedescribes.Both cache opt-outs are load-bearing, not tuning knobs.
fsspec caches filesystem instances keyed on their constructor arguments, so every call here would otherwise hand back the same object – and with it the same
dircache. s3fs fillsdircacheonls()and never expires it by default. The periodic sync thread starts with MinIO, when the first volume is served, so its first listing ofannotation/s0runs before the user has painted anything and would cache a chunk-less listing. Every later sync would reuse that stale listing,diff_and_sync_chunkswould see no chunk keys, and painted scribbles would never reach disk – whilesync_zarr_group_metadatawould keep working, becausecat()/exists()address objects directly and bypass the cache. The symptom: every sync logs “no changes” however much is painted, and training finds a volume with no populated chunks.Listings here are small and served by a local MinIO, so not caching them costs nothing.
- cellmap_flow.finetune.session.minio.proxied_url(minio_url, request=None)
minio_urlas a browser behind a reverse proxy can reach it.A browser that loaded the dashboard over a proxy’s HTTPS cannot fetch
http://<node>:<port>/...chunks from MinIO: the node may not be reachable, and the page blocks the mixed content. When CELLMAP_FLOW_MINIO_PROXY_URL is set andrequest(anything withheadersandscheme) came through a proxy, the URL’s path is put under that URL instead.Only a request carrying X-Forwarded-Host came through a proxy; the Host header is there for every browser, including one that reaches the dashboard directly. The scheme is X-Forwarded-Proto’s, else the request’s own. Otherwise, and with no request, the URL is returned unchanged.
- class cellmap_flow.finetune.session.minio.MinioServer(state: dict, preflight=None, volumes: dict | None = None)
Starts MinIO once, then serves annotation volumes through it.
stateis the dashboard’sminio_statedict (process,ip,port,bucket,output_base,log_path,sync_thread): it is read and written in place.volumesis the volume registry the sync keeps its per-chunk state in.preflight, if given, runs before anything else, e.g. a check that the binaries are installed.- state
- preflight = None
- volumes
- running() bool
- mc_env() dict
The environment for an mc call that addresses this server as MC_ALIAS.
- url_for(zarr_name: str) str
The URL a browser reads
<bucket>/<zarr_name>at, before any proxy.
- ensure_serving(zarr_path: str, volume_id: str, output_base_dir: str | None = None, mc_target_name: str | None = None) str
Start MinIO if needed, then upload the volume at
zarr_path; returns its MinIO URL.volume_idis how the sync finds its chunks: the bucket key without “.zarr”.mc_target_nameis that key when it is notbasename(zarr_path): instance corrections keep one key per ROI whichever snapshot on disk is served. A MinIO that has to start keeps its data in<output_base_dir>/.minio; a running one keeps its own.