Resource quotas SDK reference
Resource quotas SDK reference
Customer-hosted cloud features
note
Some features are only available on customer-hosted clouds. Reach out to support@anyscale.com for info.
Resource quotas SDK
anyscale.resource_quota.create
Create a resource quota.
Arguments
create_resource_quota(CreateResourceQuota): The resource quota to be created.
Returns: ResourceQuota
Examples
- Python
import anyscale
from anyscale.resource_quota.models import CreateResourceQuota
anyscale.resource_quota.create(
CreateResourceQuota(
name="my-resource-quota",
cloud="my-cloud",
project="my-project",
num_cpus=2,
),
)
anyscale.resource_quota.list
List resource quotas.
Arguments
name(str | None) = None: Name of the resource quota.cloud(str | None) = None: Name of the cloud that this resource quota applies to.creator_id(str | None) = None: ID of the creator of the resource quota.is_enabled(bool | None) = None: Whether the resource quota is enabled.max_items(int) = 20: Maximum number of items to return.
Returns: List[ResourceQuota]
Examples
- Python
import anyscale
anyscale.resource_quota.list(
name="my-resource-quota",
cloud="my-cloud",
creator_id="usr_123",
is_enabled=True,
max_items=20,
)
anyscale.resource_quota.delete
Delete a resource quota.
Arguments
resource_quota_id(str): ID of the resource quota to delete.
Examples
- Python
import anyscale
anyscale.resource_quota.delete(
resource_quota_id="rq_123",
)
anyscale.resource_quota.enable
Enable a resource quota.
Arguments
resource_quota_id(str): ID of the resource quota to enable.
Examples
- Python
import anyscale
anyscale.resource_quota.enable(
resource_quota_id="rq_123",
)
anyscale.resource_quota.disable
Disable a resource quota.
Arguments
resource_quota_id(str): ID of the resource quota to disable.
Examples
- Python
import anyscale
anyscale.resource_quota.disable(
resource_quota_id="rq_123",
)
Resource quotas models
CreateResourceQuota
Resource quota creation model.
Fields
name(str): Name of the resource quota to create.cloud(str): Name of the cloud that this resource quota applies to.project(str | None): Name of the project that this resource quota applies to (optional).user_email(str | None): Email of the user that this resource quota applies to (optional).num_cpus(int | None): The quota limit for the number of CPUs (optional).num_instances(int | None): The quota limit for the number of instances. (optional).num_gpus(int | None): The quota limit for the total number of GPUs (optional).num_accelerators(Dict[str, int] | None): The quota limit for the number of accelerators (optional).
Python Methods
def to_dict(self) -> Dict[str, Any]
"""Return a dictionary representation of the model."""
Examples
- Python
import anyscale
from anyscale.resource_quota.models import CreateResourceQuota
create_resource_quota = CreateResourceQuota(
# Name of the resource quota to create
name="resource_quota_name",
# Name of the cloud that this resource quota applies to
cloud="cloud_name",
# Name of the project that this resource quota applies to (optional)
project="project_name",
# Email of the user that this resource quota applies to (optional)
user_email="test@anyscale.com",
# The quota limit for the number of CPUs (optional)
num_cpus=50,
# The quota limit for the number of instances (optional)
num_instances=100,
# The quota limit for the total number of GPUs (optional)
num_gpus=30,
# The quota limit for the number of accelerators (optional)
num_accelerators={"A100-80G": 10, "T4": 20},
)
Quota
Resource quota limit
Fields
num_cpus(int | None): The quota limit for the number of CPUs (optional).num_instances(int | None): The quota limit for the number of instances. (optional).num_gpus(int | None): The quota limit for the total number of GPUs (optional).num_accelerators(Dict[str, int] | None): The quota limit for the number of accelerators (optional).
Python Methods
def to_dict(self) -> Dict[str, Any]
"""Return a dictionary representation of the model."""
Examples
- Python
import anyscale
from anyscale.resource_quota.models import CreateResourceQuota, ResourceQuota, Quota
create_resource_quota = CreateResourceQuota(
# Name of the resource quota to create
name="resource_quota_name",
# Name of the cloud that this resource quota applies to
cloud="cloud_name",
# Name of the project that this resource quota applies to (optional)
project="project_name",
# Email of the user that this resource quota applies to (optional)
user_email="test@anyscale.com",
# The quota limit for the number of CPUs (optional)
num_cpus=50,
# The quota limit for the number of instances (optional)
num_instances=100,
# The quota limit for the total number of GPUs (optional)
num_gpus=30,
# The quota limit for the number of accelerators (optional)
num_accelerators={"A100-80G": 10, "T4": 20},
)
resource_quota: ResourceQuota = anyscale.resource_quota.create(create_resource_quota)
quota: Quota = resource_quota.quota
ResourceQuota
Resource quota
Fields
id(str): The ID of the resource quota.name(str): Name of the resource quota.quota(Quota): The quota limit.created_at(datetime): The timestamp when this resource quota was created.cloud_id(str): ID of the cloud that this resource quota applies to.project_id(str | None): ID of the project that this resource quota applies to (optional).user_id(str | None): ID of the user that this resource quota applies to (optional).is_enabled(bool): Whether the resource quota is enabled.deleted_at(datetime | None): The timestamp when this resource quota was deleted.
Python Methods
def to_dict(self) -> Dict[str, Any]
"""Return a dictionary representation of the model."""
Examples
- Python
import anyscale
from anyscale.resource_quota.models import CreateResourceQuota, ResourceQuota
create_resource_quota = CreateResourceQuota(
# Name of the resource quota to create
name="resource_quota_name",
# Name of the cloud that this resource quota applies to
cloud="cloud_name",
# Name of the project that this resource quota applies to (optional)
project="project_name",
# Email of the user that this resource quota applies to (optional)
user_email="test@anyscale.com",
# The quota limit for the number of CPUs (optional)
num_cpus=50,
# The quota limit for the number of instances (optional)
num_instances=100,
# The quota limit for the total number of GPUs (optional)
num_gpus=30,
# The quota limit for the number of accelerators (optional)
num_accelerators={"A100-80G": 10, "T4": 20},
)
resource_quota: ResourceQuota = anyscale.resource_quota.create(create_resource_quota)