Python client and toolkit for the Rebase Platform
Project description
Rebase Toolkit
Python client and toolkit for the Rebase Platform.
The toolkit is intentionally small by default: it contains the API-key client, SDK handles for functions and workflows, and optional entry points for Rebase's energy data/modeling packages. It does not run a database or platform backend locally.
Install
During early development, install directly from GitHub into a clean uv environment:
uv venv .venv
source .venv/bin/activate
uv pip install "rebase-toolkit @ git+ssh://git@github.com/rebase-energy/rebase-toolkit.git@master"
Install from a branch by replacing master with the branch name:
uv pip install --upgrade "rebase-toolkit @ git+ssh://git@github.com/rebase-energy/rebase-toolkit.git@my-branch"
Once the package is published to PyPI:
pip install rebase-toolkit
The rebase PyPI project is a compatibility metapackage that installs the
same toolkit:
pip install rebase
When releasing to PyPI, publish rebase-toolkit first, then publish the alias
package from pypi/rebase with the same version:
uv build
uv build --project pypi/rebase
For local development:
uv sync --dev
To smoke-test a fresh install from this checkout before pushing:
scripts/smoke_uv_install.sh local
To smoke-test a GitHub ref:
REBASE_TOOLKIT_GIT_REF=master scripts/smoke_uv_install.sh github
Optional data/modeling packages:
uv pip install "rebase-toolkit[data]"
uv pip install "rebase-toolkit[modeling]"
uv pip install "rebase-toolkit[all]"
Configure
rebase setup
The setup command asks for a Rebase API key and stores it in ~/.rebase/config.json. The hosted Rebase API URL is built into the SDK, so normal user code does not need an API URL or API key argument.
You can select a named local profile when needed:
rebase setup --profile prod
For fast local development against a locally running workflow API, start the API from the platform checkout and run the editable toolkit setup helper:
cd /Users/sebaheg/Documents/Github/platform/workflows
./scripts/dev_api.sh
cd /Users/sebaheg/Documents/Github/platform/rebase-toolkit
./scripts/dev_setup_local.sh --print-command
./scripts/dev_setup_local.sh
The helper waits for http://127.0.0.1:18082/health and then runs:
uv run rebase setup --force-auth --api-url http://127.0.0.1:18082
Common overrides:
REBASE_DEV_PROFILE=local ./scripts/dev_setup_local.sh
REBASE_DEV_PROVIDER=github ./scripts/dev_setup_local.sh
REBASE_DEV_REPO=sebaheg/toolkit-test REBASE_DEV_GITHUB=1 ./scripts/dev_setup_local.sh
For local development against the internal deployed workflow API, port-forward the API and store that URL in the profile:
kubectl -n rebase-workflows port-forward svc/workflow-mvp-api 8080:8080
rebase setup --api-url http://127.0.0.1:8080
rebase workspace list
rebase workspace switch prod
Minimal Function
import rebase as rb
project = rb.project("first-user")
@project.function()
def add(a: int = 0, b: int = 0) -> dict:
return {"sum": a + b}
project.deploy()
run = add.spawn(a=2, b=3)
print(run.result(timeout=120))
Minimal Workflow
import rebase as rb
project = rb.project("forecasting")
@project.step()
def load_weather(site_id: str) -> dict:
return {"site_id": site_id}
@project.step()
def build_forecast(weather: dict, horizon_hours: int = 24) -> dict:
return {"weather": weather, "horizon_hours": horizon_hours}
@project.workflow()
def forecast(site_id: str = "site-001", horizon_hours: int = 24) -> dict:
weather = load_weather(site_id)
return build_forecast(weather, horizon_hours=horizon_hours)
project.deploy()
print(forecast.remote(site_id="site-001"))
Deploy a file from the command line:
rebase deploy workflow.py
Run a function from local source and force the Cloud Run backend:
rebase run functions.py::add --backend cloud_run --param a=2 --param b=3
If the file contains exactly one Rebase function, the function name can be omitted:
rebase run functions.py --parameters-json '{"a": 2, "b": 3}'
Models
rebase.Model is the shared base for model metadata and deployment config. Deployable models use typed emflow-style
subclasses such as rebase.Predictor, rebase.Optimizer, and rebase.Agent.
import rebase
class PriceForecastPredictor(rebase.Predictor):
name = "price-forecast"
def predict(self, zone: str = "SE3", horizon_hours: int = 24) -> dict:
return {"zone": zone, "horizon_hours": horizon_hours}
model = PriceForecastPredictor()
rebase.deploy(model)
Call a deployed model through its generated predict endpoint:
model = rebase.get_predictor("default/price-forecast")
result = model.predict.remote(zone="SE4")
Dependencies
Function dependencies are declared with a Modal-like image builder:
image = rb.Image.python("3.13").uv_pip_install("boltons==24.0.0")
@project.function(image=image)
def add_with_boltons(a: int = 0, b: int = 0) -> dict:
from boltons.iterutils import flatten
return {"sum": sum(flatten([[a], [b]]))}
Data and Modeling Packages
The toolkit can expose optional emflow and EnergyDataModel modules through:
from rebase import data
from rebase import modeling
Install rebase-toolkit[modeling] to use emflow through rebase.modeling.
Install rebase-toolkit[data] to import energydatamodel through rebase.data.
Project details
Release history Release notifications | RSS feed
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 rebase_toolkit-0.2.0.tar.gz.
File metadata
- Download URL: rebase_toolkit-0.2.0.tar.gz
- Upload date:
- Size: 153.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4417fd317cdfb1090169ad02557134c6244a4ceae4daf6868317f0af357945d4
|
|
| MD5 |
1562a920f1608cf7847e4feec1f2939b
|
|
| BLAKE2b-256 |
0af55f37dc1c875eec0d502cfc49ceea982b2796e4400e24bca04200e4b64a79
|
File details
Details for the file rebase_toolkit-0.2.0-py3-none-any.whl.
File metadata
- Download URL: rebase_toolkit-0.2.0-py3-none-any.whl
- Upload date:
- Size: 68.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebf6ad886e404db04675d41407f6e0daf346f4e5de0c1e10a175d37f1e42b2df
|
|
| MD5 |
2bc381154d2c64c58e310d0a738c7731
|
|
| BLAKE2b-256 |
912ed08ccf3ddcb7e2b573acd98e24c7ec116efabdb41b665dab1c8ccfbc82e5
|