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,269 +0,0 @@
|
|
1
|
-
import os
|
2
|
-
from typing import Optional
|
3
|
-
|
4
|
-
import click
|
5
|
-
from dateutil import tz
|
6
|
-
from rich import print as rprint
|
7
|
-
import tabulate
|
8
|
-
|
9
|
-
import anyscale
|
10
|
-
from anyscale.commands import command_examples
|
11
|
-
from anyscale.commands.util import AnyscaleCommand
|
12
|
-
|
13
|
-
|
14
|
-
@click.group("dataset", help="Dataset files stored on your Anyscale cloud.")
|
15
|
-
def dataset_cli():
|
16
|
-
pass
|
17
|
-
|
18
|
-
|
19
|
-
@dataset_cli.command(
|
20
|
-
name="get",
|
21
|
-
short_help="Retrieves metadata about a dataset.",
|
22
|
-
cls=AnyscaleCommand,
|
23
|
-
is_alpha=True,
|
24
|
-
example=command_examples.LLM_DATASET_GET_EXAMPLE,
|
25
|
-
)
|
26
|
-
@click.argument(
|
27
|
-
"name", required=True,
|
28
|
-
)
|
29
|
-
@click.option(
|
30
|
-
"--version",
|
31
|
-
"-v",
|
32
|
-
required=False,
|
33
|
-
type=int,
|
34
|
-
help="Version of the dataset. "
|
35
|
-
"If a negative integer is provided, the dataset returned is this many versions back of the latest version. "
|
36
|
-
"Default: Latest version.",
|
37
|
-
)
|
38
|
-
@click.option(
|
39
|
-
"--project",
|
40
|
-
required=False,
|
41
|
-
help="Name of the Anyscale project that the dataset belongs to. "
|
42
|
-
"If not provided, all projects will be searched.",
|
43
|
-
)
|
44
|
-
def get_dataset(
|
45
|
-
name: str, version: Optional[int], project: Optional[str],
|
46
|
-
):
|
47
|
-
"""
|
48
|
-
Retrieves metadata about a dataset.
|
49
|
-
|
50
|
-
NAME = Name of the dataset
|
51
|
-
|
52
|
-
Example usage:
|
53
|
-
|
54
|
-
anyscale llm dataset get my_first_dataset
|
55
|
-
|
56
|
-
Retrieve the second latest version of the dataset:
|
57
|
-
|
58
|
-
anyscale llm dataset get my_first_dataset -v -1
|
59
|
-
"""
|
60
|
-
dataset = anyscale.llm.dataset.get(name, version, project)
|
61
|
-
rprint(dataset)
|
62
|
-
|
63
|
-
|
64
|
-
@dataset_cli.command(
|
65
|
-
name="upload",
|
66
|
-
short_help="Upload a dataset to your Anyscale cloud.",
|
67
|
-
cls=AnyscaleCommand,
|
68
|
-
is_alpha=True,
|
69
|
-
example=command_examples.LLM_DATASET_UPLOAD_EXAMPLE,
|
70
|
-
)
|
71
|
-
@click.argument("dataset_file", required=True)
|
72
|
-
@click.option(
|
73
|
-
"--name",
|
74
|
-
"-n",
|
75
|
-
required=True,
|
76
|
-
help="Name of a new dataset, or an existing dataset, to upload a new version of.",
|
77
|
-
)
|
78
|
-
@click.option(
|
79
|
-
"--description", required=False, help="Description of the dataset version.",
|
80
|
-
)
|
81
|
-
@click.option(
|
82
|
-
"--cloud",
|
83
|
-
required=False,
|
84
|
-
help="Name of the Anyscale cloud to upload a new dataset to. "
|
85
|
-
"If not provided, the default cloud will be used.",
|
86
|
-
)
|
87
|
-
@click.option(
|
88
|
-
"--project",
|
89
|
-
required=False,
|
90
|
-
help="Name of the Anyscale project to upload a new dataset to. "
|
91
|
-
"If not provided, the default project of the cloud will be used.",
|
92
|
-
)
|
93
|
-
def upload_dataset(
|
94
|
-
dataset_file: str,
|
95
|
-
name: str,
|
96
|
-
description: Optional[str],
|
97
|
-
cloud: Optional[str],
|
98
|
-
project: Optional[str],
|
99
|
-
):
|
100
|
-
"""
|
101
|
-
Uploads a dataset, or a new version of a dataset, to your Anyscale cloud.
|
102
|
-
|
103
|
-
DATASET_FILE = Path to the dataset file to upload
|
104
|
-
|
105
|
-
Example usage:
|
106
|
-
|
107
|
-
anyscale llm dataset upload path/to/my_dataset.jsonl -n my_first_dataset
|
108
|
-
|
109
|
-
anyscale llm dataset upload my_dataset.jsonl -n second_dataset.jsonl
|
110
|
-
|
111
|
-
anyscale llm dataset upload my_dataset2.jsonl -n second_dataset.jsonl --description 'added 3 lines'
|
112
|
-
|
113
|
-
\b
|
114
|
-
NOTE:
|
115
|
-
If you are uploading a new version, have run this from within an Anyscale workspace,
|
116
|
-
and neither `--cloud` nor `--project` is provided, the cloud and project of the workspace will be used.
|
117
|
-
"""
|
118
|
-
dataset = anyscale.llm.dataset.upload(
|
119
|
-
dataset_file, name, description=description, cloud=cloud, project=project,
|
120
|
-
)
|
121
|
-
rprint(dataset)
|
122
|
-
|
123
|
-
|
124
|
-
@dataset_cli.command(
|
125
|
-
name="download",
|
126
|
-
short_help="Download a dataset.",
|
127
|
-
cls=AnyscaleCommand,
|
128
|
-
is_alpha=True,
|
129
|
-
example=command_examples.LLM_DATASET_DOWNLOAD_EXAMPLE,
|
130
|
-
)
|
131
|
-
@click.argument(
|
132
|
-
"name", required=True,
|
133
|
-
)
|
134
|
-
@click.option(
|
135
|
-
"--version",
|
136
|
-
"-v",
|
137
|
-
required=False,
|
138
|
-
type=int,
|
139
|
-
help="Version of the dataset to download. "
|
140
|
-
"If a negative integer is provided, the dataset returned is this many versions back of the latest version. "
|
141
|
-
"Default: Latest version.",
|
142
|
-
)
|
143
|
-
@click.option(
|
144
|
-
"--project",
|
145
|
-
required=False,
|
146
|
-
help="Name of the Anyscale project to download the dataset from. "
|
147
|
-
"If not provided, all projects will be searched.",
|
148
|
-
)
|
149
|
-
@click.option(
|
150
|
-
"--output",
|
151
|
-
"-o",
|
152
|
-
required=False,
|
153
|
-
help="Path to save the downloaded dataset to."
|
154
|
-
"If not provided, the dataset contents will be printed to the terminal.",
|
155
|
-
)
|
156
|
-
def download_dataset(
|
157
|
-
name: str, version: Optional[int], project: Optional[str], output: Optional[str],
|
158
|
-
):
|
159
|
-
"""
|
160
|
-
Downloads a dataset from your Anyscale cloud.
|
161
|
-
|
162
|
-
NAME = Name of the dataset to download
|
163
|
-
|
164
|
-
Prints the dataset contents to the terminal by default.
|
165
|
-
|
166
|
-
Example usage:
|
167
|
-
|
168
|
-
anyscale llm dataset download my_first_dataset.jsonl
|
169
|
-
|
170
|
-
Save the dataset to a file:
|
171
|
-
|
172
|
-
anyscale llm dataset download my_dataset.jsonl -o ~/Downloads/my_dataset.jsonl
|
173
|
-
|
174
|
-
Retrieve the second latest version of the dataset:
|
175
|
-
|
176
|
-
anyscale llm dataset download my_dataset.jsonl -v -1
|
177
|
-
"""
|
178
|
-
if output:
|
179
|
-
output = os.path.expanduser(output)
|
180
|
-
if os.path.exists(output):
|
181
|
-
raise click.ClickException(f"File already exists at '{output}'")
|
182
|
-
downloaded_contents = anyscale.llm.dataset.download(name, version, project)
|
183
|
-
if output:
|
184
|
-
# Create the parent directory if it doesn't exist
|
185
|
-
parent_dir = os.path.dirname(output)
|
186
|
-
if parent_dir:
|
187
|
-
os.makedirs(parent_dir, exist_ok=True)
|
188
|
-
with open(output, "wb") as output_file:
|
189
|
-
output_file.write(downloaded_contents)
|
190
|
-
rprint(f"Dataset '{name}' downloaded to '{output}'")
|
191
|
-
return
|
192
|
-
print(downloaded_contents.decode())
|
193
|
-
|
194
|
-
|
195
|
-
@dataset_cli.command(
|
196
|
-
name="list",
|
197
|
-
short_help="List datasets.",
|
198
|
-
cls=AnyscaleCommand,
|
199
|
-
is_alpha=True,
|
200
|
-
example=command_examples.LLM_DATASET_LIST_EXAMPLE,
|
201
|
-
)
|
202
|
-
@click.option(
|
203
|
-
"--limit",
|
204
|
-
"-l",
|
205
|
-
required=False,
|
206
|
-
default=10,
|
207
|
-
type=int,
|
208
|
-
help="Maximum number of datasets to return. Default: 10.",
|
209
|
-
)
|
210
|
-
@click.option(
|
211
|
-
"--after",
|
212
|
-
required=False,
|
213
|
-
help="ID of the dataset to start the listing from. If provided, the list will start from the dataset after this ID.",
|
214
|
-
)
|
215
|
-
@click.option(
|
216
|
-
"--name-contains",
|
217
|
-
"-n",
|
218
|
-
required=False,
|
219
|
-
help="Filter datasets by name. If provided, only datasets with name containing this string will be returned.",
|
220
|
-
)
|
221
|
-
@click.option(
|
222
|
-
"--cloud",
|
223
|
-
required=False,
|
224
|
-
help="Name of the Anyscale cloud to search in. If not provided, all clouds will be searched.",
|
225
|
-
)
|
226
|
-
@click.option(
|
227
|
-
"--project",
|
228
|
-
required=False,
|
229
|
-
help="Name of the Anyscale project to search in. If not provided, all projects will be searched.",
|
230
|
-
)
|
231
|
-
def list_datasets(
|
232
|
-
limit: int,
|
233
|
-
after: Optional[str],
|
234
|
-
name_contains: Optional[str],
|
235
|
-
cloud: Optional[str],
|
236
|
-
project: Optional[str],
|
237
|
-
):
|
238
|
-
"""
|
239
|
-
Lists datasets.
|
240
|
-
|
241
|
-
Example usage:
|
242
|
-
|
243
|
-
anyscale llm dataset list
|
244
|
-
|
245
|
-
List datasets in a specific project:
|
246
|
-
|
247
|
-
anyscale llm dataset list --project my_project
|
248
|
-
"""
|
249
|
-
datasets = anyscale.llm.dataset.list(
|
250
|
-
limit=limit,
|
251
|
-
after=after,
|
252
|
-
name_contains=name_contains,
|
253
|
-
cloud=cloud,
|
254
|
-
project=project,
|
255
|
-
)
|
256
|
-
table = tabulate.tabulate(
|
257
|
-
[
|
258
|
-
(
|
259
|
-
d.id,
|
260
|
-
d.name,
|
261
|
-
d.description,
|
262
|
-
d.created_at.astimezone(tz=tz.tzlocal()).strftime("%m/%d/%Y %I:%M %p"),
|
263
|
-
d.num_versions,
|
264
|
-
)
|
265
|
-
for d in datasets
|
266
|
-
],
|
267
|
-
headers=["ID", "Name", "Description", "Created At", "Num Versions"],
|
268
|
-
)
|
269
|
-
rprint(table)
|
anyscale/commands/llm/group.py
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
import click
|
2
|
-
|
3
|
-
from anyscale.commands.llm.dataset_commands import dataset_cli
|
4
|
-
from anyscale.commands.llm.models_commands import models_cli
|
5
|
-
|
6
|
-
|
7
|
-
@click.group(
|
8
|
-
"llm", help="Interact with Anyscale's LLM APIs.",
|
9
|
-
)
|
10
|
-
def llm_cli():
|
11
|
-
pass
|
12
|
-
|
13
|
-
|
14
|
-
llm_cli.add_command(dataset_cli)
|
15
|
-
llm_cli.add_command(models_cli)
|
@@ -1,123 +0,0 @@
|
|
1
|
-
from typing import Optional
|
2
|
-
|
3
|
-
import click
|
4
|
-
|
5
|
-
from anyscale.commands import command_examples
|
6
|
-
from anyscale.commands.util import AnyscaleCommand
|
7
|
-
from anyscale.controllers.llm.models_controller import ModelsController
|
8
|
-
from anyscale.util import validate_non_negative_arg
|
9
|
-
|
10
|
-
|
11
|
-
@click.group("model", help="Finetuned models stored on your Anyscale cloud.")
|
12
|
-
def models_cli():
|
13
|
-
pass
|
14
|
-
|
15
|
-
|
16
|
-
@models_cli.command(
|
17
|
-
name="get",
|
18
|
-
short_help="Retrieves information for a model in your Anyscale cloud.",
|
19
|
-
cls=AnyscaleCommand,
|
20
|
-
is_alpha=True,
|
21
|
-
example=command_examples.LLM_MODELS_GET_EXAMPLE,
|
22
|
-
)
|
23
|
-
@click.option(
|
24
|
-
"--model-id",
|
25
|
-
required=False,
|
26
|
-
type=str,
|
27
|
-
default=None,
|
28
|
-
help="ID for the model of interest",
|
29
|
-
)
|
30
|
-
@click.option(
|
31
|
-
"--job-id",
|
32
|
-
required=False,
|
33
|
-
type=str,
|
34
|
-
default=None,
|
35
|
-
help="ID for the Anyscale job corresponding to the fine-tuning run",
|
36
|
-
)
|
37
|
-
def get_model(model_id: Optional[str], job_id: Optional[str]) -> None:
|
38
|
-
"""
|
39
|
-
Gets the model card for the given model ID or corresponding job ID.
|
40
|
-
|
41
|
-
Example usage:
|
42
|
-
|
43
|
-
anyscale llm model get --model-id my-model-id
|
44
|
-
|
45
|
-
anyscale llm model get --job-id job_123
|
46
|
-
"""
|
47
|
-
ModelsController().get_model(model_id=model_id, job_id=job_id)
|
48
|
-
|
49
|
-
|
50
|
-
@models_cli.command(
|
51
|
-
name="delete",
|
52
|
-
short_help="Delete a fine-tuned model in your Anyscale cloud.",
|
53
|
-
cls=AnyscaleCommand,
|
54
|
-
is_alpha=True,
|
55
|
-
example=command_examples.LLM_MODELS_DELETE_EXAMPLE,
|
56
|
-
)
|
57
|
-
@click.argument("model_id", required=True)
|
58
|
-
def delete_model(model_id: str) -> None:
|
59
|
-
"""
|
60
|
-
Deletes the model for the given model ID. Requires owner permission for the corresponding Anyscale project.
|
61
|
-
|
62
|
-
MODEL_ID = ID for the model of interest
|
63
|
-
|
64
|
-
Example usage:
|
65
|
-
|
66
|
-
anyscale llm model delete my-model-id
|
67
|
-
"""
|
68
|
-
ModelsController().delete_model(model_id)
|
69
|
-
|
70
|
-
|
71
|
-
@models_cli.command(
|
72
|
-
name="list",
|
73
|
-
short_help="Lists fine-tuned models available to the user.",
|
74
|
-
cls=AnyscaleCommand,
|
75
|
-
is_alpha=True,
|
76
|
-
example=command_examples.LLM_MODELS_LIST_EXAMPLE,
|
77
|
-
)
|
78
|
-
@click.option(
|
79
|
-
"--cloud-id",
|
80
|
-
required=False,
|
81
|
-
type=str,
|
82
|
-
help="Cloud ID to filter by. If not specified, all models from all visible clouds (filtered optionally by `project_id`) are listed.",
|
83
|
-
)
|
84
|
-
@click.option(
|
85
|
-
"--project-id",
|
86
|
-
required=False,
|
87
|
-
type=str,
|
88
|
-
help="Project ID to filter by. If not specified, all the models from all visible projects (filtered optionally by `cloud_id`) are listed.",
|
89
|
-
)
|
90
|
-
@click.option(
|
91
|
-
"--max-items",
|
92
|
-
required=False,
|
93
|
-
type=int,
|
94
|
-
default=20,
|
95
|
-
help="Maximum number of items to show in the list. By default, the 20 most recently created models are fetched.",
|
96
|
-
callback=validate_non_negative_arg,
|
97
|
-
)
|
98
|
-
def list_models(cloud_id: Optional[str], project_id: Optional[str], max_items: int):
|
99
|
-
"""
|
100
|
-
Lists fine-tuned models available to the user.
|
101
|
-
|
102
|
-
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`.
|
103
|
-
|
104
|
-
Example usage:
|
105
|
-
|
106
|
-
anyscale llm model list
|
107
|
-
|
108
|
-
anyscale llm model list --max-items 50
|
109
|
-
|
110
|
-
anyscale llm model list --cloud-id cld_123
|
111
|
-
|
112
|
-
anyscale llm model list --project-id prj_123
|
113
|
-
|
114
|
-
anyscale llm model list --cloud-id cld_123 --project-id prj_123
|
115
|
-
|
116
|
-
|
117
|
-
NOTE:
|
118
|
-
If you are running this from within an Anyscale workspace, and neither `cloud_id` nor `project_id` are provided, the cloud and project of the workspace will be used.
|
119
|
-
"""
|
120
|
-
controller = ModelsController()
|
121
|
-
controller.list_models(
|
122
|
-
cloud_id=cloud_id, project_id=project_id, max_items=max_items
|
123
|
-
)
|
File without changes
|
@@ -1,144 +0,0 @@
|
|
1
|
-
import json
|
2
|
-
from typing import Any, Dict, Optional
|
3
|
-
|
4
|
-
from rich import print as rprint
|
5
|
-
|
6
|
-
from anyscale.api_utils.common_utils import (
|
7
|
-
get_current_workspace_id,
|
8
|
-
source_cloud_id_and_project_id,
|
9
|
-
)
|
10
|
-
from anyscale.cli_logger import BlockLogger
|
11
|
-
from anyscale.client.openapi_client import FinetunedmodelListResponse
|
12
|
-
from anyscale.client.openapi_client.models import FineTunedModel as APIFineTunedModel
|
13
|
-
from anyscale.controllers.base_controller import BaseController
|
14
|
-
from anyscale.llm.model.models import DeletedFineTunedModel, FineTunedModel
|
15
|
-
|
16
|
-
|
17
|
-
LIST_ENDPOINT_COUNT = 20
|
18
|
-
|
19
|
-
|
20
|
-
class ModelsController(BaseController):
|
21
|
-
def __init__(
|
22
|
-
self, log: Optional[BlockLogger] = None, initialize_auth_api_client: bool = True
|
23
|
-
):
|
24
|
-
if log is None:
|
25
|
-
log = BlockLogger()
|
26
|
-
|
27
|
-
super().__init__(initialize_auth_api_client=initialize_auth_api_client)
|
28
|
-
|
29
|
-
self.log = log
|
30
|
-
self.log.open_block("Output")
|
31
|
-
|
32
|
-
def _parse_response_model_get(self, model: APIFineTunedModel) -> FineTunedModel:
|
33
|
-
return FineTunedModel(
|
34
|
-
id=model.id,
|
35
|
-
base_model_id=model.base_model_id,
|
36
|
-
cloud_id=model.cloud_id,
|
37
|
-
# model.created_at is a datetime object, convert to unix timestamp
|
38
|
-
created_at=int(model.created_at.timestamp()),
|
39
|
-
# `creator` is a MiniUser object, just retrieve email
|
40
|
-
creator=model.creator.email if model.creator is not None else None,
|
41
|
-
ft_type=model.ft_type,
|
42
|
-
generation_config=model.generation_config,
|
43
|
-
job_id=model.job_id,
|
44
|
-
project_id=model.project_id,
|
45
|
-
storage_uri=model.storage_uri,
|
46
|
-
workspace_id=model.workspace_id,
|
47
|
-
)
|
48
|
-
|
49
|
-
def _truncate(self, val: str, limit=50):
|
50
|
-
return val[:limit] + "..." if len(val) > limit else val
|
51
|
-
|
52
|
-
def _format_as_dict(
|
53
|
-
self, model: FineTunedModel, truncate: bool = False
|
54
|
-
) -> Dict[str, Any]:
|
55
|
-
output_map = {
|
56
|
-
"id": model.id,
|
57
|
-
"base_model_id": model.base_model_id,
|
58
|
-
"storage_uri": self._truncate(model.storage_uri)
|
59
|
-
if truncate
|
60
|
-
else model.storage_uri,
|
61
|
-
"ft_type": str(model.ft_type),
|
62
|
-
"cloud_id": model.cloud_id,
|
63
|
-
"project_id": model.project_id if model.project_id else "N/A",
|
64
|
-
"created_at": model.created_at,
|
65
|
-
"creator": model.creator if model.creator else "N/A",
|
66
|
-
"job_id": model.job_id if model.job_id else "N/A",
|
67
|
-
"workspace_id": model.workspace_id if model.workspace_id else "N/A",
|
68
|
-
"generation_config": self._truncate(json.dumps(model.generation_config))
|
69
|
-
if truncate
|
70
|
-
else model.generation_config,
|
71
|
-
}
|
72
|
-
return output_map
|
73
|
-
|
74
|
-
def get_model(self, model_id: Optional[str], job_id: Optional[str]):
|
75
|
-
"""Retrieves model information given model id"""
|
76
|
-
if model_id:
|
77
|
-
model = self.api_client.get_model_api_v2_llm_models_model_id_get(
|
78
|
-
model_id
|
79
|
-
).result
|
80
|
-
elif job_id:
|
81
|
-
model = self.api_client.get_model_by_job_id_api_v2_llm_models_get_by_job_id_job_id_get(
|
82
|
-
job_id
|
83
|
-
).result
|
84
|
-
else:
|
85
|
-
raise ValueError("Atleast one of `model-id` or `job-id` should be provided")
|
86
|
-
|
87
|
-
model = self._parse_response_model_get(model)
|
88
|
-
formatted_model = self._format_as_dict(model)
|
89
|
-
rprint(formatted_model)
|
90
|
-
return
|
91
|
-
|
92
|
-
def delete_model(self, model_id: str):
|
93
|
-
deleted_model = self.api_client.delete_model_api_v2_llm_models_model_id_delete(
|
94
|
-
model_id
|
95
|
-
).result
|
96
|
-
deleted_model_dict = deleted_model.to_dict()
|
97
|
-
deleted_model_dict["deleted_at"] = int(
|
98
|
-
deleted_model_dict["deleted_at"].timestamp()
|
99
|
-
)
|
100
|
-
deleted_model = DeletedFineTunedModel.from_dict(deleted_model_dict)
|
101
|
-
rprint(deleted_model.to_dict())
|
102
|
-
return
|
103
|
-
|
104
|
-
def list_models(
|
105
|
-
self, *, cloud_id: Optional[str], project_id: Optional[str], max_items: int
|
106
|
-
):
|
107
|
-
"""Lists fine-tuned models optionally filtered by `cloud_id` and `project_id`"""
|
108
|
-
if get_current_workspace_id() is not None:
|
109
|
-
# Resolve `cloud_id` and `project_id`. If not provided and if this is being run in a workspace,
|
110
|
-
# we use the `cloud_id` and `project_id` of the workspace
|
111
|
-
cloud_id, project_id = source_cloud_id_and_project_id(
|
112
|
-
internal_api=self.api_client,
|
113
|
-
external_api=self.anyscale_api_client,
|
114
|
-
cloud_id=cloud_id,
|
115
|
-
project_id=project_id,
|
116
|
-
)
|
117
|
-
paging_token = None
|
118
|
-
results = []
|
119
|
-
while True:
|
120
|
-
count = min(LIST_ENDPOINT_COUNT, max_items)
|
121
|
-
resp: FinetunedmodelListResponse = self.api_client.list_models_api_v2_llm_models_get(
|
122
|
-
cloud_id=cloud_id,
|
123
|
-
project_id=project_id,
|
124
|
-
paging_token=paging_token,
|
125
|
-
count=count,
|
126
|
-
)
|
127
|
-
models = resp.results
|
128
|
-
results.extend(models)
|
129
|
-
if not len(models) or not resp.metadata.next_paging_token:
|
130
|
-
break
|
131
|
-
|
132
|
-
if max_items and len(results) >= max_items:
|
133
|
-
break
|
134
|
-
paging_token = resp.metadata.next_paging_token
|
135
|
-
|
136
|
-
results = results[:max_items] if max_items else results
|
137
|
-
parsed_results = [self._parse_response_model_get(result) for result in results]
|
138
|
-
# get formatted dict with truncated strings for a nicer print
|
139
|
-
models_as_dicts = [
|
140
|
-
self._format_as_dict(model, truncate=True) for model in parsed_results
|
141
|
-
]
|
142
|
-
print("MODELS:")
|
143
|
-
rprint(models_as_dicts)
|
144
|
-
return
|
anyscale/llm/__init__.py
DELETED
anyscale/llm/dataset/__init__.py
DELETED
File without changes
|
@@ -1,63 +0,0 @@
|
|
1
|
-
GET_PY_EXAMPLE = """
|
2
|
-
import anyscale
|
3
|
-
from anyscale.llm.dataset import Dataset
|
4
|
-
|
5
|
-
dataset: Dataset = anyscale.llm.dataset.get("my_first_dataset")
|
6
|
-
print(f"Dataset name: '{dataset.name}'") # Dataset name: 'my_first_dataset'
|
7
|
-
|
8
|
-
# Get the second latest version of the dataset
|
9
|
-
prev_dataset = anyscale.llm.dataset.get("my_first_dataset", version=-1)
|
10
|
-
"""
|
11
|
-
|
12
|
-
GET_PY_ARG_DOCSTRINGS = {
|
13
|
-
"name": "Name of the dataset",
|
14
|
-
"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.",
|
15
|
-
"project": "Name of the Anyscale project that the dataset belongs to. If not provided, all projects will be searched.",
|
16
|
-
}
|
17
|
-
|
18
|
-
UPLOAD_PY_EXAMPLE = """
|
19
|
-
import anyscale
|
20
|
-
|
21
|
-
anyscale.llm.dataset.upload("path/to/my_first_dataset.jsonl", name="my_first_dataset")
|
22
|
-
anyscale.llm.dataset.upload("my_dataset.jsonl", "second_dataset")
|
23
|
-
anyscale.llm.dataset.upload("my_dataset2.jsonl", "second_dataset", description="added 3 lines")
|
24
|
-
"""
|
25
|
-
|
26
|
-
UPLOAD_PY_ARG_DOCSTRINGS = {
|
27
|
-
"dataset_file": "Path to the dataset file to upload.",
|
28
|
-
"name": "Name of a new dataset, or an existing dataset, to upload a new version of.",
|
29
|
-
"description": "Description of the dataset version.",
|
30
|
-
"cloud": "Name of the Anyscale cloud to upload a new dataset to. If not provided, the default cloud will be used.",
|
31
|
-
"project": "Name of the Anyscale project to upload a new dataset to. If not provided, the default project of the cloud will be used.",
|
32
|
-
}
|
33
|
-
|
34
|
-
DOWNLOAD_PY_EXAMPLE = """
|
35
|
-
import anyscale
|
36
|
-
|
37
|
-
dataset_contents: bytes = anyscale.llm.dataset.download("my_first_dataset.jsonl")
|
38
|
-
jsonl_obj = [json.loads(line) for line in dataset_contents.decode().splitlines()]
|
39
|
-
|
40
|
-
prev_dataset_contents = anyscale.llm.dataset.download("my_first_dataset.jsonl", version=-1)
|
41
|
-
"""
|
42
|
-
|
43
|
-
DOWNLOAD_PY_ARG_DOCSTRINGS = {
|
44
|
-
"name": "Name of the dataset to download.",
|
45
|
-
"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.",
|
46
|
-
"project": "Name of the Anyscale project to download the dataset from. If not provided, all projects will be searched.",
|
47
|
-
}
|
48
|
-
|
49
|
-
LIST_PY_EXAMPLE = """
|
50
|
-
import anyscale
|
51
|
-
|
52
|
-
datasets = anyscale.llm.dataset.list(limit=10)
|
53
|
-
for d in datasets:
|
54
|
-
print(f"Dataset name: '{d.name}'") # Prints 10 dataset names
|
55
|
-
"""
|
56
|
-
|
57
|
-
LIST_PY_ARG_DOCSTRINGS = {
|
58
|
-
"limit": "Maximum number of datasets to return. Default: 1000.",
|
59
|
-
"after": "ID of the dataset to start the listing from. If provided, the list will start from the dataset after this ID.",
|
60
|
-
"name_contains": "Filter datasets by name. If provided, only datasets with name containing this string will be returned.",
|
61
|
-
"cloud": "Name of the Anyscale cloud to search in. If not provided, all clouds will be searched.",
|
62
|
-
"project": "Name of the Anyscale project to search in. If not provided, all projects will be searched.",
|
63
|
-
}
|
@@ -1,71 +0,0 @@
|
|
1
|
-
from dataclasses import dataclass, field
|
2
|
-
from datetime import datetime
|
3
|
-
from typing import Optional
|
4
|
-
|
5
|
-
from anyscale._private.models.model_base import ModelBase
|
6
|
-
from anyscale.client.openapi_client.models import Dataset as InternalDataset
|
7
|
-
from anyscale.commands import command_examples
|
8
|
-
from anyscale.llm.dataset._private import docs
|
9
|
-
|
10
|
-
|
11
|
-
@dataclass(frozen=True)
|
12
|
-
class Dataset(ModelBase):
|
13
|
-
"""
|
14
|
-
Metadata about a dataset, which is a file uploaded by a user to their Anyscale cloud.
|
15
|
-
"""
|
16
|
-
|
17
|
-
__ignore_validation__ = True
|
18
|
-
|
19
|
-
__doc_py_example__ = docs.GET_PY_EXAMPLE
|
20
|
-
__doc_cli_example__ = command_examples.LLM_DATASET_GET_EXAMPLE
|
21
|
-
|
22
|
-
id: str = field(metadata={"docstring": "The ID of the dataset."})
|
23
|
-
name: str = field(metadata={"docstring": "The name of the dataset."})
|
24
|
-
filename: str = field(
|
25
|
-
metadata={"docstring": "The file name of the uploaded dataset."}
|
26
|
-
)
|
27
|
-
storage_uri: str = field(
|
28
|
-
metadata={
|
29
|
-
"docstring": "The URI at which the dataset is stored (eg. `s3://bucket/path/to/test.jsonl`)."
|
30
|
-
}
|
31
|
-
)
|
32
|
-
version: int = field(metadata={"docstring": "The version of the dataset."})
|
33
|
-
num_versions: int = field(
|
34
|
-
metadata={"docstring": "Number of versions of the dataset."}
|
35
|
-
)
|
36
|
-
created_at: datetime = field(
|
37
|
-
metadata={"docstring": "The time at which the dataset was uploaded."}
|
38
|
-
)
|
39
|
-
creator_id: str = field(
|
40
|
-
metadata={"docstring": "The ID of the Anyscale user who uploaded the dataset."}
|
41
|
-
)
|
42
|
-
project_id: str = field(
|
43
|
-
metadata={
|
44
|
-
"docstring": "The ID of the Anyscale project that the dataset belongs to."
|
45
|
-
}
|
46
|
-
)
|
47
|
-
cloud_id: str = field(
|
48
|
-
metadata={
|
49
|
-
"docstring": "The ID of the Anyscale cloud that the dataset belongs to."
|
50
|
-
}
|
51
|
-
)
|
52
|
-
description: Optional[str] = field(
|
53
|
-
default=None,
|
54
|
-
metadata={"docstring": "The description of the current dataset version."},
|
55
|
-
)
|
56
|
-
|
57
|
-
@classmethod
|
58
|
-
def parse_from_internal_model(cls, internal_model: InternalDataset) -> "Dataset":
|
59
|
-
return Dataset(
|
60
|
-
id=internal_model.id,
|
61
|
-
name=internal_model.name,
|
62
|
-
filename=internal_model.filename,
|
63
|
-
storage_uri=internal_model.storage_uri,
|
64
|
-
version=internal_model.version,
|
65
|
-
num_versions=internal_model.num_versions,
|
66
|
-
created_at=internal_model.created_at,
|
67
|
-
creator_id=internal_model.creator_id,
|
68
|
-
project_id=internal_model.project_id,
|
69
|
-
cloud_id=internal_model.cloud_id,
|
70
|
-
description=internal_model.description,
|
71
|
-
)
|