Base utilities, mixins, and constants for the STEER OpenCell platform.
Project description
steer-core
Base utilities for the OpenCell platform: constants, mixins (Serializer, Validation, Plotter), decorators, and the DataManager REST API client.
Install
pip install -e .
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
OPENCELL_ENV |
No | production |
development = local SQLite, no auth. production = REST API + Cognito auth. |
API_URL |
In production | — | Base URL of the deployed REST API (e.g. https://59xitvvsf2.execute-api.us-east-2.amazonaws.com/production) |
API_TIMEOUT |
No | 30 |
HTTP request timeout in seconds |
Development vs Production Mode
Controlled by the OPENCELL_ENV environment variable. The helper is_development() from steer_core.Data is the single source of truth — use it anywhere you need to branch on mode.
from steer_core.Data import is_development
if is_development():
# local SQLite path
else:
# REST API path
Development mode (OPENCELL_ENV=development)
SerializerMixin.from_database()uses the local SQLite database viasteer_opencell_data.DataManager- No network calls, works fully offline
- Requires
steer-opencell-datainstalled withdatabase.db - Use this when developing new cells locally before publishing via the CLI migration tool (
steer-opencell-dataCLI)
Production mode (OPENCELL_ENV=production or unset)
SerializerMixin.from_database()uses the REST API viasteer_core.Data.DataManager- Requires
API_URLpointing to the deployed Lambda endpoint - JWT token passed automatically for authenticated operations (
DataManager.set_token()) - Logs API calls and S3 downloads to the
steer_core.DataManagerlogger
DataManager REST Client
steer_core.Data.DataManager — drop-in replacement for the SQLite-based DataManager. Same interface, talks to the REST API + S3 instead.
Key methods
| Method | What it does |
|---|---|
get_data(table, condition="name='X'") |
Fetch item + download blob from S3 presigned URL |
get_data(table) (no condition) |
List items — metadata only, no blob |
get_unique_values(table, column) |
List unique values from API |
get_{type}_materials(most_recent) |
9 material-specific convenience methods |
insert_data(table, df) |
Upload blob to S3 via presigned URL |
remove_data(table, condition) |
Soft-delete via API |
fork_cell(table, name, new_name) |
Fork cell (auth required) |
publish_cell(table, name, new_name) |
Publish cell (admin only) |
check_name_available(name) |
Check name uniqueness across all cell tables |
set_token(token) |
Set JWT for authenticated requests |
Exceptions
| Exception | HTTP Status | When |
|---|---|---|
DataManagerError |
— | Base class / missing API_URL |
APIError |
5xx | Server error |
AuthenticationError |
401 | Missing or invalid token |
ForbiddenError |
403 | Insufficient permissions |
NotFoundError |
404 | Resource not found |
ConflictError |
409 | Name already taken (fork/publish) |
Logging
API calls and S3 downloads are logged to the steer_core.DataManager logger:
[steer_core.DataManager] [API] GET /materials/tape_materials/Kapton -> 200 (164 ms)
[steer_core.DataManager] [S3] Downloaded 0.2 KB in 499 ms
Quick Start
from steer_core import ValidationMixin, SerializerMixin, DunderMixin
class MyComponent(ValidationMixin, SerializerMixin, DunderMixin):
def __init__(self, name: str, mass: float):
self._name = name
self._mass = mass
@property
def name(self) -> str:
return self._name
@property
def mass(self) -> float:
return self._mass
comp = MyComponent("cathode", 0.5)
data = comp.serialize()
restored = MyComponent.deserialize(data)
assert comp == restored
Documentation
Full documentation is available at stanford-developers.github.io/steer-core.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Citation
If you use this software, please cite it using the metadata in CITATION.cff.
License
steer-core is dual-licensed:
- Open source — GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later)
- Commercial — A separate commercial license is available for use without AGPL-3.0 copyleft requirements. Contact nsiemons@stanford.edu for details.
See LICENCE.txt for full terms.
Contributions require signing a Contributor License Agreement.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file steer_core-0.2.13.tar.gz.
File metadata
- Download URL: steer_core-0.2.13.tar.gz
- Upload date:
- Size: 80.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
328788a379430d0247e54b3925eb6d8487a8f82b01835d3a42af239b99454ed5
|
|
| MD5 |
073b21f56475d57170f049a794e74711
|
|
| BLAKE2b-256 |
22bfee00bb5834db5d67a91a7aa59fbac440a62d8df43a24238863529749ca30
|
File details
Details for the file steer_core-0.2.13-py3-none-any.whl.
File metadata
- Download URL: steer_core-0.2.13-py3-none-any.whl
- Upload date:
- Size: 71.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
368e3f4ad79a2ae3391715ad508bdaa4f206eae8107bcbdaf7c9891836d612da
|
|
| MD5 |
1ec6c1b3eea173318522dbff9aebf68b
|
|
| BLAKE2b-256 |
8eab1c1b8d23605576e428c9a8f9585f24ff367e2075c23f40cefb9c8773dd8f
|