clarifai 11.6.3__tar.gz → 11.6.4__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 (150) hide show
  1. {clarifai-11.6.3/clarifai.egg-info → clarifai-11.6.4}/PKG-INFO +1 -1
  2. clarifai-11.6.4/clarifai/__init__.py +1 -0
  3. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/cli/base.py +30 -1
  4. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/cli/model.py +41 -38
  5. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/nodepool.py +1 -1
  6. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/dockerfile_template/Dockerfile.template +1 -1
  7. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/models/model_builder.py +1 -1
  8. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/utils/cli.py +50 -1
  9. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/utils/constants.py +16 -16
  10. {clarifai-11.6.3 → clarifai-11.6.4/clarifai.egg-info}/PKG-INFO +1 -1
  11. clarifai-11.6.3/clarifai/__init__.py +0 -1
  12. {clarifai-11.6.3 → clarifai-11.6.4}/LICENSE +0 -0
  13. {clarifai-11.6.3 → clarifai-11.6.4}/MANIFEST.in +0 -0
  14. {clarifai-11.6.3 → clarifai-11.6.4}/README.md +0 -0
  15. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/cli/README.md +0 -0
  16. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/cli/__init__.py +0 -0
  17. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/cli/__main__.py +0 -0
  18. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/cli/compute_cluster.py +0 -0
  19. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/cli/deployment.py +0 -0
  20. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/cli/nodepool.py +0 -0
  21. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/cli/pipeline.py +0 -0
  22. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/cli/pipeline_step.py +0 -0
  23. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/cli/templates/__init__.py +0 -0
  24. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/cli/templates/model_templates.py +0 -0
  25. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/cli/templates/pipeline_step_templates.py +0 -0
  26. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/cli/templates/pipeline_templates.py +0 -0
  27. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/cli.py +0 -0
  28. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/__init__.py +0 -0
  29. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/app.py +0 -0
  30. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/auth/__init__.py +0 -0
  31. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/auth/helper.py +0 -0
  32. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/auth/register.py +0 -0
  33. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/auth/stub.py +0 -0
  34. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/base.py +0 -0
  35. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/compute_cluster.py +0 -0
  36. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/dataset.py +0 -0
  37. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/deployment.py +0 -0
  38. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/input.py +0 -0
  39. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/lister.py +0 -0
  40. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/model.py +0 -0
  41. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/model_client.py +0 -0
  42. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/module.py +0 -0
  43. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/pipeline.py +0 -0
  44. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/runner.py +0 -0
  45. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/search.py +0 -0
  46. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/user.py +0 -0
  47. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/client/workflow.py +0 -0
  48. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/constants/base.py +0 -0
  49. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/constants/dataset.py +0 -0
  50. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/constants/input.py +0 -0
  51. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/constants/model.py +0 -0
  52. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/constants/rag.py +0 -0
  53. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/constants/search.py +0 -0
  54. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/constants/workflow.py +0 -0
  55. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/datasets/__init__.py +0 -0
  56. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/datasets/export/__init__.py +0 -0
  57. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/datasets/export/inputs_annotations.py +0 -0
  58. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/datasets/upload/__init__.py +0 -0
  59. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/datasets/upload/base.py +0 -0
  60. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/datasets/upload/features.py +0 -0
  61. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/datasets/upload/image.py +0 -0
  62. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/datasets/upload/loaders/README.md +0 -0
  63. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/datasets/upload/loaders/__init__.py +0 -0
  64. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/datasets/upload/loaders/coco_captions.py +0 -0
  65. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/datasets/upload/loaders/coco_detection.py +0 -0
  66. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/datasets/upload/loaders/imagenet_classification.py +0 -0
  67. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/datasets/upload/loaders/xview_detection.py +0 -0
  68. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/datasets/upload/multimodal.py +0 -0
  69. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/datasets/upload/text.py +0 -0
  70. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/datasets/upload/utils.py +0 -0
  71. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/errors.py +0 -0
  72. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/models/__init__.py +0 -0
  73. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/models/api.py +0 -0
  74. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/modules/README.md +0 -0
  75. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/modules/__init__.py +0 -0
  76. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/modules/css.py +0 -0
  77. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/modules/pages.py +0 -0
  78. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/modules/style.css +0 -0
  79. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/rag/__init__.py +0 -0
  80. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/rag/rag.py +0 -0
  81. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/rag/utils.py +0 -0
  82. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/__init__.py +0 -0
  83. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/models/__init__.py +0 -0
  84. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/models/dummy_openai_model.py +0 -0
  85. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/models/mcp_class.py +0 -0
  86. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/models/model_class.py +0 -0
  87. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/models/model_run_locally.py +0 -0
  88. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/models/model_runner.py +0 -0
  89. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/models/model_servicer.py +0 -0
  90. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/models/openai_class.py +0 -0
  91. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/models/visual_classifier_class.py +0 -0
  92. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/models/visual_detector_class.py +0 -0
  93. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/pipeline_steps/__init__.py +0 -0
  94. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/pipeline_steps/pipeline_step_builder.py +0 -0
  95. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/pipelines/__init__.py +0 -0
  96. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/pipelines/pipeline_builder.py +0 -0
  97. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/server.py +0 -0
  98. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/utils/__init__.py +0 -0
  99. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/utils/code_script.py +0 -0
  100. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/utils/const.py +0 -0
  101. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/utils/data_types/__init__.py +0 -0
  102. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/utils/data_types/data_types.py +0 -0
  103. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/utils/data_utils.py +0 -0
  104. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/utils/loader.py +0 -0
  105. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/utils/method_signatures.py +0 -0
  106. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/utils/model_utils.py +0 -0
  107. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/utils/openai_convertor.py +0 -0
  108. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/utils/pipeline_validation.py +0 -0
  109. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/utils/serializers.py +0 -0
  110. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/runners/utils/url_fetcher.py +0 -0
  111. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/schema/search.py +0 -0
  112. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/urls/helper.py +0 -0
  113. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/utils/__init__.py +0 -0
  114. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/utils/config.py +0 -0
  115. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/utils/evaluation/__init__.py +0 -0
  116. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/utils/evaluation/helpers.py +0 -0
  117. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/utils/evaluation/main.py +0 -0
  118. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/utils/evaluation/testset_annotation_parser.py +0 -0
  119. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/utils/logging.py +0 -0
  120. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/utils/misc.py +0 -0
  121. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/utils/model_train.py +0 -0
  122. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/utils/protobuf.py +0 -0
  123. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/versions.py +0 -0
  124. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/workflows/__init__.py +0 -0
  125. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/workflows/export.py +0 -0
  126. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/workflows/utils.py +0 -0
  127. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai/workflows/validate.py +0 -0
  128. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai.egg-info/SOURCES.txt +0 -0
  129. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai.egg-info/dependency_links.txt +0 -0
  130. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai.egg-info/entry_points.txt +0 -0
  131. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai.egg-info/requires.txt +0 -0
  132. {clarifai-11.6.3 → clarifai-11.6.4}/clarifai.egg-info/top_level.txt +0 -0
  133. {clarifai-11.6.3 → clarifai-11.6.4}/pyproject.toml +0 -0
  134. {clarifai-11.6.3 → clarifai-11.6.4}/requirements.txt +0 -0
  135. {clarifai-11.6.3 → clarifai-11.6.4}/setup.cfg +0 -0
  136. {clarifai-11.6.3 → clarifai-11.6.4}/setup.py +0 -0
  137. {clarifai-11.6.3 → clarifai-11.6.4}/tests/test_app.py +0 -0
  138. {clarifai-11.6.3 → clarifai-11.6.4}/tests/test_async_stub.py +0 -0
  139. {clarifai-11.6.3 → clarifai-11.6.4}/tests/test_auth.py +0 -0
  140. {clarifai-11.6.3 → clarifai-11.6.4}/tests/test_data_upload.py +0 -0
  141. {clarifai-11.6.3 → clarifai-11.6.4}/tests/test_eval.py +0 -0
  142. {clarifai-11.6.3 → clarifai-11.6.4}/tests/test_list_models.py +0 -0
  143. {clarifai-11.6.3 → clarifai-11.6.4}/tests/test_misc.py +0 -0
  144. {clarifai-11.6.3 → clarifai-11.6.4}/tests/test_model_predict.py +0 -0
  145. {clarifai-11.6.3 → clarifai-11.6.4}/tests/test_model_train.py +0 -0
  146. {clarifai-11.6.3 → clarifai-11.6.4}/tests/test_modules.py +0 -0
  147. {clarifai-11.6.3 → clarifai-11.6.4}/tests/test_pipeline_client.py +0 -0
  148. {clarifai-11.6.3 → clarifai-11.6.4}/tests/test_rag.py +0 -0
  149. {clarifai-11.6.3 → clarifai-11.6.4}/tests/test_search.py +0 -0
  150. {clarifai-11.6.3 → clarifai-11.6.4}/tests/test_stub.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clarifai
3
- Version: 11.6.3
3
+ Version: 11.6.4
4
4
  Home-page: https://github.com/Clarifai/clarifai-python
5
5
  Author: Clarifai
6
6
  Author-email: support@clarifai.com
@@ -0,0 +1 @@
1
+ __version__ = "11.6.4"
@@ -154,11 +154,12 @@ def env(ctx_obj):
154
154
 
155
155
 
156
156
  @cli.command()
157
- @click.argument('api_url', default="https://api.clarifai.com")
157
+ @click.argument('api_url', default=DEFAULT_BASE)
158
158
  @click.option('--user_id', required=False, help='User ID')
159
159
  @click.pass_context
160
160
  def login(ctx, api_url, user_id):
161
161
  """Login command to set PAT and other configurations."""
162
+ from clarifai.utils.cli import validate_pat_token
162
163
 
163
164
  name = input('context name (default: "default"): ')
164
165
  user_id = user_id if user_id is not None else input('user id: ')
@@ -167,6 +168,18 @@ def login(ctx, api_url, user_id):
167
168
  'ENVVAR',
168
169
  )
169
170
 
171
+ # Validate the PAT token if it's not "ENVVAR"
172
+ if pat != "ENVVAR":
173
+ print("Validating PAT token...")
174
+ is_valid, error_message = validate_pat_token(pat, user_id, api_url)
175
+
176
+ if not is_valid:
177
+ print(f"❌ PAT token validation failed: {error_message}")
178
+ print("Please check your token and try again.")
179
+ return # Exit without saving the configuration
180
+ else:
181
+ print("✓ PAT token is valid")
182
+
170
183
  context = Context(
171
184
  name,
172
185
  CLARIFAI_API_BASE=api_url,
@@ -181,6 +194,7 @@ def login(ctx, api_url, user_id):
181
194
  ctx.obj.current_context = context.name
182
195
 
183
196
  ctx.obj.to_yaml()
197
+ print(f"✓ Configuration saved successfully for context '{context.name}'")
184
198
 
185
199
 
186
200
  @cli.group(cls=AliasedGroup)
@@ -211,6 +225,8 @@ def create(
211
225
  pat=None,
212
226
  ):
213
227
  """Create a new context"""
228
+ from clarifai.utils.cli import validate_pat_token
229
+
214
230
  if name in ctx.obj.contexts:
215
231
  print(f'{name} already exists')
216
232
  sys.exit(1)
@@ -226,9 +242,22 @@ def create(
226
242
  'ENVVAR',
227
243
  )
228
244
 
245
+ # Validate the PAT token if it's not "ENVVAR"
246
+ if pat != "ENVVAR":
247
+ print("Validating PAT token...")
248
+ is_valid, error_message = validate_pat_token(pat, user_id, base_url)
249
+
250
+ if not is_valid:
251
+ print(f"❌ PAT token validation failed: {error_message}")
252
+ print("Please check your token and try again.")
253
+ return # Exit without saving the configuration
254
+ else:
255
+ print("✓ PAT token is valid")
256
+
229
257
  context = Context(name, CLARIFAI_USER_ID=user_id, CLARIFAI_API_BASE=base_url, CLARIFAI_PAT=pat)
230
258
  ctx.obj.contexts[context.name] = context
231
259
  ctx.obj.to_yaml()
260
+ print(f"✓ Context '{name}' created successfully")
232
261
 
233
262
 
234
263
  # write a click command to delete a context
@@ -7,14 +7,14 @@ import click
7
7
  from clarifai.cli.base import cli
8
8
  from clarifai.utils.cli import validate_context
9
9
  from clarifai.utils.constants import (
10
- DEFAULT_LOCAL_DEV_APP_ID,
11
- DEFAULT_LOCAL_DEV_COMPUTE_CLUSTER_CONFIG,
12
- DEFAULT_LOCAL_DEV_COMPUTE_CLUSTER_ID,
13
- DEFAULT_LOCAL_DEV_DEPLOYMENT_ID,
14
- DEFAULT_LOCAL_DEV_MODEL_ID,
15
- DEFAULT_LOCAL_DEV_MODEL_TYPE,
16
- DEFAULT_LOCAL_DEV_NODEPOOL_CONFIG,
17
- DEFAULT_LOCAL_DEV_NODEPOOL_ID,
10
+ DEFAULT_LOCAL_RUNNER_APP_ID,
11
+ DEFAULT_LOCAL_RUNNER_COMPUTE_CLUSTER_CONFIG,
12
+ DEFAULT_LOCAL_RUNNER_COMPUTE_CLUSTER_ID,
13
+ DEFAULT_LOCAL_RUNNER_DEPLOYMENT_ID,
14
+ DEFAULT_LOCAL_RUNNER_MODEL_ID,
15
+ DEFAULT_LOCAL_RUNNER_MODEL_TYPE,
16
+ DEFAULT_LOCAL_RUNNER_NODEPOOL_CONFIG,
17
+ DEFAULT_LOCAL_RUNNER_NODEPOOL_ID,
18
18
  )
19
19
  from clarifai.utils.logging import logger
20
20
  from clarifai.utils.misc import clone_github_repo, format_github_repo_url
@@ -421,17 +421,16 @@ def run_locally(model_path, port, mode, keep_env, keep_image, skip_dockerfile=Fa
421
421
  @click.option(
422
422
  "--pool_size",
423
423
  type=int,
424
- is_flag=True,
425
- default=1, # default to 1 thread for local dev runner to avoid rapid depletion of compute time.
424
+ default=1, # default to 1 thread for local runner to avoid rapid depletion of compute time.
426
425
  show_default=True,
427
426
  help="The number of threads to use. On community plan, the compute time allocation is drained at a rate proportional to the number of threads.",
428
427
  ) # pylint: disable=range-builtin-not-iterating
429
428
  @click.pass_context
430
- def local_dev(ctx, model_path, pool_size):
431
- """Run the model as a local dev runner to help debug your model connected to the API or to
429
+ def local_runner(ctx, model_path, pool_size):
430
+ """Run the model as a local runner to help debug your model connected to the API or to
432
431
  leverage local compute resources manually. This relies on many variables being present in the env
433
432
  of the currently selected context. If they are not present then default values will be used to
434
- ease the setup of a local dev runner and your context yaml will be updated in place. The required
433
+ ease the setup of a local runner and your context yaml will be updated in place. The required
435
434
  env vars are:
436
435
 
437
436
  \b
@@ -445,7 +444,7 @@ def local_dev(ctx, model_path, pool_size):
445
444
  CLARIFAI_MODEL_ID:
446
445
 
447
446
  \b
448
- # for where the local dev runner should be in a compute cluser
447
+ # for where the local runner should be in a compute cluster
449
448
  # note the user_id of the compute cluster is the same as the user_id of the model.
450
449
 
451
450
  \b
@@ -460,7 +459,7 @@ def local_dev(ctx, model_path, pool_size):
460
459
  Additionally using the provided model path, if the config.yaml file does not contain the model
461
460
  information that matches the above CLARIFAI_USER_ID, CLARIFAI_APP_ID, CLARIFAI_MODEL_ID then the
462
461
  config.yaml will be updated to include the model information. This is to ensure that the model
463
- that starts up in the local dev runner is the same as the one you intend to call in the API.
462
+ that starts up in the local runner is the same as the one you intend to call in the API.
464
463
 
465
464
  MODEL_PATH: Path to the model directory. If not specified, the current directory is used by default.
466
465
  """
@@ -469,25 +468,29 @@ def local_dev(ctx, model_path, pool_size):
469
468
  from clarifai.runners.server import serve
470
469
 
471
470
  validate_context(ctx)
472
- logger.info("Checking setup for local development runner...")
471
+ logger.info("Checking setup for local runner...")
473
472
  logger.info(f"Current context: {ctx.obj.current.name}")
474
473
  user_id = ctx.obj.current.user_id
475
- user = User(user_id=user_id, pat=ctx.obj.current.pat, base_url=ctx.obj.current.api_base)
476
474
  logger.info(f"Current user_id: {user_id}")
477
- logger.debug("Checking if a local dev compute cluster exists...")
475
+ if not user_id:
476
+ raise ValueError(
477
+ f"User with ID '{user_id}' not found. Use 'clarifai login' to setup context."
478
+ )
479
+ user = User(user_id=user_id, pat=ctx.obj.current.pat, base_url=ctx.obj.current.api_base)
480
+ logger.debug("Checking if a local runner compute cluster exists...")
478
481
 
479
482
  # see if ctx has CLARIFAI_COMPUTE_CLUSTER_ID, if not use default
480
483
  try:
481
484
  compute_cluster_id = ctx.obj.current.compute_cluster_id
482
485
  except AttributeError:
483
- compute_cluster_id = DEFAULT_LOCAL_DEV_COMPUTE_CLUSTER_ID
486
+ compute_cluster_id = DEFAULT_LOCAL_RUNNER_COMPUTE_CLUSTER_ID
484
487
  logger.info(f"Current compute_cluster_id: {compute_cluster_id}")
485
488
 
486
489
  try:
487
490
  compute_cluster = user.compute_cluster(compute_cluster_id)
488
491
  if compute_cluster.cluster_type != 'local-dev':
489
492
  raise ValueError(
490
- f"Compute cluster {user_id}/{compute_cluster_id} is not a local-dev compute cluster. Please create a local-dev compute cluster."
493
+ f"Compute cluster {user_id}/{compute_cluster_id} is not a local-runner compute cluster. Please create a local-runner compute cluster."
491
494
  )
492
495
  try:
493
496
  compute_cluster_id = ctx.obj.current.compute_cluster_id
@@ -503,10 +506,10 @@ def local_dev(ctx, model_path, pool_size):
503
506
  )
504
507
  if y.lower() != 'y':
505
508
  raise click.Abort()
506
- # Create a compute cluster with default configuration for local dev.
509
+ # Create a compute cluster with default configuration for local runner.
507
510
  compute_cluster = user.create_compute_cluster(
508
511
  compute_cluster_id=compute_cluster_id,
509
- compute_cluster_config=DEFAULT_LOCAL_DEV_COMPUTE_CLUSTER_CONFIG,
512
+ compute_cluster_config=DEFAULT_LOCAL_RUNNER_COMPUTE_CLUSTER_CONFIG,
510
513
  )
511
514
  ctx.obj.current.CLARIFAI_COMPUTE_CLUSTER_ID = compute_cluster_id
512
515
  ctx.obj.to_yaml() # save to yaml file.
@@ -515,7 +518,7 @@ def local_dev(ctx, model_path, pool_size):
515
518
  try:
516
519
  nodepool_id = ctx.obj.current.nodepool_id
517
520
  except AttributeError:
518
- nodepool_id = DEFAULT_LOCAL_DEV_NODEPOOL_ID
521
+ nodepool_id = DEFAULT_LOCAL_RUNNER_NODEPOOL_ID
519
522
  logger.info(f"Current nodepool_id: {nodepool_id}")
520
523
 
521
524
  try:
@@ -533,7 +536,7 @@ def local_dev(ctx, model_path, pool_size):
533
536
  if y.lower() != 'y':
534
537
  raise click.Abort()
535
538
  nodepool = compute_cluster.create_nodepool(
536
- nodepool_config=DEFAULT_LOCAL_DEV_NODEPOOL_CONFIG, nodepool_id=nodepool_id
539
+ nodepool_config=DEFAULT_LOCAL_RUNNER_NODEPOOL_CONFIG, nodepool_id=nodepool_id
537
540
  )
538
541
  ctx.obj.current.CLARIFAI_NODEPOOL_ID = nodepool_id
539
542
  ctx.obj.to_yaml() # save to yaml file.
@@ -543,7 +546,7 @@ def local_dev(ctx, model_path, pool_size):
543
546
  try:
544
547
  app_id = ctx.obj.current.app_id
545
548
  except AttributeError:
546
- app_id = DEFAULT_LOCAL_DEV_APP_ID
549
+ app_id = DEFAULT_LOCAL_RUNNER_APP_ID
547
550
  logger.info(f"Current app_id: {app_id}")
548
551
 
549
552
  try:
@@ -562,11 +565,11 @@ def local_dev(ctx, model_path, pool_size):
562
565
  ctx.obj.current.CLARIFAI_APP_ID = app_id
563
566
  ctx.obj.to_yaml() # save to yaml file.
564
567
 
565
- # Within this app we now need a model to call as the local dev runner.
568
+ # Within this app we now need a model to call as the local runner.
566
569
  try:
567
570
  model_id = ctx.obj.current.model_id
568
571
  except AttributeError:
569
- model_id = DEFAULT_LOCAL_DEV_MODEL_ID
572
+ model_id = DEFAULT_LOCAL_RUNNER_MODEL_ID
570
573
  logger.info(f"Current model_id: {model_id}")
571
574
 
572
575
  try:
@@ -586,7 +589,7 @@ def local_dev(ctx, model_path, pool_size):
586
589
  try:
587
590
  model_type_id = ctx.obj.current.model_type_id
588
591
  except AttributeError:
589
- model_type_id = DEFAULT_LOCAL_DEV_MODEL_TYPE
592
+ model_type_id = DEFAULT_LOCAL_RUNNER_MODEL_TYPE
590
593
 
591
594
  model = app.create_model(model_id, model_type_id=model_type_id)
592
595
  ctx.obj.current.CLARIFAI_MODEL_TYPE_ID = model_type_id
@@ -594,10 +597,10 @@ def local_dev(ctx, model_path, pool_size):
594
597
  ctx.obj.to_yaml() # save to yaml file.
595
598
 
596
599
  # Now we need to create a version for the model if no version exists. Only need one version that
597
- # mentions it's a local dev runner.
600
+ # mentions it's a local runner.
598
601
  model_versions = [v for v in model.list_versions()]
599
602
  if len(model_versions) == 0:
600
- logger.info("No model versions found. Creating a new version for local dev runner.")
603
+ logger.info("No model versions found. Creating a new version for local runner.")
601
604
  version = model.create_version(pretrained_model_config={"local_dev": True}).model_version
602
605
  logger.info(f"Created model version {version.id}")
603
606
  else:
@@ -631,12 +634,12 @@ def local_dev(ctx, model_path, pool_size):
631
634
  raise AttributeError("Runner not found in nodepool.") from e
632
635
  except AttributeError:
633
636
  logger.info(
634
- f"Create the local dev runner tying this\n {user_id}/{app_id}/models/{model.id} model (version: {version.id}) to the\n {user_id}/{compute_cluster_id}/{nodepool_id} nodepool."
637
+ f"Create the local runner tying this\n {user_id}/{app_id}/models/{model.id} model (version: {version.id}) to the\n {user_id}/{compute_cluster_id}/{nodepool_id} nodepool."
635
638
  )
636
639
  runner = nodepool.create_runner(
637
640
  runner_config={
638
641
  "runner": {
639
- "description": "Local dev runner for model testing",
642
+ "description": "local runner for model testing",
640
643
  "worker": worker,
641
644
  "num_replicas": 1,
642
645
  }
@@ -653,7 +656,7 @@ def local_dev(ctx, model_path, pool_size):
653
656
  try:
654
657
  deployment_id = ctx.obj.current.deployment_id
655
658
  except AttributeError:
656
- deployment_id = DEFAULT_LOCAL_DEV_DEPLOYMENT_ID
659
+ deployment_id = DEFAULT_LOCAL_RUNNER_DEPLOYMENT_ID
657
660
  try:
658
661
  deployment = nodepool.deployment(deployment_id)
659
662
  # ensure the deployment is using the latest version.
@@ -708,7 +711,7 @@ def local_dev(ctx, model_path, pool_size):
708
711
  f"config.yaml not found in {model_path}. Please ensure you are passing the correct directory."
709
712
  )
710
713
  config = ModelBuilder._load_config(config_file)
711
- model_type_id = config.get('model', {}).get('model_type_id', DEFAULT_LOCAL_DEV_MODEL_TYPE)
714
+ model_type_id = config.get('model', {}).get('model_type_id', DEFAULT_LOCAL_RUNNER_MODEL_TYPE)
712
715
  # The config.yaml doens't match what we created above.
713
716
  if 'model' in config and model_id != config['model'].get('id'):
714
717
  logger.info(f"Current model section of config.yaml: {config.get('model', {})}")
@@ -717,14 +720,14 @@ def local_dev(ctx, model_path, pool_size):
717
720
  )
718
721
  if y.lower() != 'y':
719
722
  raise click.Abort()
720
- config = ModelBuilder._set_local_dev_model(
723
+ config = ModelBuilder._set_local_runner_model(
721
724
  config, user_id, app_id, model_id, model_type_id
722
725
  )
723
726
  ModelBuilder._backup_config(config_file)
724
727
  ModelBuilder._save_config(config_file, config)
725
728
 
726
729
  builder = ModelBuilder(model_path, download_validation_only=True)
727
- # don't mock for local dev since you need the dependencies to run the code anyways.
730
+ # don't mock for local runner since you need the dependencies to run the code anyways.
728
731
  method_signatures = builder.get_method_signatures(mocking=False)
729
732
 
730
733
  from clarifai.runners.utils import code_script
@@ -740,12 +743,12 @@ def local_dev(ctx, model_path, pool_size):
740
743
 
741
744
  logger.info("""\n
742
745
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
743
- # About to start up the local dev runner in this terminal...
746
+ # About to start up the local runner in this terminal...
744
747
  # Here is a code snippet to call this model once it start from another terminal:
745
748
  """)
746
749
  logger.info(snippet)
747
750
 
748
- logger.info("Now starting the local dev runner...")
751
+ logger.info("Now starting the local runner...")
749
752
 
750
753
  # This reads the config.yaml from the model_path so we alter it above first.
751
754
  serve(
@@ -280,7 +280,7 @@ class Nodepool(Lister, BaseClient):
280
280
  def create_runner(
281
281
  self, config_filepath: str = None, runner_config: Dict[str, Any] = None
282
282
  ) -> Runner:
283
- """Creates a runner for the nodepool. Only needed for local dev runners.
283
+ """Creates a runner for the nodepool. Only needed for local runners.
284
284
 
285
285
  Args:
286
286
  config_filepath (str): The path to the runner config file.
@@ -48,7 +48,7 @@ ENV PYTHONPATH=${PYTHONPATH}:/home/nonroot/main \
48
48
  CLARIFAI_COMPUTE_CLUSTER_ID=${CLARIFAI_COMPUTE_CLUSTER_ID} \
49
49
  CLARIFAI_API_BASE=${CLARIFAI_API_BASE:-https://api.clarifai.com}
50
50
 
51
- # Finally run the clarifai entrypoint to start the runner loop and local dev server.
51
+ # Finally run the clarifai entrypoint to start the runner loop and local runner server.
52
52
  # Note(zeiler): we may want to make this a clarifai CLI call.
53
53
  ENTRYPOINT ["python", "-m", "clarifai.runners.server"]
54
54
  CMD ["--model_path", "/home/nonroot/main"]
@@ -383,7 +383,7 @@ class ModelBuilder:
383
383
  sys.exit(1)
384
384
 
385
385
  @staticmethod
386
- def _set_local_dev_model(config, user_id, app_id, model_id, model_type_id):
386
+ def _set_local_runner_model(config, user_id, app_id, model_id, model_type_id):
387
387
  """
388
388
  Sets the model configuration for local development.
389
389
  This is used when running the model locally without uploading it to Clarifai.
@@ -4,7 +4,7 @@ import pkgutil
4
4
  import sys
5
5
  import typing as t
6
6
  from collections import defaultdict
7
- from typing import OrderedDict
7
+ from typing import OrderedDict, Tuple
8
8
 
9
9
  import click
10
10
  import yaml
@@ -172,3 +172,52 @@ def validate_context(ctx):
172
172
  if ctx.obj == {}:
173
173
  logger.error("CLI config file missing. Run `clarifai login` to set up the CLI config.")
174
174
  sys.exit(1)
175
+
176
+
177
+ def validate_pat_token(pat: str, user_id: str, api_base: str = None) -> Tuple[bool, str]:
178
+ """
179
+ Validate a Personal Access Token (PAT) by making a test API call.
180
+
181
+ Args:
182
+ pat (str): The Personal Access Token to validate
183
+ user_id (str): The user ID associated with the token
184
+ api_base (str): The API base URL. Defaults to None (uses default).
185
+
186
+ Returns:
187
+ tuple[bool, str]: A tuple of (is_valid, error_message)
188
+ If valid: (True, "")
189
+ If invalid: (False, error_description)
190
+ """
191
+ try:
192
+ from clarifai_grpc.grpc.api.status import status_code_pb2
193
+
194
+ from clarifai.client.user import User
195
+
196
+ # Create user client for validation
197
+ if api_base:
198
+ user_client = User(user_id=user_id, pat=pat, base_url=api_base)
199
+ else:
200
+ user_client = User(user_id=user_id, pat=pat)
201
+
202
+ # Try to get user info as a test API call
203
+ response = user_client.get_user_info()
204
+
205
+ if response.status.code == status_code_pb2.SUCCESS:
206
+ return True, ""
207
+ else:
208
+ return False, f"Authentication failed: {response.status.description}"
209
+
210
+ except Exception as e:
211
+ error_msg = str(e)
212
+
213
+ # Check for common authentication errors and provide user-friendly messages
214
+ if "PERMISSION_DENIED" in error_msg or "Unauthorized" in error_msg:
215
+ return False, "Invalid PAT token or insufficient permissions"
216
+ elif "UNAUTHENTICATED" in error_msg:
217
+ return False, "Invalid PAT token"
218
+ elif "SSL" in error_msg or "certificate" in error_msg:
219
+ return False, f"SSL/Certificate error: {error_msg}"
220
+ elif "Connection" in error_msg or "timeout" in error_msg:
221
+ return False, f"Network connection error: {error_msg}"
222
+ else:
223
+ return False, f"Validation error: {error_msg}"
@@ -14,20 +14,20 @@ CLARIFAI_USER_ID_ENV_VAR = "CLARIFAI_USER_ID"
14
14
  HOME_PATH = Path.home()
15
15
  DEFAULT_CONFIG = HOME_PATH / '.config/clarifai/config'
16
16
 
17
- # Default clusters, etc. for local dev runner easy setup
18
- DEFAULT_LOCAL_DEV_COMPUTE_CLUSTER_ID = "local-dev-compute-cluster"
19
- DEFAULT_LOCAL_DEV_NODEPOOL_ID = "local-dev-nodepool"
20
- DEFAULT_LOCAL_DEV_DEPLOYMENT_ID = "local-dev-deployment"
21
- DEFAULT_LOCAL_DEV_MODEL_ID = "local-dev-model"
22
- DEFAULT_LOCAL_DEV_APP_ID = "local-dev-runner-app"
17
+ # Default clusters, etc. for local runner easy setup
18
+ DEFAULT_LOCAL_RUNNER_COMPUTE_CLUSTER_ID = "local-runner-compute-cluster"
19
+ DEFAULT_LOCAL_RUNNER_NODEPOOL_ID = "local-runner-nodepool"
20
+ DEFAULT_LOCAL_RUNNER_DEPLOYMENT_ID = "local-runner-deployment"
21
+ DEFAULT_LOCAL_RUNNER_MODEL_ID = "local-runner-model"
22
+ DEFAULT_LOCAL_RUNNER_APP_ID = "local-runner-app"
23
23
 
24
24
  # FIXME: should have any-to-any for these cases.
25
- DEFAULT_LOCAL_DEV_MODEL_TYPE = "text-to-text"
25
+ DEFAULT_LOCAL_RUNNER_MODEL_TYPE = "text-to-text"
26
26
 
27
- DEFAULT_LOCAL_DEV_COMPUTE_CLUSTER_CONFIG = {
27
+ DEFAULT_LOCAL_RUNNER_COMPUTE_CLUSTER_CONFIG = {
28
28
  "compute_cluster": {
29
- "id": DEFAULT_LOCAL_DEV_COMPUTE_CLUSTER_ID,
30
- "description": "Default Local Dev Compute Cluster",
29
+ "id": DEFAULT_LOCAL_RUNNER_COMPUTE_CLUSTER_ID,
30
+ "description": "Default Local Runner Compute Cluster",
31
31
  "cloud_provider": {
32
32
  "id": "local",
33
33
  },
@@ -37,12 +37,12 @@ DEFAULT_LOCAL_DEV_COMPUTE_CLUSTER_CONFIG = {
37
37
  }
38
38
  }
39
39
 
40
- DEFAULT_LOCAL_DEV_NODEPOOL_CONFIG = {
40
+ DEFAULT_LOCAL_RUNNER_NODEPOOL_CONFIG = {
41
41
  "nodepool": {
42
- "id": DEFAULT_LOCAL_DEV_NODEPOOL_ID,
43
- "description": "Default Local Dev Nodepool",
42
+ "id": DEFAULT_LOCAL_RUNNER_NODEPOOL_ID,
43
+ "description": "Default Local Runner Nodepool",
44
44
  "compute_cluster": {
45
- "id": DEFAULT_LOCAL_DEV_COMPUTE_CLUSTER_ID,
45
+ "id": DEFAULT_LOCAL_RUNNER_COMPUTE_CLUSTER_ID,
46
46
  "user_id": None, # This will be set when creating the compute cluster
47
47
  },
48
48
  "instance_types": [
@@ -50,8 +50,8 @@ DEFAULT_LOCAL_DEV_NODEPOOL_CONFIG = {
50
50
  "id": "local",
51
51
  "compute_info": {
52
52
  "cpu_limit": str(os.cpu_count()),
53
- "cpu_memory": "16Gi", # made up as we don't schedule based on this for local dev.
54
- "num_accelerators": 0, # TODO if we need accelerator detection for local dev.
53
+ "cpu_memory": "16Gi", # made up as we don't schedule based on this for local runner.
54
+ "num_accelerators": 0, # TODO if we need accelerator detection for local runner.
55
55
  },
56
56
  }
57
57
  ],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clarifai
3
- Version: 11.6.3
3
+ Version: 11.6.4
4
4
  Home-page: https://github.com/Clarifai/clarifai-python
5
5
  Author: Clarifai
6
6
  Author-email: support@clarifai.com
@@ -1 +0,0 @@
1
- __version__ = "11.6.3"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes