Project SDK reference
Project SDK reference
Customer-hosted cloud features
note
Some features are only available on customer-hosted clouds. Reach out to support@anyscale.com for info.
Project SDK
anyscale.project.get
Get details of a project.
Arguments
project_id(str): The ID of the project to get details of.
Returns: Project
Examples
- Python
import anyscale
from anyscale.project.models import Project
project: Project = anyscale.project.get(project_id="my-project-id")
anyscale.project.list
List projects.
Arguments
name_contains(str | None) = None: A string to filter projects by name.creator_id(str | None) = None: The ID of a creator to filter projects.parent_cloud_id(str | None) = None: The ID of a parent cloud to filter projects.include_defaults(bool) = True: Whether to include default projects.max_items(int | None) = None: The maximum number of projects to return.page_size(int | None) = None: The number of projects to return per page.sort_field(ProjectSortField | None) = None: The field to sort projects by.sort_order(ProjectSortOrder | None) = None: The order to sort projects by.
Returns: ResultIterator[Project]
Examples
- Python
from typing import Iterator
import anyscale
from anyscale.project.models import Project, ProjectSortField, ProjectSortOrder
projects: Iterator[Project] = anyscale.project.list(
name_contains="my-project",
creator_id="my-user-id",
parent_cloud_id="my-cloud-id",
include_defaults=True,
max_items=20,
page_size=10,
sort_field=ProjectSortField.NAME,
sort_order=ProjectSortOrder.ASC,
)
for project in projects:
print(project.name)
anyscale.project.create
Create a project.
Arguments
name(str): The name of the project.parent_cloud_id(str): The parent cloud that the project belongs to.description(str | None) = None: The description of the project.initial_cluster_config(str | None) = None: A YAML string containing the initial cluster config for the project.
Returns: str
Examples
- Python
import anyscale
project_id: str = anyscale.project.create(
name="my-project",
parent_cloud_id="my-cloud-id",
description="my-project-description",
)
anyscale.project.delete
Delete a project.
Arguments
project_id(str): The ID of the project to delete.
Examples
- Python
import anyscale
anyscale.project.delete(project_id="my-project-id")
anyscale.project.get_default
Get the default project for a cloud.
Arguments
parent_cloud_id(str): The ID of the parent cloud to get the default project for.
Returns: Project
Examples
- Python
import anyscale
from anyscale.project.models import Project
project: Project = anyscale.project.get_default(parent_cloud_id="my-cloud-id")
anyscale.project.add_collaborators
Batch add collaborators to a project.
Arguments
cloud(str): The cloud that the project belongs to.project(str): The project to add users to.collaborators(List[CreateProjectCollaborator]): The list of collaborators to add to the project.
Returns: str
Examples
- Python
import anyscale
from anyscale.project.models import CreateProjectCollaborator, ProjectPermissionLevel
anyscale.project.add_collaborators(
cloud="cloud_name",
project="project_name",
collaborators=[
CreateProjectCollaborator(
email="test1@anyscale.com",
permission_level=ProjectPermissionLevel.OWNER,
),
CreateProjectCollaborator(
email="test2@anyscale.com",
permission_level=ProjectPermissionLevel.WRITE,
),
CreateProjectCollaborator(
email="test3@anyscale.com",
permission_level=ProjectPermissionLevel.READONLY,
),
],
)
Project models
Project
Project object.
Fields
id(str): ID of the project.name(str): Name of the project.description(str): Description of the project.created_at(str): Datetime of the project creation.creator_id(str | None): ID of the creator of the project.parent_cloud_id(str | None): ID of the parent cloud.is_owner(bool): Whether the user is the owner of the project.is_read_only(bool): Whether the user has read-only access to the project.directory_name(str): Directory name of project to be used as working directory of clusters.is_default(bool): Whether the project is the default project for the organization.initial_cluster_config(str | Dict[str, Any] | None): Initial cluster config associated with the project.last_used_cloud_id(str | None): ID of the last cloud used in this project, or by the user if this is a new project.owners(List[str]): List of IDs of users who have owner access to the project.
Python Methods
def to_dict(self) -> Dict[str, Any]
"""Return a dictionary representation of the model."""
Examples
- Python
import anyscale
from anyscale.project.models import Project
project: Project = anyscale.project.get(project_id="my-project-id")
ProjectSortField
Field to sort projects by.
Values
NAME: Sort by project name.
ProjectSortOrder
Direction of sorting.
Values
ASC: Sort in ascending order.DESC: Sort in descending order.
CreateProjectCollaborator
User to be added as a collaborator to a project.
Fields
email(str): Email of the user to be added as a collaborator.permission_level(ProjectPermissionLevel): Permission level the added user should have for the project (one of: OWNER,WRITE,READONLY).
Python Methods
def to_dict(self) -> Dict[str, Any]
"""Return a dictionary representation of the model."""
Examples
- Python
import anyscale
from anyscale.project.models import ProjectPermissionLevel, CreateProjectCollaborator
create_project_collaborator = CreateProjectCollaborator(
# Email of the user to be added as a collaborator
email="test@anyscale.com",
# Permission level for the user to the project (ProjectPermissionLevel.OWNER, ProjectPermissionLevel.WRITE, ProjectPermissionLevel.READONLY)
permission_level=ProjectPermissionLevel.READONLY,
)
ProjectPermissionLevel
Permission levels for project collaborators.
Values
OWNER: Owner permission level for the projectWRITE: Write permission level for the projectREADONLY: Readonly permission level for the project