Skaha¶
A lightweight python interface to the CANFAR Science Platform.
Example
from skaha.session import Session
session = Session()
session_id = session.create(
name="test",
image="images.canfar.net/skaha/base-notebook:latest",
cores=2,
ram=8,
gpu=1,
kind="headless",
cmd="env",
env={"KEY": "VALUE"},
replicas=3,
)
What's New¶
New in v1.6+
๐ Asynchronous Sessions¶
Skaha now supports asynchronous sessions using the AsyncSession class while maintaining 1-to-1 compatibility with the Session class.
from skaha.session import AsyncSession
asession = AsyncSession()
response = await asession.create(
name="test",
image="images.canfar.net/skaha/base-notebook:latest",
cores=2,
ram=8,
gpu=1,
kind="headless",
cmd="env",
env={"KEY": "VALUE"},
replicas=3,
)
๐๏ธ Backend Upgrades¶
- ๐ก Skaha now uses the
httpxlibrary for making HTTP requests instead ofrequests. This adds asynchronous support and also to circumvent therequestsdependence onurllib3which was causing SSL issues on MacOS. See this issue for more details. - ๐ Skaha now supports tokens for authentication. As a result, the constraints for providing a valid certificate filepath have been relaxed and are only enforced when the certificate is used for authentication.
- ๐๏ธ๐จ Added
loglevelandconcurrencysupport to manage the new explosion in functionality!s
๐งพ Logs to stdout¶
The [Session|AsyncSession].logs method now prints colored output to stdout instead of returning them as a string with verbose=True flag.
from skaha.session import AsyncSession
asession = AsyncSession()
await asession.logs(ids=["some-uuid"], verbose=True)
๐ชฐ Firefly Support¶
Skaha now supports launching firefly session on the CANFAR Science Platform.
session.create(
name="firefly",
image="images.canfar.net/skaha/firefly:latest",
)
New in v1.4+
๐ Private Images¶
Starting October 2024, to create a session with a private container image from the CANFAR Harbor Registry, you will need to provide your harbor username and the CLI Secret through a ContainerRegistry object.
from skaha.models import ContainerRegistry
from skaha.session import Session
registry = ContainerRegistry(username="username", secret="sUp3rS3cr3t")
session = Session(registry=registry)
Alernatively, if you have environment variables, SKAHA_REGISTRY_USERNAME and SKAHA_REGISTRY_SECRET, you can create a ContainerRegistry object without providing the username and secret.
from skaha.models import ContainerRegistry
registry = ContainerRegistry()
๐ฃ Destroy Sessions¶
from skaha.session import Session
session = Session()
session.destroy_with(prefix="test", kind="headless", status="Running")
session.destroy_with(prefix="test", kind="headless", status="Pending")