clarifai 10.10.1__tar.gz → 10.11.1__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.
Files changed (122) hide show
  1. {clarifai-10.10.1/clarifai.egg-info → clarifai-10.11.1}/PKG-INFO +74 -4
  2. {clarifai-10.10.1 → clarifai-10.11.1}/README.md +71 -0
  3. clarifai-10.11.1/clarifai/__init__.py +1 -0
  4. clarifai-10.11.1/clarifai/cli/model.py +266 -0
  5. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/model.py +1 -1
  6. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/datasets/export/inputs_annotations.py +8 -0
  7. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/rag/rag.py +6 -2
  8. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/runners/dockerfile_template/Dockerfile.template +2 -0
  9. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/runners/models/base_typed_model.py +6 -3
  10. clarifai-10.11.1/clarifai/runners/models/model_run_locally.py +530 -0
  11. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/runners/models/model_upload.py +42 -56
  12. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/runners/server.py +2 -0
  13. clarifai-10.11.1/clarifai/runners/utils/const.py +40 -0
  14. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/runners/utils/url_fetcher.py +19 -12
  15. {clarifai-10.10.1 → clarifai-10.11.1/clarifai.egg-info}/PKG-INFO +74 -4
  16. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai.egg-info/SOURCES.txt +1 -0
  17. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai.egg-info/requires.txt +2 -3
  18. {clarifai-10.10.1 → clarifai-10.11.1}/pyproject.toml +1 -1
  19. {clarifai-10.10.1 → clarifai-10.11.1}/requirements.txt +2 -3
  20. {clarifai-10.10.1 → clarifai-10.11.1}/tests/test_app.py +22 -11
  21. {clarifai-10.10.1 → clarifai-10.11.1}/tests/test_data_upload.py +6 -5
  22. {clarifai-10.10.1 → clarifai-10.11.1}/tests/test_eval.py +6 -5
  23. {clarifai-10.10.1 → clarifai-10.11.1}/tests/test_model_predict.py +26 -35
  24. {clarifai-10.10.1 → clarifai-10.11.1}/tests/test_model_train.py +6 -5
  25. {clarifai-10.10.1 → clarifai-10.11.1}/tests/test_rag.py +8 -2
  26. {clarifai-10.10.1 → clarifai-10.11.1}/tests/test_search.py +18 -4
  27. clarifai-10.10.1/clarifai/__init__.py +0 -1
  28. clarifai-10.10.1/clarifai/cli/model.py +0 -65
  29. clarifai-10.10.1/clarifai/runners/models/model_run_locally.py +0 -190
  30. {clarifai-10.10.1 → clarifai-10.11.1}/LICENSE +0 -0
  31. {clarifai-10.10.1 → clarifai-10.11.1}/MANIFEST.in +0 -0
  32. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/cli/README.md +0 -0
  33. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/cli/__init__.py +0 -0
  34. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/cli/base.py +0 -0
  35. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/cli/compute_cluster.py +0 -0
  36. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/cli/deployment.py +0 -0
  37. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/cli/nodepool.py +0 -0
  38. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/cli.py +0 -0
  39. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/__init__.py +0 -0
  40. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/app.py +0 -0
  41. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/auth/__init__.py +0 -0
  42. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/auth/helper.py +0 -0
  43. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/auth/register.py +0 -0
  44. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/auth/stub.py +0 -0
  45. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/base.py +0 -0
  46. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/compute_cluster.py +0 -0
  47. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/dataset.py +0 -0
  48. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/deployment.py +0 -0
  49. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/input.py +0 -0
  50. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/lister.py +0 -0
  51. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/module.py +0 -0
  52. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/nodepool.py +0 -0
  53. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/search.py +0 -0
  54. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/user.py +0 -0
  55. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/client/workflow.py +0 -0
  56. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/constants/base.py +0 -0
  57. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/constants/dataset.py +0 -0
  58. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/constants/input.py +0 -0
  59. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/constants/model.py +0 -0
  60. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/constants/rag.py +0 -0
  61. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/constants/search.py +0 -0
  62. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/constants/workflow.py +0 -0
  63. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/datasets/__init__.py +0 -0
  64. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/datasets/export/__init__.py +0 -0
  65. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/datasets/upload/__init__.py +0 -0
  66. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/datasets/upload/base.py +0 -0
  67. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/datasets/upload/features.py +0 -0
  68. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/datasets/upload/image.py +0 -0
  69. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/datasets/upload/loaders/README.md +0 -0
  70. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/datasets/upload/loaders/__init__.py +0 -0
  71. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/datasets/upload/loaders/coco_captions.py +0 -0
  72. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/datasets/upload/loaders/coco_detection.py +0 -0
  73. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/datasets/upload/loaders/imagenet_classification.py +0 -0
  74. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/datasets/upload/loaders/xview_detection.py +0 -0
  75. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/datasets/upload/multimodal.py +0 -0
  76. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/datasets/upload/text.py +0 -0
  77. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/datasets/upload/utils.py +0 -0
  78. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/errors.py +0 -0
  79. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/models/__init__.py +0 -0
  80. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/models/api.py +0 -0
  81. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/modules/README.md +0 -0
  82. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/modules/__init__.py +0 -0
  83. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/modules/css.py +0 -0
  84. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/modules/pages.py +0 -0
  85. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/modules/style.css +0 -0
  86. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/rag/__init__.py +0 -0
  87. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/rag/utils.py +0 -0
  88. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/runners/__init__.py +0 -0
  89. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/runners/models/__init__.py +0 -0
  90. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/runners/models/model_class.py +0 -0
  91. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/runners/models/model_runner.py +0 -0
  92. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/runners/models/model_servicer.py +0 -0
  93. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/runners/utils/__init__.py +0 -0
  94. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/runners/utils/data_handler.py +0 -0
  95. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/runners/utils/data_utils.py +0 -0
  96. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/runners/utils/loader.py +0 -0
  97. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/schema/search.py +0 -0
  98. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/urls/helper.py +0 -0
  99. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/utils/__init__.py +0 -0
  100. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/utils/cli.py +0 -0
  101. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/utils/constants.py +0 -0
  102. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/utils/evaluation/__init__.py +0 -0
  103. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/utils/evaluation/helpers.py +0 -0
  104. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/utils/evaluation/main.py +0 -0
  105. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/utils/evaluation/testset_annotation_parser.py +0 -0
  106. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/utils/logging.py +0 -0
  107. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/utils/misc.py +0 -0
  108. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/utils/model_train.py +0 -0
  109. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/versions.py +0 -0
  110. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/workflows/__init__.py +0 -0
  111. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/workflows/export.py +0 -0
  112. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/workflows/utils.py +0 -0
  113. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai/workflows/validate.py +0 -0
  114. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai.egg-info/dependency_links.txt +0 -0
  115. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai.egg-info/entry_points.txt +0 -0
  116. {clarifai-10.10.1 → clarifai-10.11.1}/clarifai.egg-info/top_level.txt +0 -0
  117. {clarifai-10.10.1 → clarifai-10.11.1}/setup.cfg +0 -0
  118. {clarifai-10.10.1 → clarifai-10.11.1}/setup.py +0 -0
  119. {clarifai-10.10.1 → clarifai-10.11.1}/tests/test_auth.py +0 -0
  120. {clarifai-10.10.1 → clarifai-10.11.1}/tests/test_misc.py +0 -0
  121. {clarifai-10.10.1 → clarifai-10.11.1}/tests/test_modules.py +0 -0
  122. {clarifai-10.10.1 → clarifai-10.11.1}/tests/test_stub.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clarifai
3
- Version: 10.10.1
3
+ Version: 10.11.1
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.9.11
24
- Requires-Dist: clarifai-protocol>=0.0.6
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__ = "10.11.1"
@@ -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)
@@ -743,7 +743,7 @@ class Model(Lister, BaseClient):
743
743
  file_bytes = f.read()
744
744
 
745
745
  return self.generate_by_bytes(
746
- filepath=file_bytes,
746
+ input_bytes=file_bytes,
747
747
  input_type=input_type,
748
748
  compute_cluster_id=compute_cluster_id,
749
749
  nodepool_id=nodepool_id,
@@ -165,6 +165,14 @@ class InputAnnotationDownloader:
165
165
  def _save_annotation_to_archive(self, new_archive: zipfile.ZipFile, annot_data: List[Dict],
166
166
  file_name: str) -> None:
167
167
  """Gets the annotation response bytestring (from requests) and append to zip file."""
168
+ # Fill zero values for missing bounding box keys
169
+ for annot in annot_data:
170
+ if annot.get('regionInfo') and annot['regionInfo'].get('boundingBox'):
171
+ bbox = annot['regionInfo']['boundingBox']
172
+ bbox.setdefault('topRow', 0)
173
+ bbox.setdefault('leftCol', 0)
174
+ bbox.setdefault('bottomRow', 0)
175
+ bbox.setdefault('rightCol', 0)
168
176
  # Serialize the dictionary to a JSON string
169
177
  json_str = json.dumps(annot_data)
170
178
  # Convert the JSON string to bytes
@@ -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(app_id=workflow.app_id, base_url=workflow.base, pat=workflow.pat)
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,
@@ -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
@@ -24,7 +24,8 @@ class AnyAnyModel(ModelRunner):
24
24
  list_input_dict = [
25
25
  InputDataHandler.from_proto(input).to_python() for input in input_request.inputs
26
26
  ]
27
- inference_params = json_format.MessageToDict(input_request.model.output_info.params)
27
+ inference_params = json_format.MessageToDict(
28
+ input_request.model.model_version.output_info.params)
28
29
 
29
30
  return list_input_dict, inference_params
30
31
 
@@ -141,7 +142,8 @@ class VisualInputModel(AnyAnyModel):
141
142
  list_input_dict = [
142
143
  InputDataHandler.from_proto(input).image(format="np") for input in input_request.inputs
143
144
  ]
144
- inference_params = json_format.MessageToDict(input_request.model.output_info.params)
145
+ inference_params = json_format.MessageToDict(
146
+ input_request.model.model_version.output_info.params)
145
147
 
146
148
  return list_input_dict, inference_params
147
149
 
@@ -181,7 +183,8 @@ class TextInputModel(AnyAnyModel):
181
183
  def parse_input_request(
182
184
  self, input_request: service_pb2.PostModelOutputsRequest) -> Tuple[List[Dict], Dict]:
183
185
  list_input_text = [InputDataHandler.from_proto(input).text for input in input_request.inputs]
184
- inference_params = json_format.MessageToDict(input_request.model.output_info.params)
186
+ inference_params = json_format.MessageToDict(
187
+ input_request.model.model_version.output_info.params)
185
188
 
186
189
  return list_input_text, inference_params
187
190