Compute Config API Reference
Customer-hosted cloud features
Some features are only available on customer-hosted clouds. Reach out to preview-help@anyscale.com for info.
Compute Config Models
ComputeConfig
Configuration for instance types and cloud resources for a cluster.
Fields
cloud
(str | None): The Anyscale Cloud to run this workload on. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).head_node
(HeadNodeConfig | Dict | None): Configuration options for the head node of the cluster. Defaults to the cloud's default head node configuration.worker_nodes
(List[WorkerNodeGroupConfig | Dict] | None): Configuration options for the worker nodes of the cluster. If not provided, worker nodes will be automatically selected based on logical resource requests. To use a head-node only cluster, pass[]
here.max_resources
(Dict[str, float] | None): Total maximum logical resources across all nodes in the cluster. Resources omitted from this field have no maximum. Only 'CPU' and 'GPU' resource limits are currently supported.zones
(List[str] | None): Availability zones to consider for this cluster. Defaults to all zones in the cloud's region. By default all instances will run in the same zone to save cost, unlessenable_cross_zone_scaling
is set.- Only available on customer-hosted clouds.
enable_cross_zone_scaling
(bool): Allow instances in the cluster to be run across multiple zones. This is recommended when running production services (for fault-tolerance in a zone failure scenario). It is not recommended for workloads that have a large amount of inter-zone communication due to the possibility of higher costs and degraded performance.- Only available on customer-hosted clouds.
advanced_instance_config
(Dict[str, Any] | None): Advanced instance configurations that will be passed through to the cloud provider.- Only available on customer-hosted clouds.
flags
(Dict[str, Any] | None): Cluster-level flags specifying advanced or experimental options.
Python Methods
def __init__(self, **fields) -> ComputeConfig
"""Construct a model with the provided field values set."""
def options(self, **fields) -> ComputeConfig
"""Return a copy of the model with the provided field values overwritten."""
def to_dict(self) -> Dict[str, Any]
"""Return a dictionary representation of the model."""
Examples
- YAML
- Python
cloud: my-cloud
head_node:
instance_type: m5.8xlarge
worker_nodes:
- instance_type: m5.8xlarge
min_nodes: 5
max_nodes: 5
- instance_type: m5.4xlarge
min_nodes: 1
max_nodes: 10
market_type: SPOT
from anyscale.compute_config.models import (
ComputeConfig, HeadNodeConfig, MarketType, WorkerNodeGroupConfig
)
config = ComputeConfig(
cloud="my-cloud",
head_node=HeadNodeConfig(
instance_type="m5.8xlarge",
),
worker_nodes=[
WorkerNodeGroupConfig(
instance_type="m5.8xlarge",
min_nodes=5,
max_nodes=5,
),
WorkerNodeGroupConfig(
instance_type="m5.4xlarge",
min_nodes=1,
max_nodes=10,
market_type=MarketType.SPOT,
),
],
)
HeadNodeConfig
Configuration options for the head node of a cluster.
Fields
instance_type
(str): Cloud provider instance type, e.g.,m5.2xlarge
on AWS orn2-standard-8
on GCP.resources
(Dict[str, float] | None): Logical resources that will be available on this node. Defaults to match the physical resources of the instance type.advanced_instance_config
(Dict[str, Any] | None): Advanced instance configurations that will be passed through to the cloud provider.- Only available on customer-hosted clouds.
flags
(Dict[str, Any] | None): Node-level flags specifying advanced or experimental options.
Python Methods
def __init__(self, **fields) -> HeadNodeConfig
"""Construct a model with the provided field values set."""
def options(self, **fields) -> HeadNodeConfig
"""Return a copy of the model with the provided field values overwritten."""
def to_dict(self) -> Dict[str, Any]
"""Return a dictionary representation of the model."""
Examples
- YAML
- Python
head_node:
instance_type: m5.8xlarge
from anyscale.compute_config.models import ComputeConfig, HeadNodeConfig
config = ComputeConfig(
head_node=HeadNodeConfig(
instance_type="m5.8xlarge",
),
)
WorkerNodeGroupConfig
Configuration options for a worker node group in a cluster.
Clusters can have multiple worker node groups that use different instance types or configurations.
Fields
instance_type
(str): Cloud provider instance type, e.g.,m5.2xlarge
on AWS orn2-standard-8
on GCP.resources
(Dict[str, float] | None): Logical resources that will be available on this node. Defaults to match the physical resources of the instance type.advanced_instance_config
(Dict[str, Any] | None): Advanced instance configurations that will be passed through to the cloud provider.- Only available on customer-hosted clouds.
flags
(Dict[str, Any] | None): Node-level flags specifying advanced or experimental options.name
(str | None): Unique name of this worker group. Defaults to a human-friendly representation of the instance type.min_nodes
(int): Minimum number of nodes of this type that will be kept running in the cluster.max_nodes
(int): Maximum number of nodes of this type that can be running in the cluster.market_type
(str | MarketType): The type of instances to use (seeMarketType
enum values for details).- Only available on customer-hosted clouds.
Python Methods
def __init__(self, **fields) -> WorkerNodeGroupConfig
"""Construct a model with the provided field values set."""
def options(self, **fields) -> WorkerNodeGroupConfig
"""Return a copy of the model with the provided field values overwritten."""
def to_dict(self) -> Dict[str, Any]
"""Return a dictionary representation of the model."""
Examples
- YAML
- Python
worker_nodes:
- instance_type: m5.8xlarge
min_nodes: 5
max_nodes: 5
- instance_type: m5.4xlarge
min_nodes: 1
max_nodes: 10
market_type: SPOT
from anyscale.compute_config.models import ComputeConfig, MarketType, WorkerNodeGroupConfig
config = ComputeConfig(
worker_nodes=[
WorkerNodeGroupConfig(
instance_type="m5.8xlarge",
min_nodes=5,
max_nodes=5,
),
WorkerNodeGroupConfig(
instance_type="m5.4xlarge",
min_nodes=1,
max_nodes=10,
market_type=MarketType.SPOT,
),
],
)
MarketType
Market type of instances to use (on-demand vs. spot).
Values
ON_DEMAND
: Use on-demand instances only.SPOT
: Use spot instances only.PREFER_SPOT
: Prefer to use spot instances, but fall back to on-demand if necessary. If on-demand instances are running and spot instances become available, the on-demand instances will be evicted and replaced with spot instances.
ComputeConfigVersion
Details of a created version of a compute config.
Includes the config options and metadata such as the name, version, and ID.
Fields
name
(str): Name of the compute config including the version tag, i.e., 'name:version'.id
(str): Unique ID of the compute config.config
(ComputeConfig): The compute configuration.
Python Methods
def to_dict(self) -> Dict[str, Any]
"""Return a dictionary representation of the model."""
Examples
- Python
- CLI
import anyscale
from anyscale.compute_config.models import (
ComputeConfigVersion
)
version: ComputeConfigVersion = anyscale.compute_config.get("my-compute-config")
$ anyscale compute-config get -n my-compute-config
name: my-compute-config:1
id: cpt_r4b4b3621rl3uggg7llj3mvme6
config:
cloud: my-cloud
head_node:
instance_type: m5.8xlarge
worker_nodes:
- instance_type: m5.8xlarge
min_nodes: 5
max_nodes: 5
- instance_type: m5.4xlarge
min_nodes: 1
max_nodes: 10
market_type: SPOT
Compute Config CLI
anyscale compute-config create
Usage
anyscale compute-config create [OPTIONS] [COMPUTE_CONFIG_FILE]
Create a new version of a compute config from a YAML file.
(1) To use the new schema defined at https://docs.anyscale.com/preview/reference/compute-config-api#computeconfig, use the -f/--config-file flag:
anyscale compute-config create -f new_schema_config.yaml
(2) To use the old schema defined at https://docs.anyscale.com/reference/python-sdk/models#createclustercomputeconfig, use the positional argument:
anyscale compute-config create old_schema_config.yaml
Options
-n/--name
: Name for the created compute config. This should not include a version tag. If a name is not provided, an anonymous compute config is generated. Anonymous compute configs are not accessible in the UI and can only be referenced by their ID.-f/--config-file
: Path to a YAML config file defining the compute config. Schema: https://docs.anyscale.com/preview/reference/compute-config-api#computeconfig.
anyscale compute-config get
Usage
anyscale compute-config get [OPTIONS] [COMPUTE_CONFIG_NAME]
Get the details of a compute config.
The name can contain an optional version, e.g., 'name:version'. If no version is provided, the latest one will be archived.
Options
-n/--name
: Name of the compute config.--compute-config-id/--id
: ID of the compute config. Alternative to name.--include-archived
: Include archived compute configurations.--old-format
: Output the config in the old format: https://docs.anyscale.com/reference/python-sdk/models#createclustercomputeconfig.
anyscale compute-config archive
Usage
anyscale compute-config archive [OPTIONS] [COMPUTE_CONFIG_NAME]
Archive all versions of a specified compute config.
Options
-n/--name
: Name of the compute config to archive.--compute-config-id/--id
: ID of the compute config to archive. Alternative to name.
Compute Config SDK
anyscale.compute_config.create
Create a new version of a compute config.
Returns the full name of the registered compute config, including the version.
Arguments
config
(ComputeConfig): The config options defining the compute config.name
(str | None): The name of the compute config. This should not include a version tag. If a name is not provided, one will be automatically generated.
Returns: str
Examples
- Python
import anyscale
from anyscale.compute_config.models import ComputeConfig, HeadNodeConfig, MarketType, WorkerNodeGroupConfig
config = ComputeConfig(
head_node=HeadNodeConfig(
instance_type="m5.8xlarge",
),
worker_nodes=[
WorkerNodeGroupConfig(
instance_type="m5.8xlarge",
min_nodes=5,
max_nodes=5,
),
WorkerNodeGroupConfig(
instance_type="m5.4xlarge",
min_nodes=1,
max_nodes=10,
market_type=MarketType.SPOT,
),
],
)
full_name: str = anyscale.compute_config.create(config, name="my-compute-config")
anyscale.compute_config.get
Get the compute config with the specified name.
The name can contain an optional version tag, i.e., 'name:version'. If no version is provided, the latest one will be returned.
Arguments
name
(str): The name of the compute config. This can inclue an optional version tag, i.e., 'name:version'. If no version tag is provided, the latest version will be returned.include_archived
(bool) = False: Whether to consider archived compute configs (defaults to False).
Returns: ComputeConfigVersion
Examples
- Python
import anyscale
from anyscale.compute_config.models import ComputeConfig
compute_config: ComputeConfig = anyscale.compute_config.get("my-compute-config")
anyscale.compute_config.archive
Archive a compute config and all of its versions.
The name can contain an optional version, e.g., 'name:version'. If no version is provided, the latest one will be archived.
Once a compute config is archived, its name will no longer be usable in the organization.
Arguments
name
(str): Name of the compute config.
Examples
- Python
import anyscale
anyscale.compute_config.archive(name="my-compute-config")