(A - C)

A comprehensive list of all available functions and models available in our Python SDK.

Python SDK Reference

Utility Functions

launch_cluster

Starts a Cluster in the specified Project.

If a Cluster with the specified name already exists, we will update that Cluster. Otherwise, a new Cluster will be created.

Returns the started Cluster object.

Raises an Exception if starting Cluster fails or times out.

Param
Type
Description

project_id

String

ID of the Project the Cluster belongs to

cluster_name

String

Name of the Cluster

cluster_environment_build_id

String

ID of the Cluster Environment Build to start this Cluster with

cluster_compute_id

String

ID of the Cluster Compute to start this Cluster with

poll_rate_seconds

Optional Integer

seconds to wait when polling cluster operation status; defaults to 15

idle_timeout_minutes

Optional Integer

Idle timeout (in minutes), after which the Cluster is terminated; Defaults to 120 minutes.

timeout_seconds

Optional Integer

maximum number of seconds to wait for cluster operation to complete before timing out; defaults to no timeout

Example

from anyscale import AnyscaleSDK

sdk = AnyscaleSDK(auth_token="sss_YourAuthToken")

cluster = sdk.launch_cluster(
    project_id="project_id",
    cluster_name="my-cluster",
    cluster_environment_build_id="cluster_environment_build_id",
    cluster_compute_id="cluster_compute_id")

print(f"Cluster started successfully: {cluster}")

launch_cluster_with_new_cluster_environment

Builds a new Cluster Environment, then starts a Cluster in the specified Project with the new build.

If a Cluster with the specified name already exists, we will update that Cluster. Otherwise, a new Cluster will be created.

Returns the started Cluster object.

Raises an Exception if building Cluster Environment fails or starting the Cluster fails.

Param
Type
Description

project_id

String

ID of the Project the Cluster belongs to

cluster_name

String

Name of the Cluster

create_cluster_environment

CreateClusterEnvironment

CreateClusterEnvironment object

cluster_compute_id

String

Cluster Compute to start this Cluster with

poll_rate_seconds

Optional Integer

seconds to wait when polling operation status; defaults to 15

timeout_seconds

Optional Integer

maximum number of seconds to wait for operations to complete before timing out; defaults to no timeout

Example

from anyscale import AnyscaleSDK
from anyscale.sdk.anyscale_client.models.create_cluster_environment import (
    CreateClusterEnvironment,
)

sdk = AnyscaleSDK(auth_token="sss_YourAuthToken")

create_cluster_environment = CreateClusterEnvironment(
    name="my-cluster-environment",
    config_json={"base_image": "anyscale/ray:1.4.1-py37"}
)

cluster = sdk.launch_cluster_with_new_cluster_environment(
    project_id="project_id",
    cluster_name="my-cluster",
    create_cluster_environment=create_cluster_environment,
    cluster_compute_id="cluster_compute_id",
)

print(f"Cluster started successfully: {cluster}")

build_cluster_environment

Creates a new Cluster Environment and waits for build to complete.

If a Cluster Environment with the same name already exists, this will create an updated build of that environment.

Returns the newly created ClusterEnvironmentBuild object.

Raises an Exception if building Cluster Environment fails or times out.

Param
Type
Description

create_cluster_environment

CreateClusterEnvironment

CreateClusterEnvironment object

poll_rate_seconds

Optional Integer

seconds to wait when polling build operation status; defaults to 15

timeout_seconds

Optional Integer

maximum number of seconds to wait for build operation to complete before timing out; defaults to no timeout

Example

from anyscale.sdk.anyscale_client.models.create_cluster_environment import (
    CreateClusterEnvironment,
)
from anyscale import AnyscaleSDK

sdk = AnyscaleSDK(auth_token="sss_YourAuthToken")

create_cluster_environment = CreateClusterEnvironment(
    name="my-cluster-environment",
    config_json={"base_image": "anyscale/ray:1.4.1-py37"}
)

cluster_environment_build = sdk.build_cluster_environment(
    create_cluster_environment=create_cluster_environment
)

print(f"Cluster Environment built successfully: {cluster_environment_build})

fetch_job_logs

Retrieves logs for a Job.

This function may take several minutes if the Cluster this Job ran on has been terminated.

Returns the log output as a string.

Raises an Exception if fetching logs fails.

Param
Type
Description

job_id

String

ID of the Job

Example

from anyscale import AnyscaleSDK

sdk = AnyscaleSDK(auth_token="sss_YourAuthToken")

job_logs = sdk.fetch_job_logs(job_id="job_id")

print(job_logs)

fetch_actor_logs

Retrieves logs for an Actor.

This function may take several minutes if the Cluster this Actor ran on has been terminated.

Returns the log output as a string.

Raises an Exception if fetching logs fails.

Param
Type
Description

actor_id

String

ID of the Actor

Example

from anyscale.sdk.anyscale_client.models.create_cluster_environment import (
    CreateClusterEnvironment,
)
from anyscale import AnyscaleSDK

sdk = AnyscaleSDK(auth_token="sss_YourAuthToken")

actor_logs = sdk.fetch_actor_logs(actor_id="actor_id")

print(actor_logs)

The OpenAPI schemas for types below can be found at the Anyscale OpenAPI Documentation

All of the following functions are synchronous by default. To make an asynchronous HTTP request, please pass async_req=True. The return value for the asynchronous calls is a thread.

thread = api.create_cloud(create_cloud, async_req=True)
result = thread.get()

Actors

get_actor

Gets an Actor by ID.

Parameters

Name
Type
Description
Notes

actor_id

str

ID of the Actor to retrieve.

Defaults to null

Returns ActorResponse

get_actor_logs

Gets an Actor's logs.

Parameters

Name
Type
Description
Notes

actor_id

str

ID of the Actor to get logs for.

Defaults to null

Returns ActorlogsResponse

search_actors

Lists all Actors the user has access to, matching the input query.

Parameters

Name
Type
Description
Notes

actors_query

Returns ActorListResponse

Clouds

create_cloud

Creates a Cloud.

Parameters

Name
Type
Description
Notes

create_cloud

Returns CloudResponse

delete_cloud

Deletes a Cloud.

Parameters

Name
Type
Description
Notes

cloud_id

str

ID of the Cloud to delete.

Defaults to null

Returns void (empty response body)

get_cloud

Retrieves a Cloud.

Parameters

Name
Type
Description
Notes

cloud_id

str

ID of the Cloud to retrieve.

Defaults to null

Returns CloudResponse

search_clouds

Searches for all accessible Clouds that satisfies the query.

Parameters

Name
Type
Description
Notes

clouds_query

Returns CloudListResponse

update_cloud

Updates a Cloud.

Parameters

Name
Type
Description
Notes

cloud_id

str

ID of the Cloud to update.

Defaults to null

update_cloud

Returns CloudResponse

Cluster Computes

create_cluster_compute

Creates a Cluster Compute.

Parameters

Name
Type
Description
Notes

create_cluster_compute

Returns ClustercomputeResponse

delete_cluster_compute

Deletes a Cluster Compute.

Parameters

Name
Type
Description
Notes

cluster_compute_id

str

ID of the Cluster Compute to delete.

Defaults to null

Returns void (empty response body)

get_cluster_compute

Retrieves a Cluster Compute.

Parameters

Name
Type
Description
Notes

cluster_compute_id

str

ID of the Cluster Compute to retrieve.

Defaults to null

Returns ClustercomputeResponse

search_cluster_computes

Lists all Cluster Computes the user has access to, matching the input query.

Parameters

Name
Type
Description
Notes

cluster_computes_query

Returns ClustercomputeListResponse

Cluster Environment Build Operations

get_cluster_environment_build_operation

Retrives a Cluster Environment Build Operation.

Parameters

Name
Type
Description
Notes

cluster_environment_build_operation_id

str

ID of the Cluster Environment Build Operation to retrieve.

Defaults to null

Returns ClusterenvironmentbuildoperationResponse

Cluster Environment Builds

cancel_cluster_environment_build

Cancels a Cluster Environment Build that is still in progress. This is a long running operation.

Parameters

Name
Type
Description
Notes

cluster_environment_build_id

str

ID of the Cluster Environment Build to cancel.

Defaults to null

Returns ClusterenvironmentbuildoperationResponse

create_cluster_environment_build

Creates and starts a Cluster Environment Build. This is a long running operation.

Parameters

Name
Type
Description
Notes

create_cluster_environment_build

Returns ClusterenvironmentbuildoperationResponse

delete_cluster_environment_build

Deletes a Cluster Environment Build.

Parameters

Name
Type
Description
Notes

cluster_environment_build_id

str

ID of the Cluster Environment Build to delete.

Defaults to null

Returns void (empty response body)

get_cluster_environment_build

Retrieves a Cluster Environment Build.

Parameters

Name
Type
Description
Notes

cluster_environment_build_id

str

ID of the Cluster Environment Build to retrieve.

Defaults to null

Returns ClusterenvironmentbuildResponse

get_cluster_environment_build_logs

Retrieves logs for a Cluster Environment Build.

Parameters

Name
Type
Description
Notes

cluster_environment_build_id

str

ID of the Cluster Environment Build to retrieve logs for.

Defaults to null

Returns ClusterenvironmentbuildlogresponseResponse

list_cluster_environment_builds

Lists all Cluster Environment Builds belonging to an Cluster Environment.

Parameters

Name
Type
Description
Notes

cluster_environment_id

str

ID of the Cluster Environment to list builds for.

Defaults to null

paging_token

optional str

Defaults to null

count

optional int

Defaults to 10

Returns ClusterenvironmentbuildListResponse

Cluster Environments

create_cluster_environment

Creates a Cluster Environment.

Parameters

Name
Type
Description
Notes

create_cluster_environment

Returns ClusterenvironmentResponse

delete_cluster_environment

Deletes a Cluster Environment.

Parameters

Name
Type
Description
Notes

cluster_config_id

str

ID of the Cluster Environment to delete.

Defaults to null

Returns void (empty response body)

get_cluster_environment

Retrieves a Cluster Environment.

Parameters

Name
Type
Description
Notes

cluster_environment_id

str

ID of the Cluster Environment to retrieve.

Defaults to null

Returns ClusterenvironmentResponse

search_cluster_environments

Lists all Cluster Environments that the logged in user has permissions to access.

Parameters

Name
Type
Description
Notes

cluster_environments_query

Returns ClusterenvironmentListResponse

Cluster Operations

get_cluster_operation

Retrieves a Cluster Operation.

Parameters

Name
Type
Description
Notes

cluster_operation_id

str

ID of the Cluster Operation to retrieve.

Defaults to null

Returns ClusteroperationResponse

Clusters

create_cluster

Creates a Cluster.

Parameters

Name
Type
Description
Notes

create_cluster

Returns ClusterResponse

delete_cluster

Deletes a Cluster.

Parameters

Name
Type
Description
Notes

cluster_id

str

ID of the Cluster to delete.

Defaults to null

Returns void (empty response body)

get_cluster

Retrieves a Cluster.

Parameters

Name
Type
Description
Notes

cluster_id

str

ID of the Cluster to retreive.

Defaults to null

Returns ClusterResponse

search_clusters

Searches for all Clusters the user has access to that satisfies the query.

Parameters

Name
Type
Description
Notes

clusters_query

Returns ClusterListResponse

start_cluster

Initializes workflow to transition the Cluster into the Running state. The Cluster will be updated if Cluster Environment Build or Cluster Compute is provided in the options. This is a long running operation. Clients will need to poll the operation's status to determine completion.

Parameters

Name
Type
Description
Notes

cluster_id

str

ID of the Cluster to start.

Defaults to null

start_cluster_options

Returns ClusteroperationResponse

terminate_cluster

Initializes workflow to transition the Cluster into the Terminated state. This is a long running operation. Clients will need to poll the operation's status to determine completion.

Parameters

Name
Type
Description
Notes

cluster_id

str

ID of the Cluster to terminate.

Defaults to null

terminate_cluster_options

Returns ClusteroperationResponse

update_cluster

Updates a Cluster.

Parameters

Name
Type
Description
Notes

cluster_id

str

ID of the Cluster to update.

Defaults to null

update_cluster

Returns ClusterResponse

Last updated

Was this helpful?