Data¶
DataManager REST API client for the OpenCell database.
Data
¶
Functions:¶
is_development
¶
Check if running in development mode (local SQLite).
Controlled by the OPENCELL_ENV environment variable:
development(default) — local SQLite database viasteer_opencell_data, no login button, guest-only functionality. No network calls; works offline. Use this when developing new cells locally before publishing via the CLI migration tool.production— REST API viasteer_core.Data.DataManager, requiresAPI_URLenv var. Full auth flow with Cognito.
DataManager
¶
Classes¶
DataManagerError
¶
Bases: Exception
Base exception for DataManager errors.
APIError
¶
Bases: DataManagerError
Unexpected API error (5xx or unrecognised status).
AuthenticationError
¶
Bases: DataManagerError
401 — token missing or invalid.
ForbiddenError
¶
Bases: DataManagerError
403 — insufficient permissions.
NotFoundError
¶
Bases: DataManagerError
404 — resource does not exist.
ConflictError
¶
Bases: DataManagerError
409 — name already taken.
DataManager
¶
Generic REST client for the OpenCell API.
Provides low-level get_data, insert_data, and remove_data
operations. Domain-specific convenience methods (material getters,
cell fork/publish) should live in a subclass (see
steer_opencell_design.Data.OpenCellDataManager).
Table classification (materials vs cells endpoint routing) is driven
by :meth:register_tables. Call it once at application startup to
map table names to resource types.
Methods:¶
register_tables
classmethod
¶
register_tables(material_tables: set[str], cell_tables: set[str], material_meta_cols: list[str] | None = None, cell_meta_cols: list[str] | None = None) -> None
Register domain-specific table names and metadata columns.
Must be called before any get_data / insert_data calls
so that url routing (/materials/… vs /cells/…) works.
Parameters¶
material_tables : set[str]
Table names whose API path is /materials/{table}.
cell_tables : set[str]
Table names whose API path is /cells/{table}.
material_meta_cols : list[str], optional
Columns returned for material listings.
cell_meta_cols : list[str], optional
Columns returned for cell listings.
set_token
classmethod
¶
Set the JWT token used for authenticated API requests.
get_data
¶
get_data(table_name: str, columns: list[str] | None = None, condition: str | list[str] | None = None, latest_column: str | None = None) -> DataFrame
Retrieve data from the API.
When condition is provided (the from_database() path), fetches a
single item including the serialized object blob. The object
column contains raw bytes — identical to what SQLite returned.
When called without a condition, returns metadata-only rows (no
object column).
get_unique_values
¶
Return unique values for column_name from the listing endpoint.
insert_data
¶
Save a cell to the API.
Extracts name and object (serialized blob) from the DataFrame,
then uploads via presigned URL.