SDK for Serwin cloud platform worker scripts
Project description
serwin_sdk
SDK for writing worker scripts on the Serwin cloud platform. It handles moving data in and out of your job — pulling input from a bucket, publishing results, and deploying trained models — so your script can focus on the actual logic.
Install
pip install serwin_sdk
Quick start
import os
from serwin_sdk import WorkersContext
ctx = WorkersContext(api_key=os.environ.get("API_KEY"))
# pull everything from a bucket into a local folder
ctx.input(bucket="my-input-bucket", dest_folder="input")
# ... your script's own logic goes here ...
# push everything in a local folder back up to a bucket
ctx.publish(dest_folder="output", bucketname="my-output-bucket")
Configuration
WorkersContext reads its settings from environment variables set on the
worker VM at provision time. You can also pass any of them explicitly to
override the environment:
| Env var | Purpose |
|---|---|
API_KEY |
Authenticates requests to the control plane |
CONTROL_PLANE_URL |
Base URL of the control plane API |
JOB_ID |
Identifies the current run |
WORK_DIR |
Local scratch directory (default /tmp/work) |
ctx = WorkersContext(
control_plane_url=os.environ.get("CONTROL_PLANE_URL"),
job_id=os.environ.get("JOB_ID"),
work_dir=os.environ.get("WORK_DIR"),
api_key=os.environ.get("API_KEY"),
)
API
ctx.input(bucket, dest_folder, filenames=None)
Pulls data from a bucket into dest_folder. Omit filenames to pull the
whole bucket; pass a list to pull only those specific files.
ctx.input(bucket="checko19", dest_folder="input")
ctx.input(bucket="checko19", dest_folder="input", filenames=["cars.csv"])
ctx.output(local_path, url)
Uploads a single local file to a presigned upload URL.
ctx.publish(dest_folder, bucketname)
Uploads everything under dest_folder to bucketname, preserving folder
structure.
ctx.publish(dest_folder="output", bucketname="checko20")
ctx.deploy(model_path, profile, name=None)
Uploads a trained model artifact (file or folder) and registers it with the control plane as a deployable endpoint.
ctx.deploy(model_path="model", profile="linear-regression", name="cars-price-model")
profile must be one of the platform's known pipeline profiles (e.g.
linear-regression, llm-train, llm-infer).
ctx.run_requirements(filepath="requirements.txt")
Installs a requirements.txt next to your script before it runs, if one
exists. No-ops if the file isn't found.
License
MIT
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 serwin_sdk-0.2.1.tar.gz.
File metadata
- Download URL: serwin_sdk-0.2.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
737aca3b51c1a4e4d05825c001179703f3e9d4824bc68b6f518346c3424c24ea
|
|
| MD5 |
00f71ceb534379d1e1f6515a48724845
|
|
| BLAKE2b-256 |
b08a886e77692a9c3e02c427e743cbbd3e3d151ffe6c86c08f3bad2bee4e23c5
|
File details
Details for the file serwin_sdk-0.2.1-py3-none-any.whl.
File metadata
- Download URL: serwin_sdk-0.2.1-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e3f7bbd3ce58765445b6f07bc84d63bb710dedb32ed4536c4b254b18b71124f
|
|
| MD5 |
9ad1f3e4dfd1916fece031f85ced26d6
|
|
| BLAKE2b-256 |
1a20a55624c95d025a99714d980c31ec1e3cf1ffa6c2f1c3ecd4a629f3e6e7b0
|