anyscale 0.24.87__py3-none-any.whl → 0.24.91__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- anyscale/__init__.py +56 -0
- anyscale/_private/anyscale_client/anyscale_client.py +158 -28
- anyscale/_private/anyscale_client/common.py +82 -0
- anyscale/_private/anyscale_client/fake_anyscale_client.py +193 -1
- anyscale/_private/docgen/README.md +1 -1
- anyscale/_private/docgen/__main__.py +74 -19
- anyscale/_private/docgen/api.md +0 -20
- anyscale/_private/docgen/generator.py +4 -2
- anyscale/_private/docgen/models.md +1 -46
- anyscale/_private/workload/workload_config.py +1 -1
- anyscale/aggregated_instance_usage/__init__.py +1 -1
- anyscale/aggregated_instance_usage/commands.py +2 -4
- anyscale/aggregated_instance_usage/models.py +8 -8
- anyscale/client/README.md +19 -23
- anyscale/client/openapi_client/__init__.py +13 -15
- anyscale/client/openapi_client/api/default_api.py +825 -962
- anyscale/client/openapi_client/models/__init__.py +13 -15
- anyscale/client/openapi_client/models/admin_create_user.py +255 -0
- anyscale/client/openapi_client/models/admin_created_user.py +281 -0
- anyscale/client/openapi_client/models/{sessionevent_list_response.py → admincreateduser_list_response.py} +15 -15
- anyscale/client/openapi_client/models/aggregated_usage_query.py +1 -29
- anyscale/client/openapi_client/models/{session_event_types.py → cloud_deployment_config.py} +35 -24
- anyscale/client/openapi_client/models/{platformfinetuningjob_response.py → clouddeploymentconfig_response.py} +11 -11
- anyscale/client/openapi_client/models/{company_size.py → cluster_size.py} +10 -10
- anyscale/client/openapi_client/models/cluster_status_details.py +2 -1
- anyscale/client/openapi_client/models/create_experimental_workspace.py +29 -1
- anyscale/client/openapi_client/models/{resubmit_ft_job_request.py → describe_machine_pool_request.py} +21 -20
- anyscale/client/openapi_client/models/describe_machine_pool_response.py +123 -0
- anyscale/client/openapi_client/models/{fine_tuning_job_status.py → describemachinepoolresponse_response.py} +34 -16
- anyscale/client/openapi_client/models/machine_allocation_state.py +3 -1
- anyscale/client/openapi_client/models/machine_state_info.py +326 -0
- anyscale/client/openapi_client/models/organization_marketing_questions.py +80 -54
- anyscale/client/openapi_client/models/request_state_info.py +210 -0
- anyscale/client/openapi_client/models/{platformfinetuningjob_list_response.py → scheduler_info.py} +43 -38
- anyscale/client/openapi_client/models/usage_by_cluster.py +28 -1
- anyscale/client/openapi_client/models/usage_by_user.py +30 -3
- anyscale/client/openapi_client/models/workload_info.py +210 -0
- anyscale/cloud/__init__.py +83 -0
- anyscale/cloud/_private/cloud_sdk.py +25 -0
- anyscale/cloud/commands.py +45 -0
- anyscale/cloud/models.py +91 -0
- anyscale/cluster_compute.py +1 -1
- anyscale/commands/aggregated_instance_usage_commands.py +4 -4
- anyscale/commands/cloud_commands.py +38 -2
- anyscale/commands/command_examples.py +67 -0
- anyscale/commands/job_commands.py +15 -3
- anyscale/commands/machine_pool_commands.py +113 -1
- anyscale/commands/organization_invitation_commands.py +98 -0
- anyscale/commands/project_commands.py +52 -2
- anyscale/commands/resource_quota_commands.py +98 -11
- anyscale/commands/service_commands.py +1 -1
- anyscale/commands/session_commands_hidden.py +5 -1
- anyscale/commands/user_commands.py +49 -0
- anyscale/commands/util.py +1 -1
- anyscale/commands/workspace_commands.py +1 -1
- anyscale/connect.py +1 -1
- anyscale/connect_utils/project.py +7 -4
- anyscale/controllers/cloud_controller.py +6 -6
- anyscale/controllers/cloud_functional_verification_controller.py +1 -1
- anyscale/controllers/cluster_controller.py +2 -2
- anyscale/controllers/compute_config_controller.py +1 -1
- anyscale/controllers/experimental_integrations_controller.py +1 -1
- anyscale/controllers/job_controller.py +8 -3
- anyscale/controllers/list_controller.py +2 -2
- anyscale/controllers/machine_pool_controller.py +12 -1
- anyscale/controllers/project_controller.py +4 -3
- anyscale/controllers/schedule_controller.py +1 -1
- anyscale/controllers/service_controller.py +1 -1
- anyscale/controllers/workspace_controller.py +1 -1
- anyscale/models/job_model.py +1 -1
- anyscale/organization_invitation/__init__.py +61 -0
- anyscale/organization_invitation/_private/organization_invitation_sdk.py +24 -0
- anyscale/organization_invitation/commands.py +84 -0
- anyscale/organization_invitation/models.py +45 -0
- anyscale/project/__init__.py +35 -0
- anyscale/project/_private/project_sdk.py +27 -0
- anyscale/project/commands.py +56 -0
- anyscale/project/models.py +91 -0
- anyscale/{project.py → project_utils.py} +3 -4
- anyscale/resource_quota/__init__.py +99 -0
- anyscale/resource_quota/_private/resource_quota_sdk.py +111 -0
- anyscale/resource_quota/commands.py +150 -0
- anyscale/resource_quota/models.py +303 -0
- anyscale/scripts.py +6 -0
- anyscale/sdk/anyscale_client/__init__.py +0 -5
- anyscale/sdk/anyscale_client/api/default_api.py +0 -150
- anyscale/sdk/anyscale_client/models/__init__.py +0 -5
- anyscale/sdk/anyscale_client/models/cluster_status_details.py +2 -1
- anyscale/sdk/anyscale_client/sdk.py +1 -1
- anyscale/user/__init__.py +35 -0
- anyscale/user/_private/user_sdk.py +32 -0
- anyscale/user/commands.py +42 -0
- anyscale/user/models.py +201 -0
- anyscale/util.py +15 -0
- anyscale/utils/cloud_utils.py +1 -1
- anyscale/version.py +1 -1
- anyscale/workspace_utils.py +1 -1
- {anyscale-0.24.87.dist-info → anyscale-0.24.91.dist-info}/METADATA +1 -5
- {anyscale-0.24.87.dist-info → anyscale-0.24.91.dist-info}/RECORD +105 -92
- anyscale/client/openapi_client/models/create_fine_tuning_hyperparameters.py +0 -156
- anyscale/client/openapi_client/models/create_fine_tuning_job_product_request.py +0 -353
- anyscale/client/openapi_client/models/finish_ft_job_request.py +0 -204
- anyscale/client/openapi_client/models/log_level_types.py +0 -100
- anyscale/client/openapi_client/models/paging_context.py +0 -172
- anyscale/client/openapi_client/models/platform_fine_tuning_job.py +0 -577
- anyscale/client/openapi_client/models/session_event.py +0 -267
- anyscale/client/openapi_client/models/session_event_cause.py +0 -150
- anyscale/controllers/resource_quota_controller.py +0 -183
- anyscale/sdk/anyscale_client/models/log_level_types.py +0 -100
- anyscale/sdk/anyscale_client/models/session_event.py +0 -267
- anyscale/sdk/anyscale_client/models/session_event_cause.py +0 -150
- anyscale/sdk/anyscale_client/models/session_event_types.py +0 -111
- anyscale/sdk/anyscale_client/models/sessionevent_list_response.py +0 -147
- anyscale/utils/imports/azure.py +0 -14
- /anyscale/{cloud.py → cloud_utils.py} +0 -0
- {anyscale-0.24.87.dist-info → anyscale-0.24.91.dist-info}/LICENSE +0 -0
- {anyscale-0.24.87.dist-info → anyscale-0.24.91.dist-info}/NOTICE +0 -0
- {anyscale-0.24.87.dist-info → anyscale-0.24.91.dist-info}/WHEEL +0 -0
- {anyscale-0.24.87.dist-info → anyscale-0.24.91.dist-info}/entry_points.txt +0 -0
- {anyscale-0.24.87.dist-info → anyscale-0.24.91.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
from dataclasses import dataclass, field
|
|
2
|
+
from typing import Any, Dict, List
|
|
3
|
+
|
|
4
|
+
from anyscale._private.models import ModelBase, ModelEnum
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class ProjectPermissionLevel(ModelEnum):
|
|
8
|
+
OWNER = "OWNER"
|
|
9
|
+
WRITE = "WRITE"
|
|
10
|
+
READONLY = "READONLY"
|
|
11
|
+
|
|
12
|
+
__docstrings__ = {
|
|
13
|
+
OWNER: "Owner permission level for the project",
|
|
14
|
+
WRITE: "Write permission level for the project",
|
|
15
|
+
READONLY: "Readonly permission level for the project",
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass(frozen=True)
|
|
20
|
+
class CreateProjectCollaborator(ModelBase):
|
|
21
|
+
"""User to be added as a collaborator to a project.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
__doc_py_example__ = """\
|
|
25
|
+
import anyscale
|
|
26
|
+
from anyscale.project.models import ProjectPermissionLevel, CreateProjectCollaborator
|
|
27
|
+
create_project_collaborator = CreateProjectCollaborator(
|
|
28
|
+
# Email of the user to be added as a collaborator
|
|
29
|
+
email="test@anyscale.com",
|
|
30
|
+
# Permission level for the user to the project (ProjectPermissionLevel.OWNER, ProjectPermissionLevel.WRITE, ProjectPermissionLevel.READONLY)
|
|
31
|
+
permission_level=ProjectPermissionLevel.READONLY,
|
|
32
|
+
)
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
def _validate_email(self, email: str):
|
|
36
|
+
if not isinstance(email, str):
|
|
37
|
+
raise TypeError("Email must be a string.")
|
|
38
|
+
|
|
39
|
+
email: str = field(
|
|
40
|
+
metadata={"docstring": "Email of the user to be added as a collaborator."},
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
def _validate_permission_level(
|
|
44
|
+
self, permission_level: ProjectPermissionLevel
|
|
45
|
+
) -> ProjectPermissionLevel:
|
|
46
|
+
if isinstance(permission_level, str):
|
|
47
|
+
return ProjectPermissionLevel.validate(permission_level)
|
|
48
|
+
elif isinstance(permission_level, ProjectPermissionLevel):
|
|
49
|
+
return permission_level
|
|
50
|
+
else:
|
|
51
|
+
raise TypeError(
|
|
52
|
+
f"'permission_level' must be a 'ProjectPermissionLevel' (it is {type(permission_level)})."
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
permission_level: ProjectPermissionLevel = field( # type: ignore
|
|
56
|
+
default=ProjectPermissionLevel.READONLY, # type: ignore
|
|
57
|
+
metadata={
|
|
58
|
+
"docstring": "Permission level the added user should have for the project" # type: ignore
|
|
59
|
+
f"(one of: {','.join([str(m.value) for m in ProjectPermissionLevel])}", # type: ignore
|
|
60
|
+
},
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@dataclass(frozen=True)
|
|
65
|
+
class CreateProjectCollaborators(ModelBase):
|
|
66
|
+
"""List of users to be added as collaborators to a project.
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
__doc_py_example__ = """\
|
|
70
|
+
import anyscale
|
|
71
|
+
from anyscale.project.models import ProjectPermissionLevel, CreateProjectCollaborator, CreateProjectCollaborators
|
|
72
|
+
create_project_collaborator = CreateProjectCollaborator(
|
|
73
|
+
# Email of the user to be added as a collaborator
|
|
74
|
+
email="test@anyscale.com",
|
|
75
|
+
# Permission level for the user to the project (ProjectPermissionLevel.OWNER, ProjectPermissionLevel.WRITE, ProjectPermissionLevel.READONLY)
|
|
76
|
+
permission_level=ProjectPermissionLevel.READONLY,
|
|
77
|
+
)
|
|
78
|
+
create_project_collaborators = CreateProjectCollaborators(
|
|
79
|
+
collaborators=[create_project_collaborator]
|
|
80
|
+
)
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
collaborators: List[Dict[str, Any]] = field(
|
|
84
|
+
metadata={
|
|
85
|
+
"docstring": "List of users to be added as collaborators to a project."
|
|
86
|
+
},
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
def _validate_collaborators(self, collaborators: List[Dict[str, Any]]):
|
|
90
|
+
if not isinstance(collaborators, list):
|
|
91
|
+
raise TypeError("Collaborators must be a list.")
|
|
@@ -5,12 +5,11 @@ import click
|
|
|
5
5
|
from click import ClickException
|
|
6
6
|
import yaml
|
|
7
7
|
|
|
8
|
-
import anyscale
|
|
9
8
|
from anyscale.authenticate import get_auth_api_client
|
|
10
9
|
from anyscale.cli_logger import BlockLogger
|
|
11
10
|
from anyscale.client.openapi_client import Project
|
|
12
11
|
from anyscale.client.openapi_client.api.default_api import DefaultApi
|
|
13
|
-
from anyscale.
|
|
12
|
+
from anyscale.cloud_utils import get_cloud_id_and_name
|
|
14
13
|
from anyscale.cluster_compute import (
|
|
15
14
|
get_cluster_compute_from_name,
|
|
16
15
|
get_selected_cloud_id_or_default,
|
|
@@ -301,13 +300,13 @@ def create_new_proj_def(
|
|
|
301
300
|
name = slugify(name)
|
|
302
301
|
log.info(f"Normalized project name to {name}")
|
|
303
302
|
|
|
304
|
-
project_definition =
|
|
303
|
+
project_definition = ProjectDefinition(os.getcwd())
|
|
305
304
|
project_definition.config["name"] = name
|
|
306
305
|
return name, project_definition
|
|
307
306
|
|
|
308
307
|
|
|
309
308
|
def _do_attach(project_id: str, is_create_project: bool) -> None:
|
|
310
|
-
with open(
|
|
309
|
+
with open(ANYSCALE_PROJECT_FILE, "w") as f:
|
|
311
310
|
yaml.dump(
|
|
312
311
|
{"project_id": project_id}, f,
|
|
313
312
|
)
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
from typing import List, Optional
|
|
2
|
+
|
|
3
|
+
from anyscale._private.anyscale_client import AnyscaleClientInterface
|
|
4
|
+
from anyscale._private.sdk import sdk_docs
|
|
5
|
+
from anyscale._private.sdk.base_sdk import Timer
|
|
6
|
+
from anyscale.cli_logger import BlockLogger
|
|
7
|
+
from anyscale.resource_quota._private.resource_quota_sdk import PrivateResourceQuotaSDK
|
|
8
|
+
from anyscale.resource_quota.commands import (
|
|
9
|
+
_CREATE_DOCSTRINGS,
|
|
10
|
+
_CREATE_EXAMPLE,
|
|
11
|
+
_DELETE_DOCSTRINGS,
|
|
12
|
+
_DELETE_EXAMPLE,
|
|
13
|
+
_DISABLE_DOCSTRINGS,
|
|
14
|
+
_DISABLE_EXAMPLE,
|
|
15
|
+
_ENABLE_DOCSTRINGS,
|
|
16
|
+
_ENABLE_EXAMPLE,
|
|
17
|
+
_LIST_DOCSTRINGS,
|
|
18
|
+
_LIST_EXAMPLE,
|
|
19
|
+
create,
|
|
20
|
+
delete,
|
|
21
|
+
disable,
|
|
22
|
+
enable,
|
|
23
|
+
list,
|
|
24
|
+
)
|
|
25
|
+
from anyscale.resource_quota.models import CreateResourceQuota, ResourceQuota
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ResourceQuotaSDK:
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
*,
|
|
32
|
+
client: Optional[AnyscaleClientInterface] = None,
|
|
33
|
+
logger: Optional[BlockLogger] = None,
|
|
34
|
+
timer: Optional[Timer] = None,
|
|
35
|
+
):
|
|
36
|
+
self._private_sdk = PrivateResourceQuotaSDK(
|
|
37
|
+
client=client, logger=logger, timer=timer
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
@sdk_docs(
|
|
41
|
+
doc_py_example=_CREATE_EXAMPLE, arg_docstrings=_CREATE_DOCSTRINGS,
|
|
42
|
+
)
|
|
43
|
+
def create( # noqa: F811
|
|
44
|
+
self, create_resource_quota: CreateResourceQuota,
|
|
45
|
+
) -> ResourceQuota:
|
|
46
|
+
"""Create a resource quota.
|
|
47
|
+
"""
|
|
48
|
+
return self._private_sdk.create(create_resource_quota)
|
|
49
|
+
|
|
50
|
+
@sdk_docs(
|
|
51
|
+
doc_py_example=_LIST_EXAMPLE, arg_docstrings=_LIST_DOCSTRINGS,
|
|
52
|
+
)
|
|
53
|
+
def list( # noqa: F811
|
|
54
|
+
self,
|
|
55
|
+
name: Optional[str] = None,
|
|
56
|
+
cloud: Optional[str] = None,
|
|
57
|
+
creator_id: Optional[str] = None,
|
|
58
|
+
is_enabled: Optional[bool] = None,
|
|
59
|
+
max_items: int = 20,
|
|
60
|
+
) -> List[ResourceQuota]:
|
|
61
|
+
"""List resource quotas.
|
|
62
|
+
"""
|
|
63
|
+
return self._private_sdk.list(
|
|
64
|
+
name=name,
|
|
65
|
+
cloud=cloud,
|
|
66
|
+
creator_id=creator_id,
|
|
67
|
+
is_enabled=is_enabled,
|
|
68
|
+
max_items=max_items,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
@sdk_docs(
|
|
72
|
+
doc_py_example=_DELETE_EXAMPLE, arg_docstrings=_DELETE_DOCSTRINGS,
|
|
73
|
+
)
|
|
74
|
+
def delete( # noqa: F811
|
|
75
|
+
self, resource_quota_id: str,
|
|
76
|
+
):
|
|
77
|
+
"""Delete a resource quota.
|
|
78
|
+
"""
|
|
79
|
+
return self._private_sdk.delete(resource_quota_id)
|
|
80
|
+
|
|
81
|
+
@sdk_docs(
|
|
82
|
+
doc_py_example=_ENABLE_EXAMPLE, arg_docstrings=_ENABLE_DOCSTRINGS,
|
|
83
|
+
)
|
|
84
|
+
def enable( # noqa: F811
|
|
85
|
+
self, resource_quota_id: str,
|
|
86
|
+
):
|
|
87
|
+
"""Enable a resource quota.
|
|
88
|
+
"""
|
|
89
|
+
return self._private_sdk.set_status(resource_quota_id, True)
|
|
90
|
+
|
|
91
|
+
@sdk_docs(
|
|
92
|
+
doc_py_example=_DISABLE_EXAMPLE, arg_docstrings=_DISABLE_DOCSTRINGS,
|
|
93
|
+
)
|
|
94
|
+
def disable( # noqa: F811
|
|
95
|
+
self, resource_quota_id: str,
|
|
96
|
+
):
|
|
97
|
+
"""Disable a resource quota.
|
|
98
|
+
"""
|
|
99
|
+
return self._private_sdk.set_status(resource_quota_id, False)
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
from typing import List, Optional
|
|
2
|
+
|
|
3
|
+
from anyscale._private.sdk.base_sdk import BaseSDK
|
|
4
|
+
from anyscale.client.openapi_client.models.create_resource_quota import (
|
|
5
|
+
CreateResourceQuota as CreateResourceQuotaModel,
|
|
6
|
+
)
|
|
7
|
+
from anyscale.client.openapi_client.models.quota import Quota as QuotaModel
|
|
8
|
+
from anyscale.resource_quota.models import CreateResourceQuota, Quota, ResourceQuota
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class PrivateResourceQuotaSDK(BaseSDK):
|
|
12
|
+
def create(self, create_resource_quota: CreateResourceQuota) -> ResourceQuota:
|
|
13
|
+
cloud_id = self.client.get_cloud_id(
|
|
14
|
+
cloud_name=create_resource_quota.cloud, compute_config_id=None
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
project_id = (
|
|
18
|
+
self.client.get_project_id(
|
|
19
|
+
parent_cloud_id=cloud_id, name=create_resource_quota.project
|
|
20
|
+
)
|
|
21
|
+
if create_resource_quota.project
|
|
22
|
+
else None
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
user_id = (
|
|
26
|
+
self.client.get_organization_collaborator(
|
|
27
|
+
email=create_resource_quota.user_email
|
|
28
|
+
).user_id
|
|
29
|
+
if create_resource_quota.user_email
|
|
30
|
+
else None
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
create_resource_quota_model = CreateResourceQuotaModel(
|
|
34
|
+
name=create_resource_quota.name,
|
|
35
|
+
cloud_id=cloud_id,
|
|
36
|
+
project_id=project_id,
|
|
37
|
+
user_id=user_id,
|
|
38
|
+
quota=QuotaModel(
|
|
39
|
+
num_cpus=create_resource_quota.num_cpus,
|
|
40
|
+
num_instances=create_resource_quota.num_instances,
|
|
41
|
+
num_gpus=create_resource_quota.num_gpus,
|
|
42
|
+
num_accelerators=create_resource_quota.num_accelerators,
|
|
43
|
+
),
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
resource_quota = self.client.create_resource_quota(
|
|
47
|
+
create_resource_quota=create_resource_quota_model
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
return ResourceQuota(
|
|
51
|
+
id=resource_quota.id,
|
|
52
|
+
name=resource_quota.name,
|
|
53
|
+
cloud_id=resource_quota.cloud_id,
|
|
54
|
+
project_id=resource_quota.project_id,
|
|
55
|
+
user_id=resource_quota.user_id,
|
|
56
|
+
is_enabled=resource_quota.is_enabled,
|
|
57
|
+
created_at=resource_quota.created_at,
|
|
58
|
+
deleted_at=resource_quota.deleted_at,
|
|
59
|
+
quota=Quota(
|
|
60
|
+
num_cpus=resource_quota.quota.num_cpus,
|
|
61
|
+
num_instances=resource_quota.quota.num_instances,
|
|
62
|
+
num_gpus=resource_quota.quota.num_gpus,
|
|
63
|
+
num_accelerators=resource_quota.quota.num_accelerators,
|
|
64
|
+
),
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
def list(
|
|
68
|
+
self,
|
|
69
|
+
name: Optional[str] = None,
|
|
70
|
+
cloud: Optional[str] = None,
|
|
71
|
+
creator_id: Optional[str] = None,
|
|
72
|
+
is_enabled: Optional[bool] = None,
|
|
73
|
+
max_items: int = 20,
|
|
74
|
+
) -> List[ResourceQuota]:
|
|
75
|
+
cloud_id = (
|
|
76
|
+
self.client.get_cloud_id(cloud_name=cloud, compute_config_id=None)
|
|
77
|
+
if cloud
|
|
78
|
+
else None
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
resource_quotas = self.client.list_resource_quotas(
|
|
82
|
+
name, cloud_id, creator_id, is_enabled, max_items,
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
return [
|
|
86
|
+
ResourceQuota(
|
|
87
|
+
id=resource_quota.id,
|
|
88
|
+
name=resource_quota.name,
|
|
89
|
+
cloud_id=resource_quota.cloud_id,
|
|
90
|
+
project_id=resource_quota.project_id,
|
|
91
|
+
user_id=resource_quota.user_id,
|
|
92
|
+
is_enabled=resource_quota.is_enabled,
|
|
93
|
+
created_at=resource_quota.created_at,
|
|
94
|
+
deleted_at=resource_quota.deleted_at,
|
|
95
|
+
quota=Quota(
|
|
96
|
+
num_cpus=resource_quota.quota.num_cpus,
|
|
97
|
+
num_instances=resource_quota.quota.num_instances,
|
|
98
|
+
num_gpus=resource_quota.quota.num_gpus,
|
|
99
|
+
num_accelerators=resource_quota.quota.num_accelerators,
|
|
100
|
+
),
|
|
101
|
+
)
|
|
102
|
+
for resource_quota in resource_quotas
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
def delete(self, resource_quota_id: str) -> None:
|
|
106
|
+
self.client.delete_resource_quota(resource_quota_id=resource_quota_id)
|
|
107
|
+
|
|
108
|
+
def set_status(self, resource_quota_id: str, is_enabled: bool) -> None:
|
|
109
|
+
self.client.set_resource_quota_status(
|
|
110
|
+
resource_quota_id=resource_quota_id, is_enabled=is_enabled
|
|
111
|
+
)
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
from typing import List, Optional
|
|
2
|
+
|
|
3
|
+
from anyscale._private.sdk import sdk_command
|
|
4
|
+
from anyscale.resource_quota._private.resource_quota_sdk import PrivateResourceQuotaSDK
|
|
5
|
+
from anyscale.resource_quota.models import CreateResourceQuota, ResourceQuota
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
_RESOURCE_QUOTA_SDK_SINGLETON_KEY = "resource_quota_sdk"
|
|
9
|
+
|
|
10
|
+
_CREATE_EXAMPLE = """
|
|
11
|
+
import anyscale
|
|
12
|
+
from anyscale.resource_quota.models import CreateResourceQuota
|
|
13
|
+
|
|
14
|
+
anyscale.resource_quota.create(
|
|
15
|
+
ResourceQuota(
|
|
16
|
+
name="my-resource-quota",
|
|
17
|
+
cloud="my-cloud",
|
|
18
|
+
project="my-project",
|
|
19
|
+
num_cpus=2,
|
|
20
|
+
),
|
|
21
|
+
)
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
_CREATE_DOCSTRINGS = {"create_resource_quota": "The resource quota to be created."}
|
|
25
|
+
|
|
26
|
+
_LIST_EXAMPLE = """
|
|
27
|
+
import anyscale
|
|
28
|
+
from anyscale.resource_quota.models import CreateResourceQuota
|
|
29
|
+
|
|
30
|
+
anyscale.resource_quota.list(
|
|
31
|
+
name="my-resource-quota",
|
|
32
|
+
cloud="my-cloud",
|
|
33
|
+
creator_id="usr_123",
|
|
34
|
+
is_enabled=True,
|
|
35
|
+
max_items=20,
|
|
36
|
+
)
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
_LIST_DOCSTRINGS = {
|
|
40
|
+
"name": "Name of the resource quota.",
|
|
41
|
+
"cloud": "Name of the cloud that this resource quota applies to.",
|
|
42
|
+
"creator_id": "ID of the creator of the resource quota.",
|
|
43
|
+
"is_enabled": "Whether the resource quota is enabled.",
|
|
44
|
+
"max_items": "Maximum number of items to return.",
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
_DELETE_EXAMPLE = """
|
|
48
|
+
import anyscale
|
|
49
|
+
|
|
50
|
+
anyscale.resource_quota.delete(
|
|
51
|
+
resource_quota_id="rq_123",
|
|
52
|
+
)
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
_DELETE_DOCSTRINGS = {
|
|
56
|
+
"resource_quota_id": "ID of the resource quota to delete.",
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_ENABLE_EXAMPLE = """
|
|
60
|
+
import anyscale
|
|
61
|
+
|
|
62
|
+
anyscale.resource_quota.enable(
|
|
63
|
+
resource_quota_id="rq_123",
|
|
64
|
+
)
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
_ENABLE_DOCSTRINGS = {
|
|
68
|
+
"resource_quota_id": "ID of the resource quota to enable.",
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
_DISABLE_EXAMPLE = """
|
|
72
|
+
import anyscale
|
|
73
|
+
|
|
74
|
+
anyscale.resource_quota.disable(
|
|
75
|
+
resource_quota_id="rq_123",
|
|
76
|
+
)
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
_DISABLE_DOCSTRINGS = {
|
|
80
|
+
"resource_quota_id": "ID of the resource quota to disable.",
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@sdk_command(
|
|
85
|
+
_RESOURCE_QUOTA_SDK_SINGLETON_KEY,
|
|
86
|
+
PrivateResourceQuotaSDK,
|
|
87
|
+
doc_py_example=_CREATE_EXAMPLE,
|
|
88
|
+
arg_docstrings=_CREATE_DOCSTRINGS,
|
|
89
|
+
)
|
|
90
|
+
def create(
|
|
91
|
+
create_resource_quota: CreateResourceQuota, *, _sdk: PrivateResourceQuotaSDK
|
|
92
|
+
) -> ResourceQuota:
|
|
93
|
+
"""Create a resource quota.
|
|
94
|
+
"""
|
|
95
|
+
return _sdk.create(create_resource_quota)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
@sdk_command(
|
|
99
|
+
_RESOURCE_QUOTA_SDK_SINGLETON_KEY,
|
|
100
|
+
PrivateResourceQuotaSDK,
|
|
101
|
+
doc_py_example=_LIST_EXAMPLE,
|
|
102
|
+
arg_docstrings=_LIST_DOCSTRINGS,
|
|
103
|
+
)
|
|
104
|
+
def list( # noqa: A001
|
|
105
|
+
name: Optional[str] = None,
|
|
106
|
+
cloud: Optional[str] = None,
|
|
107
|
+
creator_id: Optional[str] = None,
|
|
108
|
+
is_enabled: Optional[bool] = None,
|
|
109
|
+
max_items: int = 20,
|
|
110
|
+
*,
|
|
111
|
+
_sdk: PrivateResourceQuotaSDK
|
|
112
|
+
) -> List[ResourceQuota]:
|
|
113
|
+
"""List resource quotas. """
|
|
114
|
+
return _sdk.list(name, cloud, creator_id, is_enabled, max_items,)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
@sdk_command(
|
|
118
|
+
_RESOURCE_QUOTA_SDK_SINGLETON_KEY,
|
|
119
|
+
PrivateResourceQuotaSDK,
|
|
120
|
+
doc_py_example=_DELETE_EXAMPLE,
|
|
121
|
+
arg_docstrings=_DELETE_DOCSTRINGS,
|
|
122
|
+
)
|
|
123
|
+
def delete(resource_quota_id: str, *, _sdk: PrivateResourceQuotaSDK):
|
|
124
|
+
"""Delete a resource quota.
|
|
125
|
+
"""
|
|
126
|
+
return _sdk.delete(resource_quota_id)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
@sdk_command(
|
|
130
|
+
_RESOURCE_QUOTA_SDK_SINGLETON_KEY,
|
|
131
|
+
PrivateResourceQuotaSDK,
|
|
132
|
+
doc_py_example=_ENABLE_EXAMPLE,
|
|
133
|
+
arg_docstrings=_ENABLE_DOCSTRINGS,
|
|
134
|
+
)
|
|
135
|
+
def enable(resource_quota_id: str, *, _sdk: PrivateResourceQuotaSDK):
|
|
136
|
+
"""Enable a resource quota.
|
|
137
|
+
"""
|
|
138
|
+
return _sdk.set_status(resource_quota_id, True)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
@sdk_command(
|
|
142
|
+
_RESOURCE_QUOTA_SDK_SINGLETON_KEY,
|
|
143
|
+
PrivateResourceQuotaSDK,
|
|
144
|
+
doc_py_example=_DISABLE_EXAMPLE,
|
|
145
|
+
arg_docstrings=_DISABLE_DOCSTRINGS,
|
|
146
|
+
)
|
|
147
|
+
def disable(resource_quota_id: str, *, _sdk: PrivateResourceQuotaSDK):
|
|
148
|
+
"""Disable a resource quota.
|
|
149
|
+
"""
|
|
150
|
+
return _sdk.set_status(resource_quota_id, False)
|