Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
004a327
Merge pull request #1 from stanford-developers/abigail_dev
nicholas9182 Oct 21, 2025
0473f89
Merge pull request #2 from stanford-developers/peter-dev
nicholas9182 Oct 28, 2025
5f425f9
Port changes from dev_nick onto dev (squashed snapshot)
nicholas9182 Nov 8, 2025
6e526d2
Merge pull request #3 from stanford-developers/dev_nick_rebased
nicholas9182 Nov 8, 2025
7c4e165
fixed_v_conflict
nicholas9182 Nov 8, 2025
5927766
small_changes
nicholas9182 Nov 14, 2025
e69b12a
small_restructure
nicholas9182 Nov 20, 2025
5d9989a
small
nicholas9182 Dec 4, 2025
f8a1ba8
small_changes
nicholas9182 Dec 12, 2025
863b81a
made_serializr
nicholas9182 Dec 13, 2025
520ccc1
Merge pull request #4 from stanford-developers/dev_nick
nicholas9182 Dec 13, 2025
ed68c73
Merge branch 'main' into dev
nicholas9182 Dec 13, 2025
36922d2
moved_db_to_data_repo
nicholas9182 Dec 13, 2025
21d536b
Merge pull request #6 from stanford-developers/dev_nick
nicholas9182 Dec 13, 2025
b639185
added unit conversions
fschweden Jan 9, 2026
40da98e
small_changes
nicholas9182 Jan 20, 2026
649a83c
Merge pull request #9 from stanford-developers/dev_nick
nicholas9182 Jan 20, 2026
8351bb5
Merge pull request #8 from stanford-developers/dev_finn
nicholas9182 Jan 22, 2026
39b2b85
added_numpy_pandas_reqs
nicholas9182 Jan 23, 2026
345c058
vbump
nicholas9182 Jan 23, 2026
c5f935f
small_bump
nicholas9182 Jan 24, 2026
025980d
updated reqs
nicholas9182 Jan 24, 2026
a7ff5ea
added_nbformat
nicholas9182 Jan 27, 2026
70040f7
vbump
nicholas9182 Feb 4, 2026
d461759
removed_context_manager
nicholas9182 Feb 4, 2026
beb0b1a
vbump
nicholas9182 Feb 4, 2026
f835f2e
Time units added
tomeliotjullien Feb 6, 2026
d1affca
DateTime Mixin added
tomeliotjullien Feb 7, 2026
4ec38c4
Format added in Constants
tomeliotjullien Feb 7, 2026
50f237b
Time units conversion added
tomeliotjullien Feb 8, 2026
5d8c6a6
add_years and add_months staticmethods added
tomeliotjullien Feb 8, 2026
ccd0373
Units added
tomeliotjullien Feb 8, 2026
6dfd46c
Merge pull request #14 from stanford-developers/tomeliot_dev
nicholas9182 Feb 10, 2026
ea3a5e1
Merge branch 'dev' of github.com:stanford-developers/steer-core into …
nicholas9182 Feb 10, 2026
8ee5d84
small
nicholas9182 Feb 11, 2026
06adee9
vbumo
nicholas9182 Feb 11, 2026
38d6f9e
updated TypeCheker with more validations
tomeliotjullien Feb 13, 2026
5504e38
added some datetime methods
tomeliotjullien Feb 13, 2026
71f8613
Units added
tomeliotjullien Feb 13, 2026
daf2456
Merge pull request #15 from stanford-developers/tomeliot_dev
nicholas9182 Feb 17, 2026
8cb869a
pulling_tom_eliot_changes
nicholas9182 Feb 17, 2026
0087f30
feat: data manager (Phase 2 D2)
vsymoniuk-binary Feb 18, 2026
b91dfca
Merge pull request #16 from stanford-developers/feat-data-manager
nicholas9182 Feb 18, 2026
8af2b25
merged
nicholas9182 Feb 18, 2026
0116d44
added_propagation_logic
nicholas9182 Feb 19, 2026
1a51fa4
added_propagation_logic
nicholas9182 Feb 19, 2026
f695b51
adjusted_serialiser_propagation
nicholas9182 Feb 19, 2026
c3eac25
Merge branch 'previous_working' into dev_nick
nicholas9182 Feb 19, 2026
3a48b71
small
nicholas9182 Feb 19, 2026
a388e68
conflict_resolve
nicholas9182 Feb 21, 2026
ed6e4fb
vbump
nicholas9182 Feb 21, 2026
fe26b61
vbump
nicholas9182 Feb 21, 2026
01a5923
vbump
nicholas9182 Feb 21, 2026
3b7c5ac
added_proper_propagation
nicholas9182 Feb 21, 2026
bf8dbdf
feat: add target_table parameter to publish_cell()
vsymoniuk-binary Feb 26, 2026
1974e13
Merge pull request #17 from stanford-developers/feat-cell-table-select
nicholas9182 Feb 26, 2026
989d2c4
added_auth
nicholas9182 Feb 26, 2026
abb2366
added_licence_file
nicholas9182 Feb 26, 2026
1235c28
added_licence
nicholas9182 Feb 26, 2026
7eb20cc
vbump
nicholas9182 Feb 26, 2026
d1ada03
feat: secure publish
vsymoniuk-binary Mar 2, 2026
4bb04a4
Merge pull request #18 from stanford-developers/feat-secure-publish
nicholas9182 Mar 2, 2026
f9bec22
Merge branch 'dev_nick' of github.com:stanford-developers/steer-core …
nicholas9182 Mar 2, 2026
33ddc01
added_datum_mixin
nicholas9182 Mar 3, 2026
6ece469
vbump
nicholas9182 Mar 4, 2026
d159bec
Merge pull request #19 from stanford-developers/dev_nick
nicholas9182 Mar 4, 2026
7fa3aad
factory_decorators
nicholas9182 Mar 7, 2026
af61cd4
v_bump
nicholas9182 Mar 7, 2026
6997d6a
added_float_properties_dunder
nicholas9182 Mar 8, 2026
e699169
vbump
nicholas9182 Mar 8, 2026
98c3e50
added_plotter_functions
nicholas9182 Mar 11, 2026
22208da
refactored
nicholas9182 Mar 12, 2026
7b30aa2
added_pandas_support_serialize
nicholas9182 Mar 12, 2026
3e68101
small
nicholas9182 Mar 12, 2026
801e5a8
Merge pull request #21 from stanford-developers/dev_nick
nicholas9182 Mar 12, 2026
acc8316
Fix DunderMixin hash equality contract for dictionary merging purposes
0x1r1s Aug 25, 2026
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 .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
steer_core/Data/database.db filter=lfs diff=lfs merge=lfs -text
/steer_core/Data/database.db filter=lfs diff=lfs merge=lfs -text
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ data_scripts/
local_data/
Archive/
.vscode*
app_builds/
12 changes: 11 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,15 @@
"test*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true
"python.testing.unittestEnabled": true,
"python-envs.defaultEnvManager": "ms-python.python:conda",
"python-envs.defaultPackageManager": "ms-python.python:conda",
"python-envs.pythonProjects": [],
"python.analysis.extraPaths": [
"/Users/nsiemons/Drive/Code_projects/STEER/steer-core",
"/Users/nsiemons/Drive/Code_projects/STEER/steer-opencell-data",
"/Users/nsiemons/Drive/Code_projects/STEER/steer-opencell-design",
"/Users/nsiemons/Drive/Code_projects/STEER/steer-materials",
"/Users/nsiemons/Drive/Code_projects/STEER/steer-dash-components"
],
}
43 changes: 43 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International

Copyright (c) 2026 Nicholas Siemons

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

To view a copy of this license, visit:
http://creativecommons.org/licenses/by-nc-sa/4.0/

or send a letter to:
Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

===============================================================================

You are free to:

* Share — copy and redistribute the material in any medium or format
* Adapt — remix, transform, and build upon the material

The licensor cannot revoke these freedoms as long as you follow the license terms.

Under the following terms:

* Attribution — You must give appropriate credit, provide a link to the license,
and indicate if changes were made. You may do so in any reasonable manner, but
not in any way that suggests the licensor endorses you or your use.

* NonCommercial — You may not use the material for commercial purposes.

* ShareAlike — If you remix, transform, or build upon the material, you must
distribute your contributions under the same license as the original.

* No additional restrictions — You may not apply legal terms or technological
measures that legally restrict others from doing anything the license permits.

Notices:

You do not have to comply with the license for elements of the material in the
public domain or where your use is permitted by an applicable exception or limitation.

No warranties are given. The license may not give you all of the permissions necessary
for your intended use. For example, other rights such as publicity, privacy, or moral
rights may limit how you use the material.
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# steer-core

Base utilities for the OpenCell platform: constants, mixins (Serializer, Validation, Plotter), decorators, and the DataManager REST API client.

## Install

```bash
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.

```python
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 via `steer_opencell_data.DataManager`
- No network calls, works fully offline
- Requires `steer-opencell-data` installed with `database.db`
- Use this when developing new cells locally before publishing via the CLI migration tool (`steer-opencell-data` CLI)

### Production mode (`OPENCELL_ENV=production` or unset)

- `SerializerMixin.from_database()` uses the REST API via `steer_core.Data.DataManager`
- Requires `API_URL` pointing 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.DataManager` logger

## 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
```
110 changes: 110 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "steer-core"
dynamic = ["version"]
description = "Modelling energy storage from cell to site - STEER OpenCell Design"
readme = "README.md"
requires-python = ">=3.10"
license = {text = "CC-BY-NC-SA-4.0"}
authors = [
{name = "Nicholas Siemons", email = "nsiemons@stanford.edu"},
]
maintainers = [
{name = "Nicholas Siemons", email = "nsiemons@stanford.edu"},
]
keywords = ["energy", "storage", "battery", "modeling", "simulation"]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"License :: Other/Proprietary License",
"Operating System :: OS Independent",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Physics",
]
dependencies = [
"pandas==2.3.3",
"numpy==2.2.6",
"datetime==5.5",
"plotly==6.2.0",
"scipy==1.15.3",
"msgpack==1.1.1",
"msgpack-numpy==0.4.8",
"requests>=2.31.0",
"nbformat==5.10.4",
"shapely==2.1.1",
"lz4==4.4.4"
]

[project.urls]
Homepage = "https://github.com/nicholas9182/steer-core/"
Repository = "https://github.com/nicholas9182/steer-core/"
Issues = "https://github.com/nicholas9182/steer-core/issues"
Documentation = "https://github.com/nicholas9182/steer-core/"

[project.optional-dependencies]
dev = [
"pytest>=7.0",
"pytest-cov",
"black",
"flake8",
"mypy",
"isort",
]
test = [
"pytest>=7.0",
"pytest-cov",
]

[tool.setuptools]
include-package-data = true

[tool.setuptools.packages.find]
where = ["."]
include = ["steer_core*"]

[tool.setuptools.package-data]
"steer_core.Data" = ["*.py"]

[tool.setuptools.dynamic]
version = {attr = "steer_core.__version__"}

[tool.black]
line-length = 88
target-version = ['py310']
include = '\.pyi?$'
extend-exclude = '''
/(
# directories
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| build
| dist
)/
'''

[tool.isort]
profile = "black"
multi_line_output = 3
line_length = 88
known_first_party = ["steer_core"]

[tool.pytest.ini_options]
minversion = "7.0"
addopts = "-ra -q --strict-markers"
testpaths = [
"test",
]
python_files = [
"test_*.py",
"*_test.py",
]
33 changes: 0 additions & 33 deletions setup.py

This file was deleted.

Loading
Loading