Labox
A storage framework for heterogeneous data in Python.
At a Glance
Model your data with Pydantic
import pandas as pd
import plotly.express as px
from labox.extra.pydantic import StorableModel
class ExperimentData(StorableModel, class_id="..."): # (1)!
name: str
params: dict[str, float]
data: pd.DataFrame
plot: go.Figure
# Populate it with data
params = {"temperature": 298.15, "ph": 7.4, "concentration": 0.1}
data = pd.DataFrame({"measure_num": [1, 2, 3], "measure_val": [1.23, 4.56, 7.89]})
plot = px.scatter(data)
experiment = ExperimentData(name="Measurement data", params=params, data=data, plot=plot)
- Models have immutable
class_ids you need to define.
Then save and load it to a storage backend of your choice:
import boto3
from sqlalchemy.ext.asyncio import AsyncSession
from labox.core import Registry, save_one, load_one
from labox.extra.aws import S3Storage, simple_s3_router
# With a bit of setup
s3_storage = S3Storage(boto3.client("s3"), simple_s3_router("my-bucket"))
registry = Registry(...) # (1)!
session = AsyncSession(...) # (2)!
record = await save_one(experiment, session=session, registry=registry)
loaded_experiment = await load_one(record, ExperimentData, session=session, registry=registry)
- Labox has a registry of integrations you need to declare
- Labox uses SQLAlchemy sessions you need to be establish
Installation
To install the core package:
To include the core package and extra integrations:
Be sure to checkout how Labox works with Pydantic as well as all the other integrations Labox offers.
Next Steps
Check out more usage examples, or dive into the concepts and integrations to learn more about how Labox works.