Skip to main content

Python library for interacting with Saturn Cloud API

Project description

saturn-client

Python library for interacting with Saturn Cloud API.

Connect

This library is intended primarily as a way to interact with Saturn Cloud from outside of the Saturn User Interface.

External

To connect to Saturn you'll need the URL of your Saturn instance. It'll be something like: "https://app.community.saturnenterprise.io/". You'll also need your api token. You can get your token in the browser by logging in to saturn and then going to /api/user/token. So in the case of Saturn Cloud Hosted that'll be "https://app.community.saturnenterprise.io/api/user/token".

Note that this library is new and experimental - we expect to make this process easier in the future.

from saturn_client import SaturnConnection

# From outside of Saturn
conn = SaturnConnection(
    url="https://app.community.saturnenterprise.io/",
    api_token="fake_token_use_your_own"
)

Internal

From inside of saturn on the other hand you can just run:

from saturn_client import SaturnConnection

# From inside of Saturn
conn = SaturnConnection()

Create a Project

Once you have your connection object (conn) you can create a project.

The minimal acceptable input is the name of the project:

project = conn.create_project(name="my-project")

But all the other settings that are available in the UI can also be passed in:

project = conn.create_project(
    name="my-project",
    description="My new project - created from outside of Saturn programatically!",
    image_uri="saturncloud/saturn-gpu:2020.11.30",
    start_script="pip install git+https://github.com/saturncloud/dask-saturn.git@main",
    environment_variables={"DATA_URL": "s3://my-bucket/data"},
    working_dir="/home/jovyan/project",
    jupyter_size="large",
    jupyter_disk_space="50Gi",
    jupyter_auto_shutoff="Never",
    jupyter_start_ssh=False,
)

Other project methods

List all projects

Get a list of all the projects that you have access to.

conn.list_projects()

Get a project

Get the details of a particular project by ID.

project = conn.get_project("18ad47c81c5943ad9ae641b11367d1b1")

Update a project

Update a particular project by ID. Any field that can be used in create_project can also be used in update_project except for name.

project = conn.update_project("18ad47c81c5943ad9ae641b11367d1b1", image="saturncloud/saturn:2020.12.11")

Use the update_jupyter_server option to keep the jupyter_server uptodate with the project - this is set to True by default:

NOTE: If the jupyter server is running for this project it will be stopped and so will the dask cluster associated with that jupyter. You can start these back up using the start_jupyter_server method and the start_dask_cluster method.

Delete a project

Delete a particular project by ID.

conn.delete_project("18ad47c81c5943ad9ae641b11367d1b1")

Jupyter server methods

Jupyter server methods act directly on the jupyter server and require the jupyter_server_id. This can be found on the response from any of the project methods.

Get a jupyter server

Get the details of a particular jupyter server by ID.

jupyter_server = conn.get_jupyter_server("acb4588d062d4d0ba0680a4d49c72cf8")

Start a jupyter server

Start a particular jupyter server by ID. This method will return as soon as the start process has been triggered. It'll take longer for the jupyter server to be up, but you can check the status using get_jupyter_server.

conn.start_jupyter_server("acb4588d062d4d0ba0680a4d49c72cf8")

Stop a jupyter server

Stop a particular jupyter server by ID. This method will return as soon as the stop process has been triggered. It'll take longer for the jupyter server to actually shut down, but you can check the status using get_jupyter_server.

conn.stop_jupyter_server("acb4588d062d4d0ba0680a4d49c72cf8")

Dask cluster methods

Dask cluster methods act directly on the dask cluster and require the dask_cluster_id. This can be found on the response from get_jupyter_server.

Start a dask cluster

Start a dask cluster by ID. This method will return as soon as the start process has been triggered. It'll take longer for the dask cluster to be up. This is primarily useful when the dask cluster has been stopped as a side-effect of stopping a jupyter server or updating a project. For more fine-grain control over the dask cluster see dask-saturn.

conn.start_dask_cluster("e59862cbde6647e09ec1202c21b8947a")

Stop a dask cluster

Stop a particular dask cluster by ID. This method will return as soon as the stop process has been triggered. It'll take longer for the dask cluster to actually shut down.

conn.stop_dask_cluster("e59862cbde6647e09ec1202c21b8947a")

Miscelaneous

Some convenience properties are included on SaturnConnection. These include conn.options which describes the options available for workspace settings.

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

saturn-client-0.0.3.tar.gz (26.2 kB view details)

Uploaded Source

Built Distribution

saturn_client-0.0.3-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file saturn-client-0.0.3.tar.gz.

File metadata

  • Download URL: saturn-client-0.0.3.tar.gz
  • Upload date:
  • Size: 26.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7

File hashes

Hashes for saturn-client-0.0.3.tar.gz
Algorithm Hash digest
SHA256 de831a04af26d874a5f31a42151d7acf07a3a302ff292b531547a2d2aa1f013b
MD5 4c53808aca10a94e66b7e69bb213e22c
BLAKE2b-256 abfbff5e79260676699652e6120382f3a9f0d5216e57b3c2abef8081df3af1bf

See more details on using hashes here.

Provenance

File details

Details for the file saturn_client-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: saturn_client-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.8.7

File hashes

Hashes for saturn_client-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6c13abae45c5caba019213cb85a74d55313b451944843b033bad7a1474f3bcef
MD5 78ad9039c4c91e725a9b120c0d83606a
BLAKE2b-256 589869613dc9848da22124c273cdab62211faa89e0349ab5ac3ca51f4294e339

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page