mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 00:36:31 +02:00
add snapshot creation script for surfsense-sandbox
This commit is contained in:
parent
1e74c87aa1
commit
c72b737a81
1 changed files with 46 additions and 0 deletions
46
surfsense_backend/scripts/create_sandbox_snapshot.py
Normal file
46
surfsense_backend/scripts/create_sandbox_snapshot.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
"""Create the Daytona snapshot used by SurfSense sandboxes.
|
||||
|
||||
Usage:
|
||||
uv run python scripts/create_sandbox_snapshot.py
|
||||
|
||||
Requires DAYTONA_API_KEY (and optionally DAYTONA_API_URL / DAYTONA_TARGET)
|
||||
to be set in the environment or in a .env file.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from daytona import CreateSnapshotParams, Daytona, DaytonaConfig, Image
|
||||
|
||||
SNAPSHOT_NAME = "surfsense-sandbox"
|
||||
|
||||
PACKAGES = [
|
||||
"pandas",
|
||||
"numpy",
|
||||
"matplotlib",
|
||||
"scipy",
|
||||
"scikit-learn",
|
||||
]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
config = DaytonaConfig(
|
||||
api_key=os.environ.get("DAYTONA_API_KEY", ""),
|
||||
api_url=os.environ.get("DAYTONA_API_URL", "https://app.daytona.io/api"),
|
||||
target=os.environ.get("DAYTONA_TARGET", "us"),
|
||||
)
|
||||
daytona = Daytona(config)
|
||||
|
||||
image = Image.debian_slim("3.12").pip_install(*PACKAGES)
|
||||
|
||||
print(f"Creating snapshot '{SNAPSHOT_NAME}' with packages: {', '.join(PACKAGES)}")
|
||||
snapshot = daytona.snapshot.create(
|
||||
CreateSnapshotParams(name=SNAPSHOT_NAME, image=image),
|
||||
on_logs=lambda chunk: print(chunk, end=""),
|
||||
)
|
||||
print(f"\nSnapshot created: {snapshot.name}")
|
||||
print(f"Set DAYTONA_SNAPSHOT_ID={snapshot.name} in your .env")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main() or 0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue