anyscale 0.26.47__py3-none-any.whl → 0.26.49__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 +0 -7
- anyscale/_private/anyscale_client/README.md +115 -0
- anyscale/_private/anyscale_client/anyscale_client.py +12 -213
- anyscale/_private/anyscale_client/common.py +0 -55
- anyscale/_private/anyscale_client/fake_anyscale_client.py +19 -46
- anyscale/_private/docgen/__main__.py +32 -47
- anyscale/_private/docgen/generator.py +32 -16
- anyscale/_private/docgen/generator_legacy.py +58 -6
- anyscale/_private/docgen/models.md +3 -2
- anyscale/_private/workload/workload_config.py +16 -8
- anyscale/_private/workload/workload_sdk.py +24 -7
- anyscale/client/README.md +10 -2
- anyscale/client/openapi_client/__init__.py +6 -2
- anyscale/client/openapi_client/api/default_api.py +558 -8
- anyscale/client/openapi_client/models/__init__.py +6 -2
- anyscale/client/openapi_client/models/{alert_type.py → alert_issue_type.py} +8 -20
- anyscale/client/openapi_client/models/baseimagesenum.py +1 -2
- anyscale/client/openapi_client/models/cloud.py +31 -3
- anyscale/client/openapi_client/models/cloud_deployment.py +30 -3
- anyscale/client/openapi_client/models/cloud_with_cloud_resource.py +29 -1
- anyscale/client/openapi_client/models/cloud_with_cloud_resource_gcp.py +29 -1
- anyscale/client/openapi_client/models/dataset_metrics.py +6 -6
- anyscale/client/openapi_client/models/dataset_state.py +2 -1
- anyscale/client/openapi_client/models/decorated_cloud_deployment.py +481 -0
- anyscale/client/openapi_client/models/decoratedclouddeployment_response.py +121 -0
- anyscale/client/openapi_client/models/describe_system_workload_response.py +32 -6
- anyscale/client/openapi_client/models/experimental_workspace.py +29 -1
- anyscale/client/openapi_client/models/experimental_workspaces_sort_field.py +2 -1
- anyscale/client/openapi_client/models/metrics_query_response.py +121 -0
- anyscale/client/openapi_client/models/{clouddeployment_response.py → metricsqueryresponse_response.py} +11 -11
- anyscale/client/openapi_client/models/operator_metrics.py +8 -9
- anyscale/client/openapi_client/models/operator_status.py +102 -0
- anyscale/client/openapi_client/models/organization_usage_alert.py +20 -20
- anyscale/client/openapi_client/models/supportedbaseimagesenum.py +1 -2
- anyscale/cloud/models.py +330 -0
- anyscale/commands/cloud_commands.py +136 -44
- anyscale/commands/command_examples.py +54 -134
- anyscale/commands/compute_config_commands.py +7 -11
- anyscale/compute_config/__init__.py +2 -16
- anyscale/compute_config/_private/compute_config_sdk.py +27 -17
- anyscale/compute_config/commands.py +14 -44
- anyscale/compute_config/models.py +49 -26
- anyscale/controllers/cloud_controller.py +289 -171
- anyscale/controllers/cloud_file_storage_utils.py +204 -0
- anyscale/controllers/kubernetes_verifier.py +1570 -0
- anyscale/job/_private/job_sdk.py +17 -8
- anyscale/job/models.py +1 -1
- anyscale/scripts.py +0 -2
- anyscale/sdk/anyscale_client/models/baseimagesenum.py +1 -2
- anyscale/sdk/anyscale_client/models/cloud.py +31 -3
- anyscale/sdk/anyscale_client/models/supportedbaseimagesenum.py +1 -2
- anyscale/shared_anyscale_utils/headers.py +3 -0
- anyscale/shared_anyscale_utils/utils/id_gen.py +1 -0
- anyscale/version.py +1 -1
- anyscale/workspace/models.py +14 -7
- {anyscale-0.26.47.dist-info → anyscale-0.26.49.dist-info}/METADATA +1 -1
- {anyscale-0.26.47.dist-info → anyscale-0.26.49.dist-info}/RECORD +62 -73
- anyscale/commands/llm/dataset_commands.py +0 -269
- anyscale/commands/llm/group.py +0 -15
- anyscale/commands/llm/models_commands.py +0 -123
- anyscale/controllers/llm/__init__.py +0 -0
- anyscale/controllers/llm/models_controller.py +0 -144
- anyscale/llm/__init__.py +0 -2
- anyscale/llm/dataset/__init__.py +0 -2
- anyscale/llm/dataset/_private/__init__.py +0 -0
- anyscale/llm/dataset/_private/docs.py +0 -63
- anyscale/llm/dataset/_private/models.py +0 -71
- anyscale/llm/dataset/_private/sdk.py +0 -147
- anyscale/llm/model/__init__.py +0 -2
- anyscale/llm/model/_private/models_sdk.py +0 -62
- anyscale/llm/model/commands.py +0 -93
- anyscale/llm/model/models.py +0 -171
- anyscale/llm/model/sdk.py +0 -62
- anyscale/llm/sdk.py +0 -27
- {anyscale-0.26.47.dist-info → anyscale-0.26.49.dist-info}/WHEEL +0 -0
- {anyscale-0.26.47.dist-info → anyscale-0.26.49.dist-info}/entry_points.txt +0 -0
- {anyscale-0.26.47.dist-info → anyscale-0.26.49.dist-info}/licenses/LICENSE +0 -0
- {anyscale-0.26.47.dist-info → anyscale-0.26.49.dist-info}/licenses/NOTICE +0 -0
- {anyscale-0.26.47.dist-info → anyscale-0.26.49.dist-info}/top_level.txt +0 -0
@@ -1,147 +0,0 @@
|
|
1
|
-
from typing import Optional
|
2
|
-
|
3
|
-
from anyscale._private.models.model_base import ListResponse
|
4
|
-
from anyscale._private.sdk import sdk_command_v2
|
5
|
-
from anyscale._private.sdk.base_sdk import BaseSDK
|
6
|
-
from anyscale.llm.dataset._private import docs
|
7
|
-
from anyscale.llm.dataset._private.models import Dataset
|
8
|
-
|
9
|
-
|
10
|
-
@sdk_command_v2(
|
11
|
-
doc_py_example=docs.GET_PY_EXAMPLE, arg_docstrings=docs.GET_PY_ARG_DOCSTRINGS,
|
12
|
-
)
|
13
|
-
def get(
|
14
|
-
name: str, version: Optional[int] = None, project: Optional[str] = None
|
15
|
-
) -> Dataset:
|
16
|
-
"""Retrieves metadata about a dataset.
|
17
|
-
|
18
|
-
:param name: Name of the dataset.
|
19
|
-
:param version: Version of the dataset. If a negative integer is provided, the dataset returned is this many versions back of the latest version. Default: Latest version.
|
20
|
-
:param project: Name of the Anyscale project that the dataset belongs to. If not provided, all projects will be searched.
|
21
|
-
|
22
|
-
Example usage:
|
23
|
-
```python
|
24
|
-
dataset = anyscale.llm.dataset.get("my_first_dataset")
|
25
|
-
print(f"Dataset name: '{dataset.name}'") # Dataset name: 'my_first_dataset'
|
26
|
-
|
27
|
-
# Get the second latest version of the dataset
|
28
|
-
prev_dataset = anyscale.llm.dataset.get("my_first_dataset", version=-1)
|
29
|
-
```
|
30
|
-
|
31
|
-
Return:
|
32
|
-
Dataset: The `Dataset` object.
|
33
|
-
"""
|
34
|
-
_sdk = BaseSDK()
|
35
|
-
dataset = _sdk.client.get_dataset(name, version, project)
|
36
|
-
return dataset
|
37
|
-
|
38
|
-
|
39
|
-
@sdk_command_v2(
|
40
|
-
doc_py_example=docs.UPLOAD_PY_EXAMPLE, arg_docstrings=docs.UPLOAD_PY_ARG_DOCSTRINGS,
|
41
|
-
)
|
42
|
-
def upload(
|
43
|
-
dataset_file: str,
|
44
|
-
name: str,
|
45
|
-
*,
|
46
|
-
description: Optional[str] = None,
|
47
|
-
cloud: Optional[str] = None,
|
48
|
-
project: Optional[str] = None,
|
49
|
-
) -> Dataset:
|
50
|
-
"""Uploads a dataset, or a new version of a dataset, to your Anyscale cloud.
|
51
|
-
|
52
|
-
:param dataset_file: Path to the dataset file to upload.
|
53
|
-
:param name: Name of a new dataset, or an existing dataset, to upload a new version of.
|
54
|
-
:param description: Description of the dataset version.
|
55
|
-
:param cloud: Name of the Anyscale cloud to upload a new dataset to. If not provided, the default cloud will be used.
|
56
|
-
:param project: Name of the Anyscale project to upload a new dataset to. If not provided, the default project of the cloud will be used.
|
57
|
-
|
58
|
-
Example usage:
|
59
|
-
```python
|
60
|
-
anyscale.llm.dataset.upload("path/to/my_first_dataset.jsonl", name="my_first_dataset")
|
61
|
-
anyscale.llm.dataset.upload("my_dataset.jsonl", "second_dataset")
|
62
|
-
anyscale.llm.dataset.upload("my_dataset2.jsonl", "second_dataset", description="added 3 lines")
|
63
|
-
```
|
64
|
-
Return:
|
65
|
-
Dataset: The `Dataset` object representing the uploaded dataset.
|
66
|
-
|
67
|
-
NOTE:
|
68
|
-
If you are uploading a new version, have run this from within an Anyscale workspace,
|
69
|
-
and neither `cloud` nor `project` are provided, the cloud and project of the workspace will be used.
|
70
|
-
"""
|
71
|
-
_sdk = BaseSDK()
|
72
|
-
dataset = _sdk.client.upload_dataset(
|
73
|
-
dataset_file, name, description, cloud, project,
|
74
|
-
)
|
75
|
-
return dataset
|
76
|
-
|
77
|
-
|
78
|
-
@sdk_command_v2(
|
79
|
-
doc_py_example=docs.DOWNLOAD_PY_EXAMPLE,
|
80
|
-
arg_docstrings=docs.DOWNLOAD_PY_ARG_DOCSTRINGS,
|
81
|
-
)
|
82
|
-
def download(
|
83
|
-
name: str, version: Optional[int] = None, project: Optional[str] = None
|
84
|
-
) -> bytes:
|
85
|
-
"""Downloads a dataset from your Anyscale cloud.
|
86
|
-
|
87
|
-
:param name: Name of the dataset to download.
|
88
|
-
:param version: Version of the dataset to download. If a negative integer is provided, the dataset returned is this many versions back of the latest version. Default: Latest version.
|
89
|
-
:param project: Name of the Anyscale project to download the dataset from. If not provided, all projects will be searched.
|
90
|
-
|
91
|
-
Example usage:
|
92
|
-
```python
|
93
|
-
dataset_contents: bytes = anyscale.llm.dataset.download("my_first_dataset.jsonl")
|
94
|
-
jsonl_obj = [json.loads(line) for line in dataset_contents.decode().splitlines()]
|
95
|
-
|
96
|
-
prev_dataset_contents = anyscale.llm.dataset.download("my_first_dataset.jsonl", version=-1)
|
97
|
-
```
|
98
|
-
|
99
|
-
Returns:
|
100
|
-
bytes: The contents of the dataset file.
|
101
|
-
"""
|
102
|
-
_sdk = BaseSDK()
|
103
|
-
dataset_bytes = _sdk.client.download_dataset(name, version, project)
|
104
|
-
return dataset_bytes
|
105
|
-
|
106
|
-
|
107
|
-
@sdk_command_v2(
|
108
|
-
doc_py_example=docs.LIST_PY_EXAMPLE, arg_docstrings=docs.LIST_PY_ARG_DOCSTRINGS
|
109
|
-
)
|
110
|
-
def list( # noqa: A001
|
111
|
-
*,
|
112
|
-
# Pagination
|
113
|
-
limit: Optional[int] = None,
|
114
|
-
after: Optional[str] = None, # Unique ID to start listing after
|
115
|
-
# Filtering
|
116
|
-
name_contains: Optional[str] = None, # Substring in name, case insensitive
|
117
|
-
cloud: Optional[str] = None,
|
118
|
-
project: Optional[str] = None,
|
119
|
-
) -> ListResponse[Dataset]:
|
120
|
-
"""
|
121
|
-
Lists datasets.
|
122
|
-
|
123
|
-
:param limit: Maximum number of datasets to return. Default: 1000.
|
124
|
-
:param after: ID of the dataset to start the listing from. If provided, the list will start from the dataset after this ID.
|
125
|
-
:param name_contains: Filter datasets by name. If provided, only datasets with name containing this string will be returned.
|
126
|
-
:param cloud: Name of the Anyscale cloud to search in. If not provided, all clouds will be searched.
|
127
|
-
:param project: Name of the Anyscale project to search in. If not provided, all projects will be searched.
|
128
|
-
|
129
|
-
Example usage:
|
130
|
-
```
|
131
|
-
datasets = anyscale.llm.dataset.list(limit=10)
|
132
|
-
for d in datasets:
|
133
|
-
print(f"Dataset name: '{d.name}'") # Prints 10 dataset names
|
134
|
-
```
|
135
|
-
|
136
|
-
Returns:
|
137
|
-
ListResponse[Dataset]: List of `Dataset` objects.
|
138
|
-
"""
|
139
|
-
_sdk = BaseSDK()
|
140
|
-
list_response = _sdk.client.list_datasets(
|
141
|
-
limit=limit,
|
142
|
-
after=after,
|
143
|
-
name_contains=name_contains,
|
144
|
-
cloud=cloud,
|
145
|
-
project=project,
|
146
|
-
)
|
147
|
-
return list_response
|
anyscale/llm/model/__init__.py
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
from typing import Optional
|
2
|
-
|
3
|
-
from anyscale._private.anyscale_client import AnyscaleClientInterface
|
4
|
-
from anyscale._private.sdk.base_sdk import BaseSDK
|
5
|
-
from anyscale._private.sdk.timer import Timer
|
6
|
-
from anyscale.cli_logger import BlockLogger
|
7
|
-
from anyscale.client.openapi_client.models import FineTunedModel as APIFineTunedModel
|
8
|
-
from anyscale.llm.model.models import DeletedFineTunedModel, FineTunedModel
|
9
|
-
|
10
|
-
|
11
|
-
class PrivateLLMModelsSDK(BaseSDK):
|
12
|
-
def __init__(
|
13
|
-
self,
|
14
|
-
*,
|
15
|
-
logger: Optional[BlockLogger] = None,
|
16
|
-
client: Optional[AnyscaleClientInterface] = None,
|
17
|
-
timer: Optional[Timer] = None,
|
18
|
-
):
|
19
|
-
super().__init__(logger=logger, client=client, timer=timer)
|
20
|
-
|
21
|
-
def _parse_response_model_get(self, model: APIFineTunedModel) -> FineTunedModel:
|
22
|
-
return FineTunedModel(
|
23
|
-
id=model.id,
|
24
|
-
base_model_id=model.base_model_id,
|
25
|
-
cloud_id=model.cloud_id,
|
26
|
-
# model.created_at is a datetime object, convert to unix timestamp
|
27
|
-
created_at=int(model.created_at.timestamp()),
|
28
|
-
# `creator` is a MiniUser object, just retrieve email
|
29
|
-
creator=model.creator.email if model.creator is not None else None,
|
30
|
-
ft_type=model.ft_type,
|
31
|
-
generation_config=model.generation_config,
|
32
|
-
job_id=model.job_id,
|
33
|
-
project_id=model.project_id,
|
34
|
-
storage_uri=model.storage_uri,
|
35
|
-
workspace_id=model.workspace_id,
|
36
|
-
)
|
37
|
-
|
38
|
-
def list(
|
39
|
-
self,
|
40
|
-
*,
|
41
|
-
cloud_id: Optional[str] = None,
|
42
|
-
project_id: Optional[str] = None,
|
43
|
-
max_items: int = 20,
|
44
|
-
):
|
45
|
-
finetuned_models = self.client.list_finetuned_models(
|
46
|
-
cloud_id, project_id, max_items
|
47
|
-
)
|
48
|
-
parsed_models = [
|
49
|
-
self._parse_response_model_get(model) for model in finetuned_models
|
50
|
-
]
|
51
|
-
return parsed_models
|
52
|
-
|
53
|
-
def get(
|
54
|
-
self, *, model_id: Optional[str] = None, job_id: Optional[str] = None
|
55
|
-
) -> FineTunedModel:
|
56
|
-
model = self.client.get_finetuned_model(model_id, job_id)
|
57
|
-
return self._parse_response_model_get(model)
|
58
|
-
|
59
|
-
def delete(self, model_id) -> DeletedFineTunedModel:
|
60
|
-
deleted_model = self.client.delete_finetuned_model(model_id).to_dict()
|
61
|
-
deleted_model["deleted_at"] = int(deleted_model["deleted_at"].timestamp())
|
62
|
-
return DeletedFineTunedModel(**deleted_model)
|
anyscale/llm/model/commands.py
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
from typing import List, Optional
|
2
|
-
|
3
|
-
from anyscale._private.sdk import sdk_command
|
4
|
-
from anyscale.llm.model._private.models_sdk import PrivateLLMModelsSDK
|
5
|
-
from anyscale.llm.model.models import DeletedFineTunedModel, FineTunedModel
|
6
|
-
|
7
|
-
|
8
|
-
_LLM_MODELS_SDK_SINGLETON_KEY = "llm_models_sdk"
|
9
|
-
|
10
|
-
|
11
|
-
_RETRIEVE_EXAMPLE = """
|
12
|
-
import anyscale
|
13
|
-
|
14
|
-
anyscale.llm.model.get(model_id="my-model-id")
|
15
|
-
anyscale.llm.model.get(job_ib="prodjob_123")
|
16
|
-
"""
|
17
|
-
|
18
|
-
_RETRIEVE_ARG_DOCSTRINGS = {
|
19
|
-
"model_id": " ID of the finetuned model that is being retrieved.",
|
20
|
-
"job_id": " ID of the Anyscale job corresponding to the fine-tuning run.",
|
21
|
-
}
|
22
|
-
|
23
|
-
|
24
|
-
_DELETE_EXAMPLE = """
|
25
|
-
import anyscale
|
26
|
-
|
27
|
-
anyscale.llm.model.delete(model_id="my-model-id")
|
28
|
-
"""
|
29
|
-
|
30
|
-
_DELETE_ARG_DOCSTRINGS = {"model_id": " ID of the finetuned model to delete."}
|
31
|
-
|
32
|
-
_LIST_EXAMPLE = """
|
33
|
-
import anyscale
|
34
|
-
|
35
|
-
anyscale.llm.model.list()
|
36
|
-
anyscale.llm.model.list(cloud_id="cld_123")
|
37
|
-
anyscale.llm.model.list(project_id="prj_123")
|
38
|
-
anyscale.llm.model.list(cloud_id="cld_123", project_id="prj_123")
|
39
|
-
anyscale.llm.model.list(project_id="prj_123", max_items=10)
|
40
|
-
"""
|
41
|
-
|
42
|
-
_LIST_ARG_DOCSTRINGS = {
|
43
|
-
"cloud_id": "Cloud ID to filter by. If not specified, all models from all the clouds visible to the user (filtered optionally by `project_id`) are listed.",
|
44
|
-
"project_id": "Project ID to filter by. If not specified, all the models from all visible projects to the user (filtered optionally by `cloud_id`) are listed.",
|
45
|
-
"max_items": "Maximum number of items to show in the list. By default, the 20 most recently created models are fetched.",
|
46
|
-
}
|
47
|
-
|
48
|
-
|
49
|
-
@sdk_command(
|
50
|
-
_LLM_MODELS_SDK_SINGLETON_KEY,
|
51
|
-
PrivateLLMModelsSDK,
|
52
|
-
doc_py_example=_RETRIEVE_EXAMPLE,
|
53
|
-
arg_docstrings=_RETRIEVE_ARG_DOCSTRINGS,
|
54
|
-
)
|
55
|
-
def get(
|
56
|
-
*,
|
57
|
-
model_id: Optional[str] = None,
|
58
|
-
job_id: Optional[str] = None,
|
59
|
-
_sdk: PrivateLLMModelsSDK,
|
60
|
-
) -> FineTunedModel:
|
61
|
-
"""Retrieves model card for a finetuned model."""
|
62
|
-
return _sdk.get(model_id=model_id, job_id=job_id)
|
63
|
-
|
64
|
-
|
65
|
-
@sdk_command(
|
66
|
-
_LLM_MODELS_SDK_SINGLETON_KEY,
|
67
|
-
PrivateLLMModelsSDK,
|
68
|
-
doc_py_example=_DELETE_EXAMPLE,
|
69
|
-
arg_docstrings=_DELETE_ARG_DOCSTRINGS,
|
70
|
-
)
|
71
|
-
def delete(model_id: str, _sdk: PrivateLLMModelsSDK,) -> DeletedFineTunedModel:
|
72
|
-
"""Deletes a finetuned model. Requires owner permission for the corresponding Anyscale project."""
|
73
|
-
return _sdk.delete(model_id)
|
74
|
-
|
75
|
-
|
76
|
-
@sdk_command(
|
77
|
-
_LLM_MODELS_SDK_SINGLETON_KEY,
|
78
|
-
PrivateLLMModelsSDK,
|
79
|
-
doc_py_example=_LIST_EXAMPLE,
|
80
|
-
arg_docstrings=_LIST_ARG_DOCSTRINGS,
|
81
|
-
)
|
82
|
-
def list( # noqa: A001
|
83
|
-
*,
|
84
|
-
cloud_id: Optional[str] = None,
|
85
|
-
project_id: Optional[str] = None,
|
86
|
-
max_items: int = 20,
|
87
|
-
_sdk: PrivateLLMModelsSDK,
|
88
|
-
) -> List[FineTunedModel]:
|
89
|
-
"""Lists fine-tuned models available to the user.
|
90
|
-
|
91
|
-
By default, all models in all visible clouds under all visible projects to the user are listed. This is optionally filtered by `project_id` and/or `cloud_id`.
|
92
|
-
"""
|
93
|
-
return _sdk.list(cloud_id=cloud_id, project_id=project_id, max_items=max_items)
|
anyscale/llm/model/models.py
DELETED
@@ -1,171 +0,0 @@
|
|
1
|
-
from dataclasses import dataclass, field
|
2
|
-
from typing import Any, Dict, Optional
|
3
|
-
|
4
|
-
from anyscale._private.models.model_base import ModelBase, ModelEnum
|
5
|
-
|
6
|
-
|
7
|
-
class FineTuningType(ModelEnum):
|
8
|
-
LORA = "LORA"
|
9
|
-
FULL_PARAM = "FULL_PARAM"
|
10
|
-
|
11
|
-
__docstrings__ = {
|
12
|
-
LORA: "Low-Rank Adaptation (LoRA) fine-tuning method.",
|
13
|
-
FULL_PARAM: "Full parameter fine-tuning method.",
|
14
|
-
}
|
15
|
-
|
16
|
-
|
17
|
-
@dataclass(frozen=True)
|
18
|
-
class FineTunedModel(ModelBase):
|
19
|
-
"""Represents a fine-tuned model with its associated metadata."""
|
20
|
-
|
21
|
-
__doc_py_example__ = """\
|
22
|
-
import anyscale
|
23
|
-
from anyscale.llm.model.models import FineTunedModel
|
24
|
-
model: FineTunedModel = anyscale.llm.model.get(model_id="my-model-id")
|
25
|
-
"""
|
26
|
-
|
27
|
-
__doc_cli_example__ = """\
|
28
|
-
$ anyscale llm model get --model-id my-model-id
|
29
|
-
id: my-model-id
|
30
|
-
base_model_id: meta-llama/Llama-3-8B-Instruct
|
31
|
-
cloud_id: cloud_abc123
|
32
|
-
created_at: 1725473924
|
33
|
-
job_id: prodjob_xyz789
|
34
|
-
ft_type: LORA
|
35
|
-
...
|
36
|
-
"""
|
37
|
-
|
38
|
-
id: str = field(metadata={"docstring": "Unique ID/tag for the fine-tuned model."})
|
39
|
-
|
40
|
-
def _validate_id(self, id: str): # noqa: A002
|
41
|
-
if not isinstance(id, str):
|
42
|
-
raise TypeError("'id' must be a string.")
|
43
|
-
|
44
|
-
base_model_id: str = field(
|
45
|
-
metadata={"docstring": "Base model ID used for fine-tuning."}
|
46
|
-
)
|
47
|
-
|
48
|
-
def _validate_base_model_id(self, base_model_id: str):
|
49
|
-
if not isinstance(base_model_id, str):
|
50
|
-
raise TypeError("'base_model_id' must be a string.")
|
51
|
-
|
52
|
-
cloud_id: str = field(
|
53
|
-
metadata={
|
54
|
-
"docstring": "ID for the Anyscale Cloud corresponding to the fine-tuning run."
|
55
|
-
}
|
56
|
-
)
|
57
|
-
|
58
|
-
def _validate_cloud_id(self, cloud_id: str):
|
59
|
-
if not isinstance(cloud_id, str):
|
60
|
-
raise TypeError("'cloud_id' must be a string.")
|
61
|
-
|
62
|
-
created_at: int = field(
|
63
|
-
metadata={"docstring": "Time at which the fine-tuned model was created."}
|
64
|
-
)
|
65
|
-
|
66
|
-
def _validate_created_at(self, created_at: int):
|
67
|
-
if not isinstance(created_at, int):
|
68
|
-
raise TypeError("'created_at' must be an integer (Unix timestamp).")
|
69
|
-
|
70
|
-
if created_at < 0:
|
71
|
-
raise ValueError("'created_at' must be a positive integer")
|
72
|
-
|
73
|
-
creator: Optional[str] = field(
|
74
|
-
metadata={"docstring": "Email address for the user who created the model."}
|
75
|
-
)
|
76
|
-
|
77
|
-
def _validate_creator(self, creator: Optional[str]):
|
78
|
-
if creator is not None and not isinstance(creator, str):
|
79
|
-
raise TypeError("'creator' must be a string or None.")
|
80
|
-
|
81
|
-
ft_type: FineTuningType = field(metadata={"docstring": "Fine-tuning type."})
|
82
|
-
|
83
|
-
def _validate_ft_type(self, ft_type: FineTuningType) -> FineTuningType:
|
84
|
-
return FineTuningType.validate(ft_type)
|
85
|
-
|
86
|
-
generation_config: Optional[Dict[str, Any]] = field(
|
87
|
-
metadata={
|
88
|
-
"docstring": "Inference generation config with chat-templating parameters and stopping sequences."
|
89
|
-
}
|
90
|
-
)
|
91
|
-
|
92
|
-
def _validate_generation_config(self, generation_config: Optional[Dict[str, Any]]):
|
93
|
-
if generation_config is not None and not isinstance(generation_config, dict):
|
94
|
-
raise TypeError("'generation_config' must be a dictionary or None.")
|
95
|
-
|
96
|
-
job_id: Optional[str] = field(
|
97
|
-
metadata={
|
98
|
-
"docstring": "ID for the Anyscale job corresponding to the fine-tuning run, if applicable."
|
99
|
-
}
|
100
|
-
)
|
101
|
-
|
102
|
-
def _validate_job_id(self, job_id: Optional[str]):
|
103
|
-
if job_id is not None and not isinstance(job_id, str):
|
104
|
-
raise TypeError("'job_id' must be a string or None.")
|
105
|
-
|
106
|
-
project_id: Optional[str] = field(
|
107
|
-
metadata={
|
108
|
-
"docstring": "ID for the Anyscale Project corresponding to the fine-tuning run."
|
109
|
-
}
|
110
|
-
)
|
111
|
-
|
112
|
-
def _validate_project_id(self, project_id: Optional[str]):
|
113
|
-
if project_id is not None and not isinstance(project_id, str):
|
114
|
-
raise TypeError("'project_id' must be a string.")
|
115
|
-
|
116
|
-
storage_uri: str = field(
|
117
|
-
metadata={
|
118
|
-
"docstring": "URI at which the fine-tuned model checkpoint is stored."
|
119
|
-
}
|
120
|
-
)
|
121
|
-
|
122
|
-
def _validate_storage_uri(self, storage_uri: str):
|
123
|
-
if not isinstance(storage_uri, str):
|
124
|
-
raise TypeError("'storage_uri' must be a string.")
|
125
|
-
|
126
|
-
workspace_id: Optional[str] = field(
|
127
|
-
default=None,
|
128
|
-
metadata={
|
129
|
-
"docstring": "ID for the Anyscale Workspace in which the model was fine-tuned, if any."
|
130
|
-
},
|
131
|
-
)
|
132
|
-
|
133
|
-
def _validate_workspace_id(self, workspace_id: Optional[str]):
|
134
|
-
if workspace_id is not None and not isinstance(workspace_id, str):
|
135
|
-
raise TypeError("'workspace_id' must be a string or None.")
|
136
|
-
|
137
|
-
|
138
|
-
@dataclass(frozen=True)
|
139
|
-
class DeletedFineTunedModel(ModelBase):
|
140
|
-
"""Represents a deleted fine-tuned model with its deletion metadata."""
|
141
|
-
|
142
|
-
__doc_py_example__ = """\
|
143
|
-
import anyscale
|
144
|
-
from anyscale.llm.model.models import DeletedFineTunedModel
|
145
|
-
deleted_model: DeletedFineTunedModel = anyscale.llm.model.delete("my-model-id")
|
146
|
-
"""
|
147
|
-
|
148
|
-
__doc_cli_example__ = """\
|
149
|
-
$ anyscale models get-deleted my-model-id
|
150
|
-
id: my-model-id
|
151
|
-
deleted_at: 1725473924
|
152
|
-
"""
|
153
|
-
|
154
|
-
id: str = field(metadata={"docstring": "Unique ID/tag for the fine-tuned model."})
|
155
|
-
|
156
|
-
def _validate_id(self, id: str): # noqa: A002
|
157
|
-
if not isinstance(id, str):
|
158
|
-
raise TypeError("'id' must be a string.")
|
159
|
-
|
160
|
-
deleted_at: int = field(
|
161
|
-
metadata={
|
162
|
-
"docstring": "Unix timestamp (in seconds) at which the fine-tuned model was deleted."
|
163
|
-
}
|
164
|
-
)
|
165
|
-
|
166
|
-
def _validate_deleted_at(self, deleted_at: int):
|
167
|
-
if not isinstance(deleted_at, int):
|
168
|
-
raise TypeError("'deleted_at' must be an integer (Unix timestamp).")
|
169
|
-
|
170
|
-
if deleted_at < 0:
|
171
|
-
raise ValueError("'deleted_at' must be a positive integer (Unix timestamp)")
|
anyscale/llm/model/sdk.py
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
from typing import Any, 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 BaseSDK, Timer
|
6
|
-
from anyscale.cli_logger import BlockLogger
|
7
|
-
from anyscale.llm.model._private.models_sdk import PrivateLLMModelsSDK
|
8
|
-
from anyscale.llm.model.commands import (
|
9
|
-
_DELETE_ARG_DOCSTRINGS,
|
10
|
-
_DELETE_EXAMPLE,
|
11
|
-
_LIST_ARG_DOCSTRINGS,
|
12
|
-
_LIST_EXAMPLE,
|
13
|
-
_RETRIEVE_ARG_DOCSTRINGS,
|
14
|
-
_RETRIEVE_EXAMPLE,
|
15
|
-
)
|
16
|
-
|
17
|
-
|
18
|
-
class LLMModelsSDK(BaseSDK):
|
19
|
-
def __init__(
|
20
|
-
self,
|
21
|
-
*,
|
22
|
-
logger: Optional[BlockLogger] = None,
|
23
|
-
client: Optional[AnyscaleClientInterface] = None,
|
24
|
-
timer: Optional[Timer] = None,
|
25
|
-
):
|
26
|
-
self._private_sdk = PrivateLLMModelsSDK(
|
27
|
-
logger=logger, client=client, timer=timer
|
28
|
-
)
|
29
|
-
|
30
|
-
@sdk_docs(
|
31
|
-
doc_py_example=_RETRIEVE_EXAMPLE, arg_docstrings=_RETRIEVE_ARG_DOCSTRINGS,
|
32
|
-
)
|
33
|
-
def get(
|
34
|
-
self, *, model_id: Optional[str] = None, job_id: Optional[str] = None
|
35
|
-
) -> Any:
|
36
|
-
"""Retrives model card for a finetuned model."""
|
37
|
-
return self._private_sdk.get(model_id=model_id, job_id=job_id)
|
38
|
-
|
39
|
-
@sdk_docs(
|
40
|
-
doc_py_example=_DELETE_EXAMPLE, arg_docstrings=_DELETE_ARG_DOCSTRINGS,
|
41
|
-
)
|
42
|
-
def delete(self, model_id: str) -> Any:
|
43
|
-
"""Deletes a finetuned model. Requires owner permission for the corresponding Anyscale project."""
|
44
|
-
return self._private_sdk.delete(model_id)
|
45
|
-
|
46
|
-
@sdk_docs(
|
47
|
-
doc_py_example=_LIST_EXAMPLE, arg_docstrings=_LIST_ARG_DOCSTRINGS,
|
48
|
-
)
|
49
|
-
def list(
|
50
|
-
self,
|
51
|
-
*,
|
52
|
-
cloud_id: Optional[str] = None,
|
53
|
-
project_id: Optional[str] = None,
|
54
|
-
max_items: int = 20,
|
55
|
-
) -> Any:
|
56
|
-
"""Lists fine-tuned models available to the user.
|
57
|
-
|
58
|
-
By default, all models in all visible clouds under all visible projects to the user are listed. This is optionally filtered by `project_id` and/or `cloud_id`.
|
59
|
-
"""
|
60
|
-
return self._private_sdk.list(
|
61
|
-
cloud_id=cloud_id, project_id=project_id, max_items=max_items
|
62
|
-
)
|
anyscale/llm/sdk.py
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
from typing import Optional
|
2
|
-
|
3
|
-
import anyscale
|
4
|
-
from anyscale._private.anyscale_client import AnyscaleClientInterface
|
5
|
-
from anyscale._private.sdk.base_sdk import BaseSDK
|
6
|
-
from anyscale._private.sdk.timer import Timer
|
7
|
-
from anyscale.cli_logger import BlockLogger
|
8
|
-
from anyscale.llm.model import LLMModelsSDK
|
9
|
-
|
10
|
-
|
11
|
-
class LLMSDK(BaseSDK):
|
12
|
-
def __init__(
|
13
|
-
self,
|
14
|
-
*,
|
15
|
-
logger: Optional[BlockLogger] = None,
|
16
|
-
client: Optional[AnyscaleClientInterface] = None,
|
17
|
-
timer: Optional[Timer] = None,
|
18
|
-
):
|
19
|
-
self._model = LLMModelsSDK(logger=logger, client=client, timer=timer)
|
20
|
-
|
21
|
-
@property
|
22
|
-
def model(self):
|
23
|
-
return self._model
|
24
|
-
|
25
|
-
@property
|
26
|
-
def dataset(self):
|
27
|
-
return anyscale.llm.dataset
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|