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 AnyscaleSDKsdk =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
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
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
fetch_actor_logs
Retrieves logs for an Actor.
This function may take several minutes if the Cluster this Actor ran on has been terminated.
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.
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.
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.