clarifai 10.9.2__tar.gz → 10.9.5__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 (117) hide show
  1. {clarifai-10.9.2/clarifai.egg-info → clarifai-10.9.5}/PKG-INFO +15 -11
  2. {clarifai-10.9.2 → clarifai-10.9.5}/README.md +12 -9
  3. clarifai-10.9.5/clarifai/__init__.py +1 -0
  4. clarifai-10.9.5/clarifai/cli/base.py +74 -0
  5. clarifai-10.9.5/clarifai/cli/model.py +65 -0
  6. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/auth/helper.py +10 -3
  7. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/input.py +3 -3
  8. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/model.py +101 -73
  9. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/workflow.py +48 -8
  10. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/datasets/export/inputs_annotations.py +4 -2
  11. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/datasets/upload/utils.py +1 -1
  12. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/runners/models/model_run_locally.py +6 -12
  13. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/runners/models/model_servicer.py +3 -3
  14. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/runners/models/model_upload.py +2 -25
  15. clarifai-10.9.5/clarifai/utils/cli.py +45 -0
  16. clarifai-10.9.5/clarifai/workflows/__init__.py +0 -0
  17. {clarifai-10.9.2 → clarifai-10.9.5/clarifai.egg-info}/PKG-INFO +15 -11
  18. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai.egg-info/SOURCES.txt +4 -0
  19. clarifai-10.9.5/clarifai.egg-info/entry_points.txt +2 -0
  20. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai.egg-info/requires.txt +2 -1
  21. {clarifai-10.9.2 → clarifai-10.9.5}/requirements.txt +2 -1
  22. {clarifai-10.9.2 → clarifai-10.9.5}/setup.py +1 -1
  23. {clarifai-10.9.2 → clarifai-10.9.5}/tests/test_data_upload.py +5 -5
  24. {clarifai-10.9.2 → clarifai-10.9.5}/tests/test_model_predict.py +2 -2
  25. clarifai-10.9.2/clarifai/__init__.py +0 -1
  26. clarifai-10.9.2/clarifai.egg-info/entry_points.txt +0 -2
  27. {clarifai-10.9.2 → clarifai-10.9.5}/LICENSE +0 -0
  28. {clarifai-10.9.2 → clarifai-10.9.5}/MANIFEST.in +0 -0
  29. {clarifai-10.9.2/clarifai/datasets → clarifai-10.9.5/clarifai/cli}/__init__.py +0 -0
  30. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/cli.py +0 -0
  31. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/__init__.py +0 -0
  32. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/app.py +0 -0
  33. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/auth/__init__.py +0 -0
  34. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/auth/register.py +0 -0
  35. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/auth/stub.py +0 -0
  36. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/base.py +0 -0
  37. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/compute_cluster.py +0 -0
  38. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/dataset.py +0 -0
  39. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/deployment.py +0 -0
  40. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/lister.py +0 -0
  41. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/module.py +0 -0
  42. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/nodepool.py +0 -0
  43. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/search.py +0 -0
  44. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/client/user.py +0 -0
  45. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/constants/base.py +0 -0
  46. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/constants/dataset.py +0 -0
  47. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/constants/input.py +0 -0
  48. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/constants/model.py +0 -0
  49. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/constants/rag.py +0 -0
  50. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/constants/search.py +0 -0
  51. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/constants/workflow.py +0 -0
  52. {clarifai-10.9.2/clarifai/datasets/export → clarifai-10.9.5/clarifai/datasets}/__init__.py +0 -0
  53. {clarifai-10.9.2/clarifai/datasets/upload → clarifai-10.9.5/clarifai/datasets/export}/__init__.py +0 -0
  54. {clarifai-10.9.2/clarifai/datasets/upload/loaders → clarifai-10.9.5/clarifai/datasets/upload}/__init__.py +0 -0
  55. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/datasets/upload/base.py +0 -0
  56. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/datasets/upload/features.py +0 -0
  57. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/datasets/upload/image.py +0 -0
  58. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/datasets/upload/loaders/README.md +0 -0
  59. {clarifai-10.9.2/clarifai/models → clarifai-10.9.5/clarifai/datasets/upload/loaders}/__init__.py +0 -0
  60. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/datasets/upload/loaders/coco_captions.py +0 -0
  61. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/datasets/upload/loaders/coco_detection.py +0 -0
  62. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/datasets/upload/loaders/imagenet_classification.py +0 -0
  63. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/datasets/upload/loaders/xview_detection.py +0 -0
  64. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/datasets/upload/multimodal.py +0 -0
  65. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/datasets/upload/text.py +0 -0
  66. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/errors.py +0 -0
  67. {clarifai-10.9.2/clarifai/modules → clarifai-10.9.5/clarifai/models}/__init__.py +0 -0
  68. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/models/api.py +0 -0
  69. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/modules/README.md +0 -0
  70. {clarifai-10.9.2/clarifai/runners/models → clarifai-10.9.5/clarifai/modules}/__init__.py +0 -0
  71. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/modules/css.py +0 -0
  72. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/modules/pages.py +0 -0
  73. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/modules/style.css +0 -0
  74. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/rag/__init__.py +0 -0
  75. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/rag/rag.py +0 -0
  76. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/rag/utils.py +0 -0
  77. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/runners/__init__.py +0 -0
  78. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/runners/dockerfile_template/Dockerfile.cpu.template +0 -0
  79. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/runners/dockerfile_template/Dockerfile.cuda.template +0 -0
  80. {clarifai-10.9.2/clarifai/runners/utils → clarifai-10.9.5/clarifai/runners/models}/__init__.py +0 -0
  81. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/runners/models/base_typed_model.py +0 -0
  82. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/runners/models/model_class.py +0 -0
  83. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/runners/models/model_runner.py +0 -0
  84. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/runners/server.py +0 -0
  85. {clarifai-10.9.2/clarifai → clarifai-10.9.5/clarifai/runners}/utils/__init__.py +0 -0
  86. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/runners/utils/data_handler.py +0 -0
  87. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/runners/utils/data_utils.py +0 -0
  88. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/runners/utils/loader.py +0 -0
  89. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/runners/utils/url_fetcher.py +0 -0
  90. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/schema/search.py +0 -0
  91. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/urls/helper.py +0 -0
  92. {clarifai-10.9.2/clarifai/workflows → clarifai-10.9.5/clarifai/utils}/__init__.py +0 -0
  93. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/utils/constants.py +0 -0
  94. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/utils/evaluation/__init__.py +0 -0
  95. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/utils/evaluation/helpers.py +0 -0
  96. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/utils/evaluation/main.py +0 -0
  97. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/utils/evaluation/testset_annotation_parser.py +0 -0
  98. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/utils/logging.py +0 -0
  99. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/utils/misc.py +0 -0
  100. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/utils/model_train.py +0 -0
  101. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/versions.py +0 -0
  102. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/workflows/export.py +0 -0
  103. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/workflows/utils.py +0 -0
  104. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai/workflows/validate.py +0 -0
  105. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai.egg-info/dependency_links.txt +0 -0
  106. {clarifai-10.9.2 → clarifai-10.9.5}/clarifai.egg-info/top_level.txt +0 -0
  107. {clarifai-10.9.2 → clarifai-10.9.5}/pyproject.toml +0 -0
  108. {clarifai-10.9.2 → clarifai-10.9.5}/setup.cfg +0 -0
  109. {clarifai-10.9.2 → clarifai-10.9.5}/tests/test_app.py +0 -0
  110. {clarifai-10.9.2 → clarifai-10.9.5}/tests/test_auth.py +0 -0
  111. {clarifai-10.9.2 → clarifai-10.9.5}/tests/test_eval.py +0 -0
  112. {clarifai-10.9.2 → clarifai-10.9.5}/tests/test_misc.py +0 -0
  113. {clarifai-10.9.2 → clarifai-10.9.5}/tests/test_model_train.py +0 -0
  114. {clarifai-10.9.2 → clarifai-10.9.5}/tests/test_modules.py +0 -0
  115. {clarifai-10.9.2 → clarifai-10.9.5}/tests/test_rag.py +0 -0
  116. {clarifai-10.9.2 → clarifai-10.9.5}/tests/test_search.py +0 -0
  117. {clarifai-10.9.2 → clarifai-10.9.5}/tests/test_stub.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clarifai
3
- Version: 10.9.2
3
+ Version: 10.9.5
4
4
  Summary: Clarifai Python SDK
5
5
  Home-page: https://github.com/Clarifai/clarifai-python
6
6
  Author: Clarifai
@@ -20,7 +20,7 @@ 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.4
23
+ Requires-Dist: clarifai-grpc>=10.9.11
24
24
  Requires-Dist: clarifai-protocol>=0.0.6
25
25
  Requires-Dist: numpy>=1.22.0
26
26
  Requires-Dist: tqdm>=4.65.0
@@ -33,15 +33,17 @@ Requires-Dist: inquirerpy==0.3.4
33
33
  Requires-Dist: tabulate>=0.9.0
34
34
  Requires-Dist: protobuf==5.27.3
35
35
  Requires-Dist: fsspec==2024.6.1
36
+ Requires-Dist: click==8.1.7
36
37
  Provides-Extra: all
37
38
  Requires-Dist: pycocotools==2.0.6; extra == "all"
38
39
 
39
40
  <h1 align="center">
40
- <a href="https://www.clarifai.com/"><img alt="Clarifai" title="Clarifai" src="https://upload.wikimedia.org/wikipedia/commons/b/bc/Clarifai_Logo_FC_Web.png"></a>
41
+ <a href="https://www.clarifai.com/"><img alt="Clarifai" title="Clarifai" src="https://github.com/user-attachments/assets/623b883b-7fe5-4b95-bbfa-8691f5779af4"></a>
41
42
  </h1>
42
43
 
44
+
43
45
  <h2 align="center">
44
- Clarifai Python SDK</a>
46
+ Clarifai Python SDK
45
47
  </h2>
46
48
 
47
49
 
@@ -51,6 +53,8 @@ Clarifai Python SDK</a>
51
53
  </a>
52
54
  <a href="https://pypi.org/project/clarifai" target="_blank"> <img src="https://img.shields.io/pypi/dm/clarifai" alt="PyPI - Downloads">
53
55
  </a>
56
+ <a href="https://img.shields.io/pypi/pyversions/clarifai" target="_blank"> <img src="https://img.shields.io/pypi/pyversions/clarifai" alt="PyPI - Versions">
57
+ </a>
54
58
  </p>
55
59
 
56
60
 
@@ -261,19 +265,19 @@ print(gpt_4_model)
261
265
 
262
266
 
263
267
  # Model Predict
264
- model_prediction = Model("https://clarifai.com/anthropic/completion/models/claude-v2").predict_by_bytes(b"Write a tweet on future of AI", input_type="text")
268
+ model_prediction = Model("https://clarifai.com/anthropic/completion/models/claude-v2").predict_by_bytes(b"Write a tweet on future of AI")
265
269
 
266
270
  # Customizing Model Inference Output
267
- model_prediction = gpt_4_model.predict_by_bytes(b"Write a tweet on future of AI", "text", inference_params=dict(temperature=str(0.7), max_tokens=30))
271
+ model_prediction = gpt_4_model.predict_by_bytes(b"Write a tweet on future of AI", inference_params=dict(temperature=str(0.7), max_tokens=30))
268
272
  # Return predictions having prediction confidence > 0.98
269
- model_prediction = model.predict_by_filepath(filepath="local_filepath", input_type, output_config={"min_value": 0.98}) # Supports image, text, audio, video
273
+ model_prediction = model.predict_by_filepath(filepath="local_filepath", output_config={"min_value": 0.98}) # Supports image, text, audio, video
270
274
 
271
275
  # Supports prediction by url
272
- model_prediction = model.predict_by_url(url="url", input_type) # Supports image, text, audio, video
276
+ model_prediction = model.predict_by_url(url="url") # Supports image, text, audio, video
273
277
 
274
278
  # Return predictions for specified interval of video
275
279
  video_input_proto = [input_obj.get_input_from_url("Input_id", video_url=BEER_VIDEO_URL)]
276
- model_prediction = model.predict(video_input_proto, input_type="video", output_config={"sample_ms": 2000})
280
+ model_prediction = model.predict(video_input_proto, output_config={"sample_ms": 2000})
277
281
  ```
278
282
  #### Model Training
279
283
  ```python
@@ -383,12 +387,12 @@ from clarifai.client.workflow import Workflow
383
387
 
384
388
  # Workflow Predict
385
389
  workflow = Workflow("workflow_url") # Example: https://clarifai.com/clarifai/main/workflows/Face-Sentiment
386
- workflow_prediction = workflow.predict_by_url(url="url", input_type="image") # Supports image, text, audio, video
390
+ workflow_prediction = workflow.predict_by_url(url="url") # Supports image, text, audio, video
387
391
 
388
392
  # Customizing Workflow Inference Output
389
393
  workflow = Workflow(user_id="user_id", app_id="app_id", workflow_id="workflow_id",
390
394
  output_config={"min_value": 0.98}) # Return predictions having prediction confidence > 0.98
391
- workflow_prediction = workflow.predict_by_filepath(filepath="local_filepath", input_type="text") # Supports image, text, audio, video
395
+ workflow_prediction = workflow.predict_by_filepath(filepath="local_filepath") # Supports image, text, audio, video
392
396
  ```
393
397
 
394
398
  #### Workflows Listing
@@ -1,9 +1,10 @@
1
1
  <h1 align="center">
2
- <a href="https://www.clarifai.com/"><img alt="Clarifai" title="Clarifai" src="https://upload.wikimedia.org/wikipedia/commons/b/bc/Clarifai_Logo_FC_Web.png"></a>
2
+ <a href="https://www.clarifai.com/"><img alt="Clarifai" title="Clarifai" src="https://github.com/user-attachments/assets/623b883b-7fe5-4b95-bbfa-8691f5779af4"></a>
3
3
  </h1>
4
4
 
5
+
5
6
  <h2 align="center">
6
- Clarifai Python SDK</a>
7
+ Clarifai Python SDK
7
8
  </h2>
8
9
 
9
10
 
@@ -13,6 +14,8 @@ Clarifai Python SDK</a>
13
14
  </a>
14
15
  <a href="https://pypi.org/project/clarifai" target="_blank"> <img src="https://img.shields.io/pypi/dm/clarifai" alt="PyPI - Downloads">
15
16
  </a>
17
+ <a href="https://img.shields.io/pypi/pyversions/clarifai" target="_blank"> <img src="https://img.shields.io/pypi/pyversions/clarifai" alt="PyPI - Versions">
18
+ </a>
16
19
  </p>
17
20
 
18
21
 
@@ -223,19 +226,19 @@ print(gpt_4_model)
223
226
 
224
227
 
225
228
  # Model Predict
226
- model_prediction = Model("https://clarifai.com/anthropic/completion/models/claude-v2").predict_by_bytes(b"Write a tweet on future of AI", input_type="text")
229
+ model_prediction = Model("https://clarifai.com/anthropic/completion/models/claude-v2").predict_by_bytes(b"Write a tweet on future of AI")
227
230
 
228
231
  # Customizing Model Inference Output
229
- model_prediction = gpt_4_model.predict_by_bytes(b"Write a tweet on future of AI", "text", inference_params=dict(temperature=str(0.7), max_tokens=30))
232
+ model_prediction = gpt_4_model.predict_by_bytes(b"Write a tweet on future of AI", inference_params=dict(temperature=str(0.7), max_tokens=30))
230
233
  # Return predictions having prediction confidence > 0.98
231
- model_prediction = model.predict_by_filepath(filepath="local_filepath", input_type, output_config={"min_value": 0.98}) # Supports image, text, audio, video
234
+ model_prediction = model.predict_by_filepath(filepath="local_filepath", output_config={"min_value": 0.98}) # Supports image, text, audio, video
232
235
 
233
236
  # Supports prediction by url
234
- model_prediction = model.predict_by_url(url="url", input_type) # Supports image, text, audio, video
237
+ model_prediction = model.predict_by_url(url="url") # Supports image, text, audio, video
235
238
 
236
239
  # Return predictions for specified interval of video
237
240
  video_input_proto = [input_obj.get_input_from_url("Input_id", video_url=BEER_VIDEO_URL)]
238
- model_prediction = model.predict(video_input_proto, input_type="video", output_config={"sample_ms": 2000})
241
+ model_prediction = model.predict(video_input_proto, output_config={"sample_ms": 2000})
239
242
  ```
240
243
  #### Model Training
241
244
  ```python
@@ -345,12 +348,12 @@ from clarifai.client.workflow import Workflow
345
348
 
346
349
  # Workflow Predict
347
350
  workflow = Workflow("workflow_url") # Example: https://clarifai.com/clarifai/main/workflows/Face-Sentiment
348
- workflow_prediction = workflow.predict_by_url(url="url", input_type="image") # Supports image, text, audio, video
351
+ workflow_prediction = workflow.predict_by_url(url="url") # Supports image, text, audio, video
349
352
 
350
353
  # Customizing Workflow Inference Output
351
354
  workflow = Workflow(user_id="user_id", app_id="app_id", workflow_id="workflow_id",
352
355
  output_config={"min_value": 0.98}) # Return predictions having prediction confidence > 0.98
353
- workflow_prediction = workflow.predict_by_filepath(filepath="local_filepath", input_type="text") # Supports image, text, audio, video
356
+ workflow_prediction = workflow.predict_by_filepath(filepath="local_filepath") # Supports image, text, audio, video
354
357
  ```
355
358
 
356
359
  #### Workflows Listing
@@ -0,0 +1 @@
1
+ __version__ = "10.9.5"
@@ -0,0 +1,74 @@
1
+ import os
2
+
3
+ import click
4
+
5
+ from ..utils.cli import dump_yaml, from_yaml, load_command_modules, set_base_url
6
+
7
+
8
+ @click.group()
9
+ @click.pass_context
10
+ def cli(ctx):
11
+ """Clarifai CLI"""
12
+ ctx.ensure_object(dict)
13
+ config_path = 'config.yaml'
14
+ if os.path.exists(config_path):
15
+ ctx.obj = from_yaml(config_path)
16
+ else:
17
+ ctx.obj = {}
18
+
19
+
20
+ @cli.command()
21
+ @click.option('--config', type=click.Path(), required=False, help='Path to the config file')
22
+ @click.option(
23
+ '-e',
24
+ '--env',
25
+ required=False,
26
+ help='Environment to use, choose from prod, staging and dev',
27
+ type=click.Choice(['prod', 'staging', 'dev']))
28
+ @click.option('--user_id', required=False, help='User ID')
29
+ @click.pass_context
30
+ def login(ctx, config, env, user_id):
31
+ """Login command to set PAT and other configurations."""
32
+
33
+ if config and os.path.exists(config):
34
+ ctx.obj = from_yaml(config)
35
+
36
+ if 'pat' in ctx.obj:
37
+ os.environ["CLARIFAI_PAT"] = ctx.obj['pat']
38
+ click.echo("Loaded PAT from config file.")
39
+ elif 'CLARIFAI_PAT' in os.environ:
40
+ ctx.obj['pat'] = os.environ["CLARIFAI_PAT"]
41
+ click.echo("Loaded PAT from environment variable.")
42
+ else:
43
+ _pat = click.prompt(
44
+ "Get your PAT from https://clarifai.com/settings/security and pass it here", type=str)
45
+ os.environ["CLARIFAI_PAT"] = _pat
46
+ ctx.obj['pat'] = _pat
47
+ click.echo("PAT saved successfully.")
48
+
49
+ if user_id:
50
+ ctx.obj['user_id'] = user_id
51
+ os.environ["CLARIFAI_USER_ID"] = ctx.obj['user_id']
52
+ elif 'user_id' in ctx.obj or 'CLARIFAI_USER_ID' in os.environ:
53
+ ctx.obj['user_id'] = ctx.obj.get('user_id', os.environ["CLARIFAI_USER_ID"])
54
+ os.environ["CLARIFAI_USER_ID"] = ctx.obj['user_id']
55
+
56
+ if env:
57
+ ctx.obj['env'] = env
58
+ ctx.obj['base_url'] = set_base_url(env)
59
+ os.environ["CLARIFAI_API_BASE"] = ctx.obj['base_url']
60
+ elif 'env' in ctx.obj:
61
+ ctx.obj['env'] = ctx.obj.get('env', "prod")
62
+ ctx.obj['base_url'] = set_base_url(ctx.obj['env'])
63
+ os.environ["CLARIFAI_API_BASE"] = ctx.obj['base_url']
64
+ elif 'CLARIFAI_API_BASE' in os.environ:
65
+ ctx.obj['base_url'] = os.environ["CLARIFAI_API_BASE"]
66
+
67
+ dump_yaml(ctx.obj, 'config.yaml')
68
+
69
+
70
+ # Import the CLI commands to register them
71
+ load_command_modules()
72
+
73
+ if __name__ == '__main__':
74
+ cli()
@@ -0,0 +1,65 @@
1
+ import click
2
+ from clarifai.cli.base import cli
3
+
4
+
5
+ @cli.group()
6
+ def model():
7
+ """Manage models: upload, test locally"""
8
+ pass
9
+
10
+
11
+ @model.command()
12
+ @click.option(
13
+ '--model_path',
14
+ type=click.Path(exists=True),
15
+ required=True,
16
+ help='Path to the model directory.')
17
+ @click.option(
18
+ '--download_checkpoints',
19
+ is_flag=True,
20
+ help=
21
+ '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.',
22
+ )
23
+ @click.option(
24
+ '--skip_dockerfile',
25
+ is_flag=True,
26
+ help=
27
+ 'Flag to skip generating a dockerfile so that you can manually edit an already created dockerfile.',
28
+ )
29
+ def upload(model_path, download_checkpoints, skip_dockerfile):
30
+ """Upload a model to Clarifai."""
31
+ from clarifai.runners.models import model_upload
32
+
33
+ model_upload.main(model_path, download_checkpoints, skip_dockerfile)
34
+
35
+
36
+ @model.command()
37
+ @click.option(
38
+ '--model_path',
39
+ type=click.Path(exists=True),
40
+ required=True,
41
+ help='Path to the model directory.')
42
+ def test_locally(model_path):
43
+ """Test model locally."""
44
+ try:
45
+ from clarifai.runners.models import model_run_locally
46
+ model_run_locally.main(model_path)
47
+ click.echo(f"Model tested locally from {model_path}.")
48
+ except Exception as e:
49
+ click.echo(f"Failed to test model locally: {e}", err=True)
50
+
51
+
52
+ @model.command()
53
+ @click.option(
54
+ '--model_path',
55
+ type=click.Path(exists=True),
56
+ required=True,
57
+ help='Path to the model directory.')
58
+ def run_locally(model_path):
59
+ """Run model locally and starts a GRPC server to serve the model."""
60
+ try:
61
+ from clarifai.runners.models import model_run_locally
62
+ model_run_locally.main(model_path, run_model_server=True)
63
+ click.echo(f"Model server started locally from {model_path}.")
64
+ except Exception as e:
65
+ click.echo(f"Failed to starts model server locally: {e}", err=True)
@@ -5,11 +5,16 @@ from urllib.parse import urlparse
5
5
 
6
6
  from clarifai_grpc.channel.clarifai_channel import ClarifaiChannel
7
7
  from clarifai_grpc.grpc.api import resources_pb2, service_pb2_grpc
8
+
9
+ from clarifai import __version__
8
10
  from clarifai.utils.constants import CLARIFAI_PAT_ENV_VAR, CLARIFAI_SESSION_TOKEN_ENV_VAR
9
11
 
10
12
  DEFAULT_BASE = "https://api.clarifai.com"
11
13
  DEFAULT_UI = "https://clarifai.com"
12
14
 
15
+ REQUEST_ID_PREFIX_HEADER = "x-clarifai-request-id-prefix"
16
+ REQUEST_ID_PREFIX = f"sdk-python-{__version__}"
17
+
13
18
  # Map from base domain to True / False for whether the base has https or http.
14
19
  # This is filled in get_stub() if it's not in there already.
15
20
  base_https_cache = {}
@@ -136,7 +141,7 @@ class ClarifaiAuthHelper:
136
141
 
137
142
  # Then add in the query params.
138
143
  try:
139
- auth.add_streamlit_query_params(st.experimental_get_query_params())
144
+ auth.add_streamlit_query_params(dict(st.query_params))
140
145
  except Exception as e:
141
146
  st.error(e)
142
147
  st.stop()
@@ -269,9 +274,11 @@ Additionally, these optional params are supported:
269
274
  metadata: the metadata need to send with all grpc API calls in the API client.
270
275
  """
271
276
  if self._pat != "":
272
- return (("authorization", "Key %s" % self._pat),)
277
+ return (("authorization", "Key %s" % self._pat), (REQUEST_ID_PREFIX_HEADER,
278
+ REQUEST_ID_PREFIX))
273
279
  elif self._token != "":
274
- return (("x-clarifai-session-token", self._token),)
280
+ return (("x-clarifai-session-token", self._token), (REQUEST_ID_PREFIX_HEADER,
281
+ REQUEST_ID_PREFIX))
275
282
  else:
276
283
  raise Exception("'token' or 'pat' needed to be provided in the query params or env vars.")
277
284
 
@@ -100,7 +100,7 @@ class Inputs(Lister, BaseClient):
100
100
  if not label_ids:
101
101
  concepts=[
102
102
  resources_pb2.Concept(
103
- id=f"id-{''.join(_label.split(' '))}", name=_label, value=1.)\
103
+ id=_label, name=_label, value=1.)\
104
104
  for _label in labels
105
105
  ]
106
106
  else:
@@ -516,7 +516,7 @@ class Inputs(Lister, BaseClient):
516
516
  right_col=bbox[2] #x_max
517
517
  )),
518
518
  data=resources_pb2.Data(concepts=[
519
- resources_pb2.Concept(id=f"id-{''.join(label.split(' '))}", name=label, value=1.)
519
+ resources_pb2.Concept(id=label, name=label, value=1.)
520
520
  if not label_id else resources_pb2.Concept(id=label_id, name=label, value=1.)
521
521
  ]))
522
522
  ])
@@ -561,7 +561,7 @@ class Inputs(Lister, BaseClient):
561
561
  visibility="VISIBLE") for _point in polygons
562
562
  ])),
563
563
  data=resources_pb2.Data(concepts=[
564
- resources_pb2.Concept(id=f"id-{''.join(label.split(' '))}", name=label, value=1.)
564
+ resources_pb2.Concept(id=label, name=label, value=1.)
565
565
  if not label_id else resources_pb2.Concept(id=label_id, name=label, value=1.)
566
566
  ]))
567
567
  ])