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
2 changes: 2 additions & 0 deletions src/polystore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
"NapariShapeType": ".streaming_constants",
"StreamingDataType": ".streaming_constants",
"SourcePixelRef": ".virtual_workspace",
"GitBackend": ".git",
"GitCommit": ".git",
"DiskBackend": ".disk",
"DiskStorageBackend": ".disk",
}
Expand Down
11 changes: 4 additions & 7 deletions src/polystore/backend_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,11 @@ def create_storage_registry() -> dict[str, DataSink]:
STORAGE_BACKENDS._discover()
logger.debug("Triggered backend discovery via LazyDiscoveryDict")

# Backends that require context-specific initialization (e.g., plate_root)
# These are registered lazily when needed, not at startup
SKIP_BACKENDS = {"virtual_workspace", "omero_local", "bioformats"}

registry = {}
for backend_type in STORAGE_BACKENDS.keys():
# Skip backends that need context-specific initialization
if backend_type in SKIP_BACKENDS:
for backend_type, backend_class in STORAGE_BACKENDS.items():
# A backend that declares it needs application context (a plate root, a
# repository) is built by the application, not here.
if backend_class.requires_context:
logger.debug(
f"Skipping backend '{backend_type}' - requires context-specific initialization"
)
Expand Down
7 changes: 7 additions & 0 deletions src/polystore/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ def requires_filesystem_validation(self) -> bool:
"""
pass

requires_context: bool = False
"""
Whether constructing this backend needs application context (a plate root, a server
connection, a repository): the application builds it and adds it to its registry. A
context-free backend is built by ``create_storage_registry``.
"""

# Class attribute: can be accessed without instantiation
supports_arbitrary_files: bool = True
"""
Expand Down
1 change: 1 addition & 0 deletions src/polystore/bioformats_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class BioFormatsStorageBackend(ReadOnlyBackend, PicklableBackend):
"""Load planes addressed directly by ``BioFormatsPlaneRef`` values."""

_backend_type = Backend.BIOFORMATS.value
requires_context = True

def get_connection_params(self) -> dict[str, Any] | None:
return None
Expand Down
1 change: 1 addition & 0 deletions src/polystore/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Backend(Enum):
DISK = "disk"
MEMORY = "memory"
ZARR = "zarr"
GIT = "git"
OME_ZARR = "ome_zarr"
STREAMING = "streaming"
NAPARI_STREAM = "napari_stream"
Expand Down
Loading
Loading