clarifai 10.11.0__tar.gz → 11.0.0__tar.gz
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.
- {clarifai-10.11.0/clarifai.egg-info → clarifai-11.0.0}/PKG-INFO +74 -4
- {clarifai-10.11.0 → clarifai-11.0.0}/README.md +71 -0
- clarifai-11.0.0/clarifai/__init__.py +1 -0
- clarifai-11.0.0/clarifai/cli/model.py +266 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/datasets/upload/features.py +1 -1
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/datasets/upload/multimodal.py +2 -1
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/datasets/upload/text.py +3 -2
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/rag/rag.py +6 -2
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/runners/dockerfile_template/Dockerfile.template +2 -0
- clarifai-11.0.0/clarifai/runners/models/model_run_locally.py +530 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/runners/models/model_upload.py +41 -55
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/runners/server.py +2 -0
- clarifai-11.0.0/clarifai/runners/utils/const.py +40 -0
- {clarifai-10.11.0 → clarifai-11.0.0/clarifai.egg-info}/PKG-INFO +74 -4
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai.egg-info/SOURCES.txt +1 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai.egg-info/requires.txt +2 -3
- {clarifai-10.11.0 → clarifai-11.0.0}/requirements.txt +2 -3
- clarifai-10.11.0/clarifai/__init__.py +0 -1
- clarifai-10.11.0/clarifai/cli/model.py +0 -70
- clarifai-10.11.0/clarifai/runners/models/model_run_locally.py +0 -205
- {clarifai-10.11.0 → clarifai-11.0.0}/LICENSE +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/MANIFEST.in +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/cli/README.md +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/cli/__init__.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/cli/base.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/cli/compute_cluster.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/cli/deployment.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/cli/nodepool.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/cli.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/__init__.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/app.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/auth/__init__.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/auth/helper.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/auth/register.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/auth/stub.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/base.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/compute_cluster.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/dataset.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/deployment.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/input.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/lister.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/model.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/module.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/nodepool.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/search.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/user.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/client/workflow.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/constants/base.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/constants/dataset.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/constants/input.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/constants/model.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/constants/rag.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/constants/search.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/constants/workflow.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/datasets/__init__.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/datasets/export/__init__.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/datasets/export/inputs_annotations.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/datasets/upload/__init__.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/datasets/upload/base.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/datasets/upload/image.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/datasets/upload/loaders/README.md +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/datasets/upload/loaders/__init__.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/datasets/upload/loaders/coco_captions.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/datasets/upload/loaders/coco_detection.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/datasets/upload/loaders/imagenet_classification.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/datasets/upload/loaders/xview_detection.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/datasets/upload/utils.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/errors.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/models/__init__.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/models/api.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/modules/README.md +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/modules/__init__.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/modules/css.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/modules/pages.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/modules/style.css +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/rag/__init__.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/rag/utils.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/runners/__init__.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/runners/models/__init__.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/runners/models/base_typed_model.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/runners/models/model_class.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/runners/models/model_runner.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/runners/models/model_servicer.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/runners/utils/__init__.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/runners/utils/data_handler.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/runners/utils/data_utils.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/runners/utils/loader.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/runners/utils/url_fetcher.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/schema/search.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/urls/helper.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/utils/__init__.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/utils/cli.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/utils/constants.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/utils/evaluation/__init__.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/utils/evaluation/helpers.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/utils/evaluation/main.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/utils/evaluation/testset_annotation_parser.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/utils/logging.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/utils/misc.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/utils/model_train.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/versions.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/workflows/__init__.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/workflows/export.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/workflows/utils.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai/workflows/validate.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai.egg-info/dependency_links.txt +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai.egg-info/entry_points.txt +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/clarifai.egg-info/top_level.txt +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/pyproject.toml +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/setup.cfg +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/setup.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/tests/test_app.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/tests/test_auth.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/tests/test_data_upload.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/tests/test_eval.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/tests/test_misc.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/tests/test_model_predict.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/tests/test_model_train.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/tests/test_modules.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/tests/test_rag.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/tests/test_search.py +0 -0
- {clarifai-10.11.0 → clarifai-11.0.0}/tests/test_stub.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: clarifai
|
3
|
-
Version:
|
3
|
+
Version: 11.0.0
|
4
4
|
Summary: Clarifai Python SDK
|
5
5
|
Home-page: https://github.com/Clarifai/clarifai-python
|
6
6
|
Author: Clarifai
|
@@ -20,8 +20,8 @@ Classifier: Operating System :: OS Independent
|
|
20
20
|
Requires-Python: >=3.8
|
21
21
|
Description-Content-Type: text/markdown
|
22
22
|
License-File: LICENSE
|
23
|
-
Requires-Dist: clarifai-grpc>=10.
|
24
|
-
Requires-Dist: clarifai-protocol>=0.0.
|
23
|
+
Requires-Dist: clarifai-grpc>=10.11.2
|
24
|
+
Requires-Dist: clarifai-protocol>=0.0.14
|
25
25
|
Requires-Dist: numpy>=1.22.0
|
26
26
|
Requires-Dist: tqdm>=4.65.0
|
27
27
|
Requires-Dist: tritonclient>=2.34.0
|
@@ -31,7 +31,6 @@ Requires-Dist: schema==0.7.5
|
|
31
31
|
Requires-Dist: Pillow>=9.5.0
|
32
32
|
Requires-Dist: inquirerpy==0.3.4
|
33
33
|
Requires-Dist: tabulate>=0.9.0
|
34
|
-
Requires-Dist: protobuf==5.27.3
|
35
34
|
Requires-Dist: fsspec==2024.6.1
|
36
35
|
Requires-Dist: click==8.1.7
|
37
36
|
Provides-Extra: all
|
@@ -73,6 +72,10 @@ Give the repo a star ⭐
|
|
73
72
|
|
74
73
|
* **[Installation](#rocket-installation)**
|
75
74
|
* **[Getting Started](#memo-getting-started)**
|
75
|
+
* **[Compute Orchestration](#rocket-compute-orchestration)**
|
76
|
+
* [Cluster Operations](#cluster-operations)
|
77
|
+
* [Nodepool Operations](#nodepool-operations)
|
78
|
+
* [Depolyment Operations](#deployment-operations)
|
76
79
|
* **[Interacting with Datasets](#floppy_disk-interacting-with-datasets)**
|
77
80
|
* **[Interacting with Inputs](#floppy_disk-interacting-with-inputs)**
|
78
81
|
* [Input Upload](#input-upload)
|
@@ -157,6 +160,73 @@ client = User(user_id="user_id", pat="your personal access token")
|
|
157
160
|
```
|
158
161
|
|
159
162
|
|
163
|
+
## :rocket: Compute Orchestration
|
164
|
+
|
165
|
+
Clarifai’s Compute Orchestration offers a streamlined solution for managing the infrastructure required for training, deploying, and scaling machine learning models and workflows.
|
166
|
+
|
167
|
+
This flexible system supports any compute instance — across various hardware providers and deployment methods — and provides automatic scaling to match workload demands. [More Details](https://www.clarifai.com/products/compute-orchestration)
|
168
|
+
|
169
|
+
#### Cluster Operations
|
170
|
+
```python
|
171
|
+
from clarifai.client.user import User
|
172
|
+
client = User(user_id="user_id",base_url="https://api.clarifai.com")
|
173
|
+
|
174
|
+
# Create a new compute cluster
|
175
|
+
compute_cluster = client.create_compute_cluster(compute_cluster_id="demo-id",config_filepath="computer_cluster_config.yaml")
|
176
|
+
|
177
|
+
# List Clusters
|
178
|
+
all_compute_clusters = list(client.list_compute_clusters())
|
179
|
+
print(all_compute_clusters)
|
180
|
+
```
|
181
|
+
##### [Example Cluster Config](https://github.com/Clarifai/examples/blob/main/ComputeOrchestration/configs/compute_cluster_config.yaml)
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
#### Nodepool Operations
|
186
|
+
```python
|
187
|
+
from clarifai.client.compute_cluster import ComputeCluster
|
188
|
+
|
189
|
+
# Initialize the ComputeCluster instance
|
190
|
+
compute_cluster = ComputeCluster(user_id="user_id",compute_cluster_id="demo-id")
|
191
|
+
|
192
|
+
# Create a new nodepool
|
193
|
+
nodepool = compute_cluster.create_nodepool(nodepool_id="demo-nodepool-id",config_filepath="nodepool_config.yaml")
|
194
|
+
|
195
|
+
#Get a nodepool
|
196
|
+
nodepool = compute_cluster.nodepool(nodepool_id="demo-nodepool-id")
|
197
|
+
print(nodepool)
|
198
|
+
|
199
|
+
# List nodepools
|
200
|
+
all_nodepools = list(compute_cluster.list_nodepools())
|
201
|
+
print(all_nodepools)
|
202
|
+
```
|
203
|
+
##### [Example Nodepool config](https://github.com/Clarifai/examples/blob/main/ComputeOrchestration/configs/nodepool_config.yaml)
|
204
|
+
|
205
|
+
#### Deployment Operations
|
206
|
+
```python
|
207
|
+
from clarifai.client.nodepool import Nodepool
|
208
|
+
|
209
|
+
# Initialize the Nodepool instance
|
210
|
+
nodepool = Nodepool(user_id="user_id",nodepool_id="demo-nodepool-id")
|
211
|
+
|
212
|
+
# Create a new deployment
|
213
|
+
deployment = nodepool.create_deployment(deployment_id="demo-deployment-id",config_filepath="deployment_config.yaml")
|
214
|
+
|
215
|
+
#Get a deployment
|
216
|
+
deployment = nodepool.deployment(nodepool_id="demo-deployment-id")
|
217
|
+
print(deployment)
|
218
|
+
|
219
|
+
# List deployments
|
220
|
+
all_deployments = list(nodepool.list_deployments())
|
221
|
+
print(all_deployments)
|
222
|
+
|
223
|
+
```
|
224
|
+
##### [Example Deployment config](https://github.com/Clarifai/examples/blob/main/ComputeOrchestration/configs/deployment_config.yaml)
|
225
|
+
|
226
|
+
#### Compute Orchestration CLI Operations
|
227
|
+
Refer Here: https://github.com/Clarifai/clarifai-python/tree/master/clarifai/cli
|
228
|
+
|
229
|
+
|
160
230
|
## :floppy_disk: Interacting with Datasets
|
161
231
|
|
162
232
|
Clarifai datasets help in managing datasets used for model training and evaluation. It provides functionalities like creating datasets,uploading datasets, retrying failed uploads from logs and exporting datasets as .zip files.
|
@@ -34,6 +34,10 @@ Give the repo a star ⭐
|
|
34
34
|
|
35
35
|
* **[Installation](#rocket-installation)**
|
36
36
|
* **[Getting Started](#memo-getting-started)**
|
37
|
+
* **[Compute Orchestration](#rocket-compute-orchestration)**
|
38
|
+
* [Cluster Operations](#cluster-operations)
|
39
|
+
* [Nodepool Operations](#nodepool-operations)
|
40
|
+
* [Depolyment Operations](#deployment-operations)
|
37
41
|
* **[Interacting with Datasets](#floppy_disk-interacting-with-datasets)**
|
38
42
|
* **[Interacting with Inputs](#floppy_disk-interacting-with-inputs)**
|
39
43
|
* [Input Upload](#input-upload)
|
@@ -118,6 +122,73 @@ client = User(user_id="user_id", pat="your personal access token")
|
|
118
122
|
```
|
119
123
|
|
120
124
|
|
125
|
+
## :rocket: Compute Orchestration
|
126
|
+
|
127
|
+
Clarifai’s Compute Orchestration offers a streamlined solution for managing the infrastructure required for training, deploying, and scaling machine learning models and workflows.
|
128
|
+
|
129
|
+
This flexible system supports any compute instance — across various hardware providers and deployment methods — and provides automatic scaling to match workload demands. [More Details](https://www.clarifai.com/products/compute-orchestration)
|
130
|
+
|
131
|
+
#### Cluster Operations
|
132
|
+
```python
|
133
|
+
from clarifai.client.user import User
|
134
|
+
client = User(user_id="user_id",base_url="https://api.clarifai.com")
|
135
|
+
|
136
|
+
# Create a new compute cluster
|
137
|
+
compute_cluster = client.create_compute_cluster(compute_cluster_id="demo-id",config_filepath="computer_cluster_config.yaml")
|
138
|
+
|
139
|
+
# List Clusters
|
140
|
+
all_compute_clusters = list(client.list_compute_clusters())
|
141
|
+
print(all_compute_clusters)
|
142
|
+
```
|
143
|
+
##### [Example Cluster Config](https://github.com/Clarifai/examples/blob/main/ComputeOrchestration/configs/compute_cluster_config.yaml)
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
#### Nodepool Operations
|
148
|
+
```python
|
149
|
+
from clarifai.client.compute_cluster import ComputeCluster
|
150
|
+
|
151
|
+
# Initialize the ComputeCluster instance
|
152
|
+
compute_cluster = ComputeCluster(user_id="user_id",compute_cluster_id="demo-id")
|
153
|
+
|
154
|
+
# Create a new nodepool
|
155
|
+
nodepool = compute_cluster.create_nodepool(nodepool_id="demo-nodepool-id",config_filepath="nodepool_config.yaml")
|
156
|
+
|
157
|
+
#Get a nodepool
|
158
|
+
nodepool = compute_cluster.nodepool(nodepool_id="demo-nodepool-id")
|
159
|
+
print(nodepool)
|
160
|
+
|
161
|
+
# List nodepools
|
162
|
+
all_nodepools = list(compute_cluster.list_nodepools())
|
163
|
+
print(all_nodepools)
|
164
|
+
```
|
165
|
+
##### [Example Nodepool config](https://github.com/Clarifai/examples/blob/main/ComputeOrchestration/configs/nodepool_config.yaml)
|
166
|
+
|
167
|
+
#### Deployment Operations
|
168
|
+
```python
|
169
|
+
from clarifai.client.nodepool import Nodepool
|
170
|
+
|
171
|
+
# Initialize the Nodepool instance
|
172
|
+
nodepool = Nodepool(user_id="user_id",nodepool_id="demo-nodepool-id")
|
173
|
+
|
174
|
+
# Create a new deployment
|
175
|
+
deployment = nodepool.create_deployment(deployment_id="demo-deployment-id",config_filepath="deployment_config.yaml")
|
176
|
+
|
177
|
+
#Get a deployment
|
178
|
+
deployment = nodepool.deployment(nodepool_id="demo-deployment-id")
|
179
|
+
print(deployment)
|
180
|
+
|
181
|
+
# List deployments
|
182
|
+
all_deployments = list(nodepool.list_deployments())
|
183
|
+
print(all_deployments)
|
184
|
+
|
185
|
+
```
|
186
|
+
##### [Example Deployment config](https://github.com/Clarifai/examples/blob/main/ComputeOrchestration/configs/deployment_config.yaml)
|
187
|
+
|
188
|
+
#### Compute Orchestration CLI Operations
|
189
|
+
Refer Here: https://github.com/Clarifai/clarifai-python/tree/master/clarifai/cli
|
190
|
+
|
191
|
+
|
121
192
|
## :floppy_disk: Interacting with Datasets
|
122
193
|
|
123
194
|
Clarifai datasets help in managing datasets used for model training and evaluation. It provides functionalities like creating datasets,uploading datasets, retrying failed uploads from logs and exporting datasets as .zip files.
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "11.0.0"
|
@@ -0,0 +1,266 @@
|
|
1
|
+
import click
|
2
|
+
|
3
|
+
from clarifai.cli.base import cli
|
4
|
+
|
5
|
+
|
6
|
+
@cli.group(['model'])
|
7
|
+
def model():
|
8
|
+
"""Manage models: upload, test locally, run_locally, predict"""
|
9
|
+
pass
|
10
|
+
|
11
|
+
|
12
|
+
@model.command()
|
13
|
+
@click.option(
|
14
|
+
'--model_path',
|
15
|
+
type=click.Path(exists=True),
|
16
|
+
required=True,
|
17
|
+
help='Path to the model directory.')
|
18
|
+
@click.option(
|
19
|
+
'--download_checkpoints',
|
20
|
+
is_flag=True,
|
21
|
+
help=
|
22
|
+
'Flag to download checkpoints before uploading and including them in the tar file that is uploaded. Defaults to False, which will attempt to download them at docker build time.',
|
23
|
+
)
|
24
|
+
@click.option(
|
25
|
+
'--skip_dockerfile',
|
26
|
+
is_flag=True,
|
27
|
+
help=
|
28
|
+
'Flag to skip generating a dockerfile so that you can manually edit an already created dockerfile.',
|
29
|
+
)
|
30
|
+
def upload(model_path, download_checkpoints, skip_dockerfile):
|
31
|
+
"""Upload a model to Clarifai."""
|
32
|
+
from clarifai.runners.models import model_upload
|
33
|
+
|
34
|
+
model_upload.main(model_path, download_checkpoints, skip_dockerfile)
|
35
|
+
|
36
|
+
|
37
|
+
@model.command()
|
38
|
+
@click.option(
|
39
|
+
'--model_path',
|
40
|
+
type=click.Path(exists=True),
|
41
|
+
required=True,
|
42
|
+
help='Path to the model directory.')
|
43
|
+
@click.option(
|
44
|
+
'--mode',
|
45
|
+
type=click.Choice(['env', 'container'], case_sensitive=False),
|
46
|
+
default='env',
|
47
|
+
show_default=True,
|
48
|
+
help=
|
49
|
+
'Specify how to test the model locally: "env" for virtual environment or "container" for Docker container. Defaults to "env".'
|
50
|
+
)
|
51
|
+
@click.option(
|
52
|
+
'--keep_env',
|
53
|
+
is_flag=True,
|
54
|
+
help=
|
55
|
+
'Keep the virtual environment after testing the model locally (applicable for virtualenv mode). Defaults to False.'
|
56
|
+
)
|
57
|
+
@click.option(
|
58
|
+
'--keep_image',
|
59
|
+
is_flag=True,
|
60
|
+
help=
|
61
|
+
'Keep the Docker image after testing the model locally (applicable for container mode). Defaults to False.'
|
62
|
+
)
|
63
|
+
def test_locally(model_path, keep_env=False, keep_image=False, mode='env'):
|
64
|
+
"""Test model locally."""
|
65
|
+
try:
|
66
|
+
from clarifai.runners.models import model_run_locally
|
67
|
+
if mode == 'env' and keep_image:
|
68
|
+
raise ValueError("'keep_image' is applicable only for 'container' mode")
|
69
|
+
if mode == 'container' and keep_env:
|
70
|
+
raise ValueError("'keep_env' is applicable only for 'env' mode")
|
71
|
+
|
72
|
+
if mode == "env":
|
73
|
+
click.echo("Testing model locally in a virtual environment...")
|
74
|
+
model_run_locally.main(model_path, run_model_server=False, keep_env=keep_env)
|
75
|
+
elif mode == "container":
|
76
|
+
click.echo("Testing model locally inside a container...")
|
77
|
+
model_run_locally.main(
|
78
|
+
model_path, inside_container=True, run_model_server=False, keep_image=keep_image)
|
79
|
+
click.echo("Model tested successfully.")
|
80
|
+
except Exception as e:
|
81
|
+
click.echo(f"Failed to test model locally: {e}", err=True)
|
82
|
+
|
83
|
+
|
84
|
+
@model.command()
|
85
|
+
@click.option(
|
86
|
+
'--model_path',
|
87
|
+
type=click.Path(exists=True),
|
88
|
+
required=True,
|
89
|
+
help='Path to the model directory.')
|
90
|
+
@click.option(
|
91
|
+
'--port',
|
92
|
+
'-p',
|
93
|
+
type=int,
|
94
|
+
default=8000,
|
95
|
+
show_default=True,
|
96
|
+
help="The port to host the gRPC server for running the model locally. Defaults to 8000.")
|
97
|
+
@click.option(
|
98
|
+
'--mode',
|
99
|
+
type=click.Choice(['env', 'container'], case_sensitive=False),
|
100
|
+
default='env',
|
101
|
+
show_default=True,
|
102
|
+
help=
|
103
|
+
'Specifies how to run the model: "env" for virtual environment or "container" for Docker container. Defaults to "env".'
|
104
|
+
)
|
105
|
+
@click.option(
|
106
|
+
'--keep_env',
|
107
|
+
is_flag=True,
|
108
|
+
help=
|
109
|
+
'Keep the virtual environment after testing the model locally (applicable for virtualenv mode). Defaults to False.'
|
110
|
+
)
|
111
|
+
@click.option(
|
112
|
+
'--keep_image',
|
113
|
+
is_flag=True,
|
114
|
+
help=
|
115
|
+
'Keep the Docker image after testing the model locally (applicable for container mode). Defaults to False.'
|
116
|
+
)
|
117
|
+
def run_locally(model_path, port, mode, keep_env, keep_image):
|
118
|
+
"""Run the model locally and start a gRPC server to serve the model."""
|
119
|
+
try:
|
120
|
+
from clarifai.runners.models import model_run_locally
|
121
|
+
if mode == 'env' and keep_image:
|
122
|
+
raise ValueError("'keep_image' is applicable only for 'container' mode")
|
123
|
+
if mode == 'container' and keep_env:
|
124
|
+
raise ValueError("'keep_env' is applicable only for 'env' mode")
|
125
|
+
|
126
|
+
if mode == "env":
|
127
|
+
click.echo("Running model locally in a virtual environment...")
|
128
|
+
model_run_locally.main(model_path, run_model_server=True, keep_env=keep_env, port=port)
|
129
|
+
elif mode == "container":
|
130
|
+
click.echo("Running model locally inside a container...")
|
131
|
+
model_run_locally.main(
|
132
|
+
model_path,
|
133
|
+
inside_container=True,
|
134
|
+
run_model_server=True,
|
135
|
+
port=port,
|
136
|
+
keep_image=keep_image)
|
137
|
+
click.echo(f"Model server started locally from {model_path} in {mode} mode.")
|
138
|
+
except Exception as e:
|
139
|
+
click.echo(f"Failed to starts model server locally: {e}", err=True)
|
140
|
+
|
141
|
+
|
142
|
+
@model.command()
|
143
|
+
@click.option(
|
144
|
+
'--config',
|
145
|
+
type=click.Path(exists=True),
|
146
|
+
required=False,
|
147
|
+
help='Path to the model predict config file.')
|
148
|
+
@click.option('--model_id', required=False, help='Model ID of the model used to predict.')
|
149
|
+
@click.option('--user_id', required=False, help='User ID of the model used to predict.')
|
150
|
+
@click.option('--app_id', required=False, help='App ID of the model used to predict.')
|
151
|
+
@click.option('--model_url', required=False, help='Model URL of the model used to predict.')
|
152
|
+
@click.option('--file_path', required=False, help='File path of file for the model to predict')
|
153
|
+
@click.option('--url', required=False, help='URL to the file for the model to predict')
|
154
|
+
@click.option('--bytes', required=False, help='Bytes to the file for the model to predict')
|
155
|
+
@click.option(
|
156
|
+
'--input_id', required=False, help='Existing input id in the app for the model to predict')
|
157
|
+
@click.option('--input_type', required=False, help='Type of input')
|
158
|
+
@click.option(
|
159
|
+
'-cc_id',
|
160
|
+
'--compute_cluster_id',
|
161
|
+
required=False,
|
162
|
+
help='Compute Cluster ID to use for the model')
|
163
|
+
@click.option('-np_id', '--nodepool_id', required=False, help='Nodepool ID to use for the model')
|
164
|
+
@click.option(
|
165
|
+
'-dpl_id', '--deployment_id', required=False, help='Deployment ID to use for the model')
|
166
|
+
@click.option(
|
167
|
+
'--inference_params', required=False, default='{}', help='Inference parameters to override')
|
168
|
+
@click.option('--output_config', required=False, default='{}', help='Output config to override')
|
169
|
+
@click.pass_context
|
170
|
+
def predict(ctx, config, model_id, user_id, app_id, model_url, file_path, url, bytes, input_id,
|
171
|
+
input_type, compute_cluster_id, nodepool_id, deployment_id, inference_params,
|
172
|
+
output_config):
|
173
|
+
"""Predict using the given model"""
|
174
|
+
import json
|
175
|
+
|
176
|
+
from clarifai.client.deployment import Deployment
|
177
|
+
from clarifai.client.input import Input
|
178
|
+
from clarifai.client.model import Model
|
179
|
+
from clarifai.client.nodepool import Nodepool
|
180
|
+
from clarifai.utils.cli import from_yaml
|
181
|
+
if config:
|
182
|
+
config = from_yaml(config)
|
183
|
+
model_id, user_id, app_id, model_url, file_path, url, bytes, input_id, input_type, compute_cluster_id, nodepool_id, deployment_id, inference_params, output_config = (
|
184
|
+
config.get(k, v)
|
185
|
+
for k, v in [('model_id', model_id), ('user_id', user_id), ('app_id', app_id), (
|
186
|
+
'model_url', model_url), ('file_path', file_path), ('url', url), ('bytes', bytes), (
|
187
|
+
'input_id',
|
188
|
+
input_id), ('input_type',
|
189
|
+
input_type), ('compute_cluster_id',
|
190
|
+
compute_cluster_id), ('nodepool_id', nodepool_id), (
|
191
|
+
'deployment_id',
|
192
|
+
deployment_id), ('inference_params',
|
193
|
+
inference_params), ('output_config',
|
194
|
+
output_config)])
|
195
|
+
if sum([opt[1] for opt in [(model_id, 1), (user_id, 1), (app_id, 1), (model_url, 3)]
|
196
|
+
if opt[0]]) != 3:
|
197
|
+
raise ValueError("Either --model_id & --user_id & --app_id or --model_url must be provided.")
|
198
|
+
if sum([1 for opt in [file_path, url, bytes, input_id] if opt]) != 1:
|
199
|
+
raise ValueError("Exactly one of --file_path, --url, --bytes or --input_id must be provided.")
|
200
|
+
if compute_cluster_id or nodepool_id or deployment_id:
|
201
|
+
if sum([
|
202
|
+
opt[1] for opt in [(compute_cluster_id, 0.5), (nodepool_id, 0.5), (deployment_id, 1)]
|
203
|
+
if opt[0]
|
204
|
+
]) != 1:
|
205
|
+
raise ValueError(
|
206
|
+
"Either --compute_cluster_id & --nodepool_id or --deployment_id must be provided.")
|
207
|
+
if model_url:
|
208
|
+
model = Model(url=model_url, pat=ctx.obj['pat'], base_url=ctx.obj['base_url'])
|
209
|
+
else:
|
210
|
+
model = Model(
|
211
|
+
model_id=model_id,
|
212
|
+
user_id=user_id,
|
213
|
+
app_id=app_id,
|
214
|
+
pat=ctx.obj['pat'],
|
215
|
+
base_url=ctx.obj['base_url'])
|
216
|
+
|
217
|
+
if inference_params:
|
218
|
+
inference_params = json.loads(inference_params)
|
219
|
+
if output_config:
|
220
|
+
output_config = json.loads(output_config)
|
221
|
+
|
222
|
+
if file_path:
|
223
|
+
model_prediction = model.predict_by_filepath(
|
224
|
+
filepath=file_path,
|
225
|
+
input_type=input_type,
|
226
|
+
compute_cluster_id=compute_cluster_id,
|
227
|
+
nodepool_id=nodepool_id,
|
228
|
+
deployment_id=deployment_id,
|
229
|
+
inference_params=inference_params,
|
230
|
+
output_config=output_config)
|
231
|
+
elif url:
|
232
|
+
model_prediction = model.predict_by_url(
|
233
|
+
url=url,
|
234
|
+
input_type=input_type,
|
235
|
+
compute_cluster_id=compute_cluster_id,
|
236
|
+
nodepool_id=nodepool_id,
|
237
|
+
deployment_id=deployment_id,
|
238
|
+
inference_params=inference_params,
|
239
|
+
output_config=output_config)
|
240
|
+
elif bytes:
|
241
|
+
bytes = str.encode(bytes)
|
242
|
+
model_prediction = model.predict_by_bytes(
|
243
|
+
input_bytes=bytes,
|
244
|
+
input_type=input_type,
|
245
|
+
compute_cluster_id=compute_cluster_id,
|
246
|
+
nodepool_id=nodepool_id,
|
247
|
+
deployment_id=deployment_id,
|
248
|
+
inference_params=inference_params,
|
249
|
+
output_config=output_config)
|
250
|
+
elif input_id:
|
251
|
+
inputs = [Input.get_input(input_id)]
|
252
|
+
runner_selector = None
|
253
|
+
if deployment_id:
|
254
|
+
runner_selector = Deployment.get_runner_selector(
|
255
|
+
user_id=ctx.obj['user_id'], deployment_id=deployment_id)
|
256
|
+
elif compute_cluster_id and nodepool_id:
|
257
|
+
runner_selector = Nodepool.get_runner_selector(
|
258
|
+
user_id=ctx.obj['user_id'],
|
259
|
+
compute_cluster_id=compute_cluster_id,
|
260
|
+
nodepool_id=nodepool_id)
|
261
|
+
model_prediction = model.predict(
|
262
|
+
inputs=inputs,
|
263
|
+
runner_selector=runner_selector,
|
264
|
+
inference_params=inference_params,
|
265
|
+
output_config=output_config)
|
266
|
+
click.echo(model_prediction)
|
@@ -7,7 +7,7 @@ from typing import List, Optional, Union
|
|
7
7
|
class TextFeatures:
|
8
8
|
"""Text classification datasets preprocessing output features."""
|
9
9
|
text: str
|
10
|
-
labels: List[Union[str, int]] # List[str or int] to cater for multi-class tasks
|
10
|
+
labels: List[Union[str, int]] = None # List[str or int] to cater for multi-class tasks
|
11
11
|
id: Optional[int] = None # text_id
|
12
12
|
metadata: Optional[dict] = None
|
13
13
|
label_ids: Optional[List[str]] = None
|
@@ -34,7 +34,8 @@ class MultiModalDataset(ClarifaiDataset):
|
|
34
34
|
metadata = Struct()
|
35
35
|
image_bytes = data_item.image_bytes
|
36
36
|
text = data_item.text
|
37
|
-
labels = data_item.labels if
|
37
|
+
labels = data_item.labels if ((data_item.labels is None) or
|
38
|
+
isinstance(data_item.labels, list)) else [data_item.labels]
|
38
39
|
input_id = f"{self.dataset_id}-{id}" if data_item.id is None else f"{self.dataset_id}-{str(data_item.id)}"
|
39
40
|
if data_item.metadata is not None:
|
40
41
|
metadata.update(data_item.metadata)
|
@@ -34,8 +34,9 @@ class TextClassificationDataset(ClarifaiDataset):
|
|
34
34
|
data_item = self.data_generator[id]
|
35
35
|
metadata = Struct()
|
36
36
|
text = data_item.text
|
37
|
-
labels = data_item.labels if
|
38
|
-
|
37
|
+
labels = data_item.labels if ((data_item.labels is None) or
|
38
|
+
isinstance(data_item.labels, list)) else [data_item.labels
|
39
|
+
] # clarifai concept
|
39
40
|
label_ids = data_item.label_ids
|
40
41
|
input_id = f"{self.dataset_id}-{get_uuid(8)}" if data_item.id is None else f"{self.dataset_id}-{str(data_item.id)}"
|
41
42
|
if data_item.metadata is not None:
|
@@ -45,10 +45,14 @@ class RAG:
|
|
45
45
|
self.logger.info("workflow_url:%s", workflow_url)
|
46
46
|
w = Workflow(workflow_url, base_url=base_url, pat=pat)
|
47
47
|
self._prompt_workflow = w
|
48
|
-
self._app = App(app_id=w.app_id, base_url=w.base, pat=w.pat)
|
48
|
+
self._app = App(app_id=w.app_id, user_id=w.user_id, base_url=w.base, pat=w.pat)
|
49
49
|
elif workflow_url is None and workflow is not None:
|
50
50
|
self._prompt_workflow = workflow
|
51
|
-
self._app = App(
|
51
|
+
self._app = App(
|
52
|
+
app_id=workflow.app_id,
|
53
|
+
user_id=workflow.user_id,
|
54
|
+
base_url=workflow.base,
|
55
|
+
pat=workflow.pat)
|
52
56
|
|
53
57
|
@classmethod
|
54
58
|
def setup(cls,
|
{clarifai-10.11.0 → clarifai-11.0.0}/clarifai/runners/dockerfile_template/Dockerfile.template
RENAMED
@@ -22,6 +22,8 @@ ENV CLARIFAI_API_BASE=${CLARIFAI_API_BASE}
|
|
22
22
|
|
23
23
|
# Set the NUMBA cache dir to /tmp
|
24
24
|
ENV NUMBA_CACHE_DIR=/tmp/numba_cache
|
25
|
+
# Set the TORCHINDUCTOR cache dir to /tmp
|
26
|
+
ENV TORCHINDUCTOR_CACHE_DIR=/tmp/torchinductor_cache
|
25
27
|
ENV HOME=/tmp
|
26
28
|
|
27
29
|
# Set the working directory to /app
|