Skaha Usage Examples¶
Session API¶
The bread and butter of Skaha is the Session API. This API allows you to create, destroy, and get information about your sessions on the Skaha platform.
Creating a Session¶
from skaha.session import Session
session = Session()
session_id = session.create(
name="test",
image="images.canfar.net/chimefrb/testing:keep",
cores=2,
ram=8,
kind="headless",
cmd="env",
env={"TEST": "test"},
replicas=3,
)
This will create three headless containers, each with 2 cores and 8GB of RAM, and run the command env
in each container. The environment variable TEST
will be set to test
in each container.
The response will be a list of session IDs created.
Getting Session Information¶
[{'id': 'mrjdtbn9',
'userid': 'shinybrar',
'image': 'images.canfar.net/chimefrb/testing:keep',
'type': 'headless',
'status': 'Succeeded',
'name': 'test',
'startTime': '2022-12-15T18:59:12Z',
'connectURL': 'not-applicable',
'requestedRAM': '8G',
'requestedCPUCores': '2',
'requestedGPUCores': '<none>',
'coresInUse': '<none>',
'ramInUse': '<none>'},
...
{'id': 'ayv4553m',
'userid': 'shinybrar',
'image': 'images.canfar.net/chimefrb/testing:keep',
'type': 'headless',
'status': 'Succeeded',
'name': 'test',
'startTime': '2022-12-15T18:59:13Z',
'connectURL': 'not-applicable',
'requestedRAM': '8G',
'requestedCPUCores': '2',
'requestedGPUCores': '<none>',
'coresInUse': '<none>',
'ramInUse': '<none>'}]
Getting Session Logs¶
To get the logs of a session, you can use the logs
method. The response will be a dictionary with the session IDs as keys and the logs as values.
The logs are plain text format and can be printed to the console.
Destroying a Session¶
When you are done with your session, you can destroy it using the destroy
method.
The response will be a dictionary with the session IDs as keys and a boolean value indicating whether the session was destroyed or not.
Image API¶
The Image API allows you to get information about the images available on the Skaha platform. Nominally,
Getting Image Information¶
But most of the time, you are only interested in images of a particular type. For example, if you want to get all the images that are available for headless sessions, you can do the following:
[
"images.canfar.net/chimefrb/testing:keep",
"images.canfar.net/lsst/lsst_v19_0_0:0.1",
"images.canfar.net/skaha/lensfit:22.11",
"images.canfar.net/skaha/lensfit:22.10",
"images.canfar.net/skaha/lensingsim:22.07",
"images.canfar.net/skaha/phosim:5.6.11",
"images.canfar.net/skaha/terminal:1.1.2",
"images.canfar.net/skaha/terminal:1.1.1",
"images.canfar.net/uvickbos/pycharm:0.1",
"images.canfar.net/uvickbos/swarp:0.1",
"images.canfar.net/uvickbos/isis:2.2",
"images.canfar.net/uvickbos/find_moving:0.1",
]
Context API¶
Context API allows the user to get information about the resources available on the Skaha platform.