clarifai 11.1.4rc2__py3-none-any.whl → 11.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. clarifai/__init__.py +1 -1
  2. clarifai/cli/model.py +21 -10
  3. clarifai/client/model.py +4 -4
  4. clarifai/client/workflow.py +2 -2
  5. clarifai/runners/dockerfile_template/Dockerfile.template +1 -32
  6. clarifai/runners/models/model_builder.py +14 -13
  7. clarifai/runners/models/model_run_locally.py +5 -2
  8. clarifai/runners/server.py +21 -8
  9. clarifai/runners/utils/const.py +1 -1
  10. clarifai/utils/misc.py +12 -0
  11. {clarifai-11.1.4rc2.dist-info → clarifai-11.1.5.dist-info}/METADATA +26 -15
  12. clarifai-11.1.5.dist-info/RECORD +101 -0
  13. {clarifai-11.1.4rc2.dist-info → clarifai-11.1.5.dist-info}/WHEEL +1 -1
  14. clarifai/__pycache__/__init__.cpython-310.pyc +0 -0
  15. clarifai/__pycache__/errors.cpython-310.pyc +0 -0
  16. clarifai/__pycache__/versions.cpython-310.pyc +0 -0
  17. clarifai/cli/__main__.py~ +0 -4
  18. clarifai/cli/__pycache__/__init__.cpython-310.pyc +0 -0
  19. clarifai/cli/__pycache__/__main__.cpython-310.pyc +0 -0
  20. clarifai/cli/__pycache__/base.cpython-310.pyc +0 -0
  21. clarifai/cli/__pycache__/compute_cluster.cpython-310.pyc +0 -0
  22. clarifai/cli/__pycache__/deployment.cpython-310.pyc +0 -0
  23. clarifai/cli/__pycache__/model.cpython-310.pyc +0 -0
  24. clarifai/cli/__pycache__/nodepool.cpython-310.pyc +0 -0
  25. clarifai/client/__pycache__/__init__.cpython-310.pyc +0 -0
  26. clarifai/client/__pycache__/app.cpython-310.pyc +0 -0
  27. clarifai/client/__pycache__/base.cpython-310.pyc +0 -0
  28. clarifai/client/__pycache__/dataset.cpython-310.pyc +0 -0
  29. clarifai/client/__pycache__/input.cpython-310.pyc +0 -0
  30. clarifai/client/__pycache__/lister.cpython-310.pyc +0 -0
  31. clarifai/client/__pycache__/model.cpython-310.pyc +0 -0
  32. clarifai/client/__pycache__/module.cpython-310.pyc +0 -0
  33. clarifai/client/__pycache__/runner.cpython-310.pyc +0 -0
  34. clarifai/client/__pycache__/search.cpython-310.pyc +0 -0
  35. clarifai/client/__pycache__/user.cpython-310.pyc +0 -0
  36. clarifai/client/__pycache__/workflow.cpython-310.pyc +0 -0
  37. clarifai/client/auth/__pycache__/__init__.cpython-310.pyc +0 -0
  38. clarifai/client/auth/__pycache__/helper.cpython-310.pyc +0 -0
  39. clarifai/client/auth/__pycache__/register.cpython-310.pyc +0 -0
  40. clarifai/client/auth/__pycache__/stub.cpython-310.pyc +0 -0
  41. clarifai/constants/__pycache__/dataset.cpython-310.pyc +0 -0
  42. clarifai/constants/__pycache__/model.cpython-310.pyc +0 -0
  43. clarifai/constants/__pycache__/search.cpython-310.pyc +0 -0
  44. clarifai/datasets/__pycache__/__init__.cpython-310.pyc +0 -0
  45. clarifai/datasets/export/__pycache__/__init__.cpython-310.pyc +0 -0
  46. clarifai/datasets/export/__pycache__/inputs_annotations.cpython-310.pyc +0 -0
  47. clarifai/datasets/upload/__pycache__/__init__.cpython-310.pyc +0 -0
  48. clarifai/datasets/upload/__pycache__/base.cpython-310.pyc +0 -0
  49. clarifai/datasets/upload/__pycache__/features.cpython-310.pyc +0 -0
  50. clarifai/datasets/upload/__pycache__/image.cpython-310.pyc +0 -0
  51. clarifai/datasets/upload/__pycache__/text.cpython-310.pyc +0 -0
  52. clarifai/datasets/upload/__pycache__/utils.cpython-310.pyc +0 -0
  53. clarifai/models/__pycache__/__init__.cpython-310.pyc +0 -0
  54. clarifai/models/model_serving/__pycache__/__init__.cpython-310.pyc +0 -0
  55. clarifai/models/model_serving/__pycache__/constants.cpython-310.pyc +0 -0
  56. clarifai/models/model_serving/cli/__pycache__/__init__.cpython-310.pyc +0 -0
  57. clarifai/models/model_serving/cli/__pycache__/_utils.cpython-310.pyc +0 -0
  58. clarifai/models/model_serving/cli/__pycache__/base.cpython-310.pyc +0 -0
  59. clarifai/models/model_serving/cli/__pycache__/build.cpython-310.pyc +0 -0
  60. clarifai/models/model_serving/cli/__pycache__/create.cpython-310.pyc +0 -0
  61. clarifai/models/model_serving/model_config/__pycache__/__init__.cpython-310.pyc +0 -0
  62. clarifai/models/model_serving/model_config/__pycache__/base.cpython-310.pyc +0 -0
  63. clarifai/models/model_serving/model_config/__pycache__/config.cpython-310.pyc +0 -0
  64. clarifai/models/model_serving/model_config/__pycache__/inference_parameter.cpython-310.pyc +0 -0
  65. clarifai/models/model_serving/model_config/__pycache__/output.cpython-310.pyc +0 -0
  66. clarifai/models/model_serving/model_config/triton/__pycache__/__init__.cpython-310.pyc +0 -0
  67. clarifai/models/model_serving/model_config/triton/__pycache__/serializer.cpython-310.pyc +0 -0
  68. clarifai/models/model_serving/model_config/triton/__pycache__/triton_config.cpython-310.pyc +0 -0
  69. clarifai/models/model_serving/model_config/triton/__pycache__/wrappers.cpython-310.pyc +0 -0
  70. clarifai/models/model_serving/repo_build/__pycache__/__init__.cpython-310.pyc +0 -0
  71. clarifai/models/model_serving/repo_build/__pycache__/build.cpython-310.pyc +0 -0
  72. clarifai/models/model_serving/repo_build/static_files/__pycache__/base_test.cpython-310-pytest-7.2.0.pyc +0 -0
  73. clarifai/rag/__pycache__/__init__.cpython-310.pyc +0 -0
  74. clarifai/rag/__pycache__/rag.cpython-310.pyc +0 -0
  75. clarifai/rag/__pycache__/utils.cpython-310.pyc +0 -0
  76. clarifai/runners/__pycache__/__init__.cpython-310.pyc +0 -0
  77. clarifai/runners/__pycache__/server.cpython-310.pyc +0 -0
  78. clarifai/runners/dockerfile_template/Dockerfile.debug +0 -11
  79. clarifai/runners/dockerfile_template/Dockerfile.debug~ +0 -9
  80. clarifai/runners/models/__pycache__/__init__.cpython-310.pyc +0 -0
  81. clarifai/runners/models/__pycache__/base_typed_model.cpython-310.pyc +0 -0
  82. clarifai/runners/models/__pycache__/model_builder.cpython-310.pyc +0 -0
  83. clarifai/runners/models/__pycache__/model_class.cpython-310.pyc +0 -0
  84. clarifai/runners/models/__pycache__/model_run_locally.cpython-310.pyc +0 -0
  85. clarifai/runners/models/__pycache__/model_runner.cpython-310.pyc +0 -0
  86. clarifai/runners/models/__pycache__/model_servicer.cpython-310.pyc +0 -0
  87. clarifai/runners/models/__pycache__/model_upload.cpython-310.pyc +0 -0
  88. clarifai/runners/models/model_upload.py +0 -607
  89. clarifai/runners/utils/#const.py# +0 -30
  90. clarifai/runners/utils/__pycache__/__init__.cpython-310.pyc +0 -0
  91. clarifai/runners/utils/__pycache__/const.cpython-310.pyc +0 -0
  92. clarifai/runners/utils/__pycache__/data_handler.cpython-310.pyc +0 -0
  93. clarifai/runners/utils/__pycache__/data_utils.cpython-310.pyc +0 -0
  94. clarifai/runners/utils/__pycache__/loader.cpython-310.pyc +0 -0
  95. clarifai/runners/utils/__pycache__/logging.cpython-310.pyc +0 -0
  96. clarifai/runners/utils/__pycache__/url_fetcher.cpython-310.pyc +0 -0
  97. clarifai/schema/__pycache__/search.cpython-310.pyc +0 -0
  98. clarifai/urls/__pycache__/helper.cpython-310.pyc +0 -0
  99. clarifai/utils/__pycache__/__init__.cpython-310.pyc +0 -0
  100. clarifai/utils/__pycache__/logging.cpython-310.pyc +0 -0
  101. clarifai/utils/__pycache__/misc.cpython-310.pyc +0 -0
  102. clarifai/utils/__pycache__/model_train.cpython-310.pyc +0 -0
  103. clarifai/workflows/__pycache__/__init__.cpython-310.pyc +0 -0
  104. clarifai/workflows/__pycache__/export.cpython-310.pyc +0 -0
  105. clarifai/workflows/__pycache__/utils.cpython-310.pyc +0 -0
  106. clarifai/workflows/__pycache__/validate.cpython-310.pyc +0 -0
  107. clarifai-11.1.4rc2.dist-info/RECORD +0 -194
  108. {clarifai-11.1.4rc2.dist-info → clarifai-11.1.5.dist-info}/LICENSE +0 -0
  109. {clarifai-11.1.4rc2.dist-info → clarifai-11.1.5.dist-info}/entry_points.txt +0 -0
  110. {clarifai-11.1.4rc2.dist-info → clarifai-11.1.5.dist-info}/top_level.txt +0 -0
clarifai/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "11.1.4rc2"
1
+ __version__ = "11.1.5"
clarifai/cli/model.py CHANGED
@@ -15,10 +15,13 @@ def model():
15
15
  required=True,
16
16
  help='Path to the model directory.')
17
17
  @click.option(
18
- '--download_checkpoints',
19
- is_flag=True,
18
+ '--stage',
19
+ required=False,
20
+ type=click.Choice(['runtime', 'build', 'upload'], case_sensitive=True),
21
+ default="upload",
22
+ show_default=True,
20
23
  help=
21
- 'Flag to download checkpoints before uploading and including them in the tar file that is uploaded. Defaults to False, which will use the "when" field in config.yaml checkpoints section which can be "upload", "build", or "runtime".',
24
+ 'The stage we are calling download checkpoints from. Typically this would "upload" and will download checkpoints if config.yaml checkpoints section has when set to "upload". Other options include "runtime" to be used in load_model or "upload" to be used during model upload. Set this stage to whatever you have in config.yaml to force downloading now.'
22
25
  )
23
26
  @click.option(
24
27
  '--skip_dockerfile',
@@ -26,13 +29,9 @@ def model():
26
29
  help=
27
30
  'Flag to skip generating a dockerfile so that you can manually edit an already created dockerfile.',
28
31
  )
29
- def upload(model_path, download_checkpoints, skip_dockerfile):
32
+ def upload(model_path, stage, skip_dockerfile):
30
33
  """Upload a model to Clarifai."""
31
34
  from clarifai.runners.models.model_builder import upload_model
32
- if download_checkpoints:
33
- stage = "any" # ignore config.yaml and force download now.
34
- else:
35
- stage = "upload"
36
35
  upload_model(model_path, stage, skip_dockerfile)
37
36
 
38
37
 
@@ -52,12 +51,12 @@ def upload(model_path, download_checkpoints, skip_dockerfile):
52
51
  )
53
52
  @click.option(
54
53
  '--stage',
55
- type=str,
56
54
  required=False,
55
+ type=click.Choice(['runtime', 'build', 'upload'], case_sensitive=True),
57
56
  default="build",
58
57
  show_default=True,
59
58
  help=
60
- 'The stage we are calling download checkpoints from. Typically this would be in the build stage which is the default. Other options include "runtime" to be used in load_model, "upload" to be used during model upload or "any" which will force download now regardless of config.yaml'
59
+ 'The stage we are calling download checkpoints from. Typically this would be in the build stage which is the default. Other options include "runtime" to be used in load_model or "upload" to be used during model upload. Set this stage to whatever you have in config.yaml to force downloading now.'
61
60
  )
62
61
  def download_checkpoints(model_path, out_path, stage):
63
62
  """Download checkpoints from external source to local model_path"""
@@ -172,6 +171,18 @@ def run_locally(model_path, port, mode, keep_env, keep_image):
172
171
  click.echo(f"Failed to starts model server locally: {e}", err=True)
173
172
 
174
173
 
174
+ @model.command()
175
+ @click.option(
176
+ '--model_path',
177
+ type=click.Path(exists=True),
178
+ required=True,
179
+ help='Path to the model directory.')
180
+ def local_dev(model_path):
181
+ """Run the model as a local dev runner to help debug your model connected to the API. You must set several envvars such as CLARIFAI_PAT, CLARIFAI_RUNNER_ID, CLARIFAI_NODEPOOL_ID, CLARIFAI_COMPUTE_CLUSTER_ID. """
182
+ from clarifai.runners.server import serve
183
+ serve(model_path)
184
+
185
+
175
186
  @model.command()
176
187
  @click.option(
177
188
  '--config',
clarifai/client/model.py CHANGED
@@ -26,7 +26,7 @@ from clarifai.constants.model import (CHUNK_SIZE, MAX_CHUNK_SIZE, MAX_MODEL_PRED
26
26
  from clarifai.errors import UserError
27
27
  from clarifai.urls.helper import ClarifaiUrlHelper
28
28
  from clarifai.utils.logging import logger
29
- from clarifai.utils.misc import BackoffIterator
29
+ from clarifai.utils.misc import BackoffIterator, status_is_retryable
30
30
  from clarifai.utils.model_train import (find_and_replace_key, params_parser,
31
31
  response_to_model_params, response_to_param_info,
32
32
  response_to_templates)
@@ -438,7 +438,7 @@ class Model(Lister, BaseClient):
438
438
  while True:
439
439
  response = self._grpc_request(self.STUB.PostModelOutputs, request)
440
440
 
441
- if response.status.code == status_code_pb2.MODEL_DEPLOYING and \
441
+ if status_is_retryable(response.status.code) and \
442
442
  time.time() - start_time < 60 * 10: # 10 minutes
443
443
  self.logger.info(f"{self.id} model is still deploying, please wait...")
444
444
  time.sleep(next(backoff_iterator))
@@ -721,7 +721,7 @@ class Model(Lister, BaseClient):
721
721
  break
722
722
  stream_response = self._grpc_request(self.STUB.GenerateModelOutputs, request)
723
723
  for response in stream_response:
724
- if response.status.code == status_code_pb2.MODEL_DEPLOYING and \
724
+ if status_is_retryable(response.status.code) and \
725
725
  time.time() - start_time < 60 * 10:
726
726
  self.logger.info(f"{self.id} model is still deploying, please wait...")
727
727
  time.sleep(next(backoff_iterator))
@@ -965,7 +965,7 @@ class Model(Lister, BaseClient):
965
965
  break
966
966
  stream_response = self._grpc_request(self.STUB.StreamModelOutputs, request)
967
967
  for response in stream_response:
968
- if response.status.code == status_code_pb2.MODEL_DEPLOYING and \
968
+ if status_is_retryable(response.status.code) and \
969
969
  time.time() - start_time < 60 * 10:
970
970
  self.logger.info(f"{self.id} model is still deploying, please wait...")
971
971
  time.sleep(next(backoff_iterator))
@@ -15,7 +15,7 @@ from clarifai.constants.workflow import MAX_WORKFLOW_PREDICT_INPUTS
15
15
  from clarifai.errors import UserError
16
16
  from clarifai.urls.helper import ClarifaiUrlHelper
17
17
  from clarifai.utils.logging import logger
18
- from clarifai.utils.misc import BackoffIterator
18
+ from clarifai.utils.misc import BackoffIterator, status_is_retryable
19
19
  from clarifai.workflows.export import Exporter
20
20
 
21
21
 
@@ -99,7 +99,7 @@ class Workflow(Lister, BaseClient):
99
99
  while True:
100
100
  response = self._grpc_request(self.STUB.PostWorkflowResults, request)
101
101
 
102
- if response.status.code == status_code_pb2.MODEL_DEPLOYING and \
102
+ if status_is_retryable(response.status.code) and \
103
103
  time.time() - start_time < 60*10: # 10 minutes
104
104
  self.logger.info(f"{self.id} Workflow is still deploying, please wait...")
105
105
  time.sleep(next(backoff_iterator))
@@ -1,30 +1,11 @@
1
1
  # syntax=docker/dockerfile:1.13-labs
2
- #############################
3
- # User specific requirements installed in the pip_packages
4
- #############################
5
- FROM --platform=$TARGETPLATFORM ${FINAL_IMAGE} as pip_packages
2
+ FROM --platform=$TARGETPLATFORM ${FINAL_IMAGE} as final
6
3
 
7
4
  COPY --link requirements.txt /home/nonroot/requirements.txt
8
5
 
9
6
  # Update clarifai package so we always have latest protocol to the API. Everything should land in /venv
10
7
  RUN ["pip", "install", "--no-cache-dir", "-r", "/home/nonroot/requirements.txt"]
11
8
  RUN ["pip", "show", "clarifai"]
12
- #############################
13
-
14
- #############################
15
- # Downloader dependencies image
16
- #############################
17
- FROM --platform=$TARGETPLATFORM ${DOWNLOADER_IMAGE} as downloader
18
-
19
- # make sure we have the latest clarifai package. This version is filled in by SDK.
20
- RUN ["pip", "install", "clarifai==${CLARIFAI_VERSION}"]
21
- #####
22
-
23
-
24
- #############################
25
- # Final runtime image
26
- #############################
27
- FROM --platform=$TARGETPLATFORM ${FINAL_IMAGE} as final
28
9
 
29
10
  # Set the NUMBA cache dir to /tmp
30
11
  # Set the TORCHINDUCTOR cache dir to /tmp
@@ -34,12 +15,6 @@ ENV NUMBA_CACHE_DIR=/tmp/numba_cache \
34
15
  HOME=/tmp \
35
16
  DEBIAN_FRONTEND=noninteractive
36
17
 
37
- #####
38
- # Copy the python requirements needed to download checkpoints
39
- #####
40
- COPY --link=true --from=downloader /venv /venv
41
- #####
42
-
43
18
  #####
44
19
  # Copy the files needed to download
45
20
  #####
@@ -52,12 +27,6 @@ COPY --link=true config.yaml /home/nonroot/main/
52
27
  RUN ["python", "-m", "clarifai.cli", "model", "download-checkpoints", "--model_path", "/home/nonroot/main", "--out_path", "/home/nonroot/main/1/checkpoints", "--stage", "build"]
53
28
  #####
54
29
 
55
-
56
- #####
57
- # Copy the python packages from the builder stage.
58
- COPY --link=true --from=pip_packages /venv /venv
59
- #####
60
-
61
30
  # Copy in the actual files like config.yaml, requirements.txt, and most importantly 1/model.py
62
31
  # for the actual model.
63
32
  # If checkpoints aren't downloaded since a checkpoints: block is not provided, then they will
@@ -159,7 +159,6 @@ class ModelBuilder:
159
159
  f"No 'when' specified in the config file for checkpoints, defaulting to download at {DEFAULT_DOWNLOAD_CHECKPOINT_WHEN}"
160
160
  )
161
161
  when = checkpoints.get("when", DEFAULT_DOWNLOAD_CHECKPOINT_WHEN)
162
- # In the config.yaml we don't allow "any", that's only used in download_checkpoints to force download.
163
162
  assert when in [
164
163
  "upload",
165
164
  "build",
@@ -366,10 +365,10 @@ class ModelBuilder:
366
365
  if 'python_version' in build_info:
367
366
  python_version = build_info['python_version']
368
367
  if python_version not in AVAILABLE_PYTHON_IMAGES:
369
- logger.error(
370
- f"Python version {python_version} not supported, please use one of the following versions: {AVAILABLE_PYTHON_IMAGES}"
368
+ raise Exception(
369
+ f"Python version {python_version} not supported, please use one of the following versions: {AVAILABLE_PYTHON_IMAGES} in your config.yaml"
371
370
  )
372
- return
371
+
373
372
  logger.info(
374
373
  f"Using Python version {python_version} from the config file to build the Dockerfile")
375
374
  else:
@@ -443,7 +442,7 @@ class ModelBuilder:
443
442
 
444
443
  @property
445
444
  def checkpoint_suffix(self):
446
- return '1/checkpoints'
445
+ return os.path.join('1', 'checkpoints')
447
446
 
448
447
  @property
449
448
  def tar_file(self):
@@ -452,13 +451,15 @@ class ModelBuilder:
452
451
  def default_runtime_checkpoint_path(self):
453
452
  return DEFAULT_RUNTIME_DOWNLOAD_PATH
454
453
 
455
- def download_checkpoints(self, stage: str, checkpoint_path_override: str = None):
454
+ def download_checkpoints(self,
455
+ stage: str = DEFAULT_DOWNLOAD_CHECKPOINT_WHEN,
456
+ checkpoint_path_override: str = None):
456
457
  """
457
458
  Downloads the checkpoints specified in the config file.
458
459
 
459
460
  :param stage: The stage of the build process. This is used to determine when to download the
460
- checkpoints. The stage can be one of ['build', 'upload', 'runtime', 'any']. If "any" it will always try to download
461
- regardless of what is specified in config.yaml. Otherwise it must match what is in config.yaml
461
+ checkpoints. The stage can be one of ['build', 'upload', 'runtime']. If you want to force
462
+ downloading now then set stage to match e when field of the checkpoints section of you config.yaml.
462
463
  :param checkpoint_path_override: The path to download the checkpoints to (with 1/checkpoints added as suffix). If not provided, the
463
464
  default path is used based on the folder ModelUploader was initialized with. The checkpoint_suffix will be appended to the path.
464
465
  If stage is 'runtime' and checkpoint_path_override is None, the default runtime path will be used.
@@ -471,9 +472,9 @@ class ModelBuilder:
471
472
  return path
472
473
 
473
474
  loader_type, repo_id, hf_token, when = self._validate_config_checkpoints()
474
- if stage not in ["build", "upload", "runtime", "any"]:
475
+ if stage not in ["build", "upload", "runtime"]:
475
476
  raise Exception("Invalid stage provided, must be one of ['build', 'upload', 'runtime']")
476
- if when != stage and stage != "any":
477
+ if when != stage:
477
478
  logger.info(
478
479
  f"Skipping downloading checkpoints for stage {stage} since config.yaml says to download them at stage {when}"
479
480
  )
@@ -588,7 +589,7 @@ class ModelBuilder:
588
589
 
589
590
  def filter_func(tarinfo):
590
591
  name = tarinfo.name
591
- exclude = [self.tar_file, "*~"]
592
+ exclude = [self.tar_file, "*~", "*.pyc", "*.pyo", "__pycache__"]
592
593
  if when != "upload":
593
594
  exclude.append(self.checkpoint_suffix)
594
595
  return None if any(name.endswith(ex) for ex in exclude) else tarinfo
@@ -739,8 +740,8 @@ def upload_model(folder, stage, skip_dockerfile):
739
740
  Uploads a model to Clarifai.
740
741
 
741
742
  :param folder: The folder containing the model files.
742
- :param stage: The stage of when you're uploading this model. This is used to determine when to download the checkpoints based on a match with the "when" field in the config.yaml checkpoints section or if you set stage to "any" it will always download the checkpoints.
743
- :param skip_dockerfile: If True, skips creating the Dockerfile so you can re-use the local one.
743
+ :param stage: The stage we are calling download checkpoints from. Typically this would "upload" and will download checkpoints if config.yaml checkpoints section has when set to "upload". Other options include "runtime" to be used in load_model or "upload" to be used during model upload. Set this stage to whatever you have in config.yaml to force downloading now.
744
+ :param skip_dockerfile: If True, will not create a Dockerfile.
744
745
  """
745
746
  builder = ModelBuilder(folder)
746
747
  builder.download_checkpoints(stage=stage)
@@ -481,8 +481,11 @@ def main(model_path,
481
481
  )
482
482
  sys.exit(1)
483
483
  manager = ModelRunLocally(model_path)
484
- # stage="any" forces downloaded now regardless of config.yaml
485
- manager.builder.download_checkpoints(stage="any")
484
+ # get whatever stage is in config.yaml to force download now
485
+ # also always write to where upload/build wants to, not the /tmp folder that runtime stage uses
486
+ _, _, _, when = manager.builder._validate_config_checkpoints()
487
+ manager.builder.download_checkpoints(
488
+ stage=when, checkpoint_path_override=manager.builder.checkpoint_path)
486
489
  if inside_container:
487
490
  if not manager.is_docker_installed():
488
491
  sys.exit(1)
@@ -68,30 +68,43 @@ def main():
68
68
 
69
69
  parsed_args = parser.parse_args()
70
70
 
71
- builder = ModelBuilder(parsed_args.model_path, download_validation_only=True)
71
+ serve(parsed_args.model_path, parsed_args.port, parsed_args.pool_size,
72
+ parsed_args.max_queue_size, parsed_args.max_msg_length, parsed_args.enable_tls,
73
+ parsed_args.grpc)
74
+
75
+
76
+ def serve(model_path,
77
+ port=8000,
78
+ pool_size=32,
79
+ max_queue_size=10,
80
+ max_msg_length=1024 * 1024 * 1024,
81
+ enable_tls=False,
82
+ grpc=False):
83
+
84
+ builder = ModelBuilder(model_path, download_validation_only=True)
72
85
 
73
86
  model = builder.create_model_instance()
74
87
 
75
88
  # Setup the grpc server for local development.
76
- if parsed_args.grpc:
89
+ if grpc:
77
90
 
78
91
  # initialize the servicer with the runner so that it gets the predict(), generate(), stream() classes.
79
92
  servicer = ModelServicer(model)
80
93
 
81
94
  server = GRPCServer(
82
95
  futures.ThreadPoolExecutor(
83
- max_workers=parsed_args.pool_size,
96
+ max_workers=pool_size,
84
97
  thread_name_prefix="ServeCalls",
85
98
  ),
86
- parsed_args.max_msg_length,
87
- parsed_args.max_queue_size,
99
+ max_msg_length,
100
+ max_queue_size,
88
101
  )
89
- server.add_port_to_server('[::]:%s' % parsed_args.port, parsed_args.enable_tls)
102
+ server.add_port_to_server('[::]:%s' % port, enable_tls)
90
103
 
91
104
  service_pb2_grpc.add_V2Servicer_to_server(servicer, server)
92
105
  server.start()
93
- logger.info("Started server on port %s", parsed_args.port)
94
- logger.info(f"Access the model at http://localhost:{parsed_args.port}")
106
+ logger.info("Started server on port %s", port)
107
+ logger.info(f"Access the model at http://localhost:{port}")
95
108
  server.wait_for_termination()
96
109
  else: # start the runner with the proper env variables and as a runner protocol.
97
110
 
@@ -16,7 +16,7 @@ DEFAULT_PYTHON_VERSION = 3.12
16
16
  DEFAULT_DOWNLOAD_CHECKPOINT_WHEN = "runtime"
17
17
 
18
18
  # Folder for downloading checkpoints at runtime.
19
- DEFAULT_RUNTIME_DOWNLOAD_PATH = "/tmp/.cache"
19
+ DEFAULT_RUNTIME_DOWNLOAD_PATH = os.path.join(os.sep, "tmp", ".cache")
20
20
 
21
21
  # List of available torch images
22
22
  # Keep sorted by most recent cuda version.
clarifai/utils/misc.py CHANGED
@@ -3,8 +3,20 @@ import re
3
3
  import uuid
4
4
  from typing import Any, Dict, List
5
5
 
6
+ from clarifai_grpc.grpc.api.status import status_code_pb2
7
+
6
8
  from clarifai.errors import UserError
7
9
 
10
+ RETRYABLE_CODES = [
11
+ status_code_pb2.MODEL_DEPLOYING, status_code_pb2.MODEL_LOADING,
12
+ status_code_pb2.MODEL_BUSY_PLEASE_RETRY
13
+ ]
14
+
15
+
16
+ def status_is_retryable(status_code: int) -> bool:
17
+ """Check if a status code is retryable."""
18
+ return status_code in RETRYABLE_CODES
19
+
8
20
 
9
21
  class Chunker:
10
22
  """Split an input sequence into small chunks."""
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: clarifai
3
- Version: 11.1.4rc2
3
+ Version: 11.1.5
4
4
  Summary: Clarifai Python SDK
5
5
  Home-page: https://github.com/Clarifai/clarifai-python
6
6
  Author: Clarifai
@@ -20,20 +20,31 @@ 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 >=11.0.7
24
- Requires-Dist: clarifai-protocol >=0.0.16
25
- Requires-Dist: numpy >=1.22.0
26
- Requires-Dist: tqdm >=4.65.0
27
- Requires-Dist: rich >=13.4.2
28
- Requires-Dist: PyYAML >=6.0.1
29
- Requires-Dist: schema ==0.7.5
30
- Requires-Dist: Pillow >=9.5.0
31
- Requires-Dist: tabulate >=0.9.0
32
- Requires-Dist: fsspec >=2024.6.1
33
- Requires-Dist: click >=8.1.7
34
- Requires-Dist: requests >=2.32.3
23
+ Requires-Dist: clarifai-grpc>=11.1.3
24
+ Requires-Dist: clarifai-protocol>=0.0.16
25
+ Requires-Dist: numpy>=1.22.0
26
+ Requires-Dist: tqdm>=4.65.0
27
+ Requires-Dist: rich>=13.4.2
28
+ Requires-Dist: PyYAML>=6.0.1
29
+ Requires-Dist: schema==0.7.5
30
+ Requires-Dist: Pillow>=9.5.0
31
+ Requires-Dist: tabulate>=0.9.0
32
+ Requires-Dist: fsspec>=2024.6.1
33
+ Requires-Dist: click>=8.1.7
34
+ Requires-Dist: requests>=2.32.3
35
35
  Provides-Extra: all
36
- Requires-Dist: pycocotools ==2.0.6 ; extra == 'all'
36
+ Requires-Dist: pycocotools==2.0.6; extra == "all"
37
+ Dynamic: author
38
+ Dynamic: author-email
39
+ Dynamic: classifier
40
+ Dynamic: description
41
+ Dynamic: description-content-type
42
+ Dynamic: home-page
43
+ Dynamic: license
44
+ Dynamic: provides-extra
45
+ Dynamic: requires-dist
46
+ Dynamic: requires-python
47
+ Dynamic: summary
37
48
 
38
49
  <h1 align="center">
39
50
  <a href="https://www.clarifai.com/"><img alt="Clarifai" title="Clarifai" src="https://github.com/user-attachments/assets/623b883b-7fe5-4b95-bbfa-8691f5779af4"></a>
@@ -0,0 +1,101 @@
1
+ clarifai/__init__.py,sha256=HNrgaOFUAWYh8yQEI1yC5ehweLTfZlW4BUMnm8AXQxw,23
2
+ clarifai/cli.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ clarifai/errors.py,sha256=RwzTajwds51wLD0MVlMC5kcpBnzRpreDLlazPSBZxrg,2605
4
+ clarifai/versions.py,sha256=jctnczzfGk_S3EnVqb2FjRKfSREkNmvNEwAAa_VoKiQ,222
5
+ clarifai/cli/README.md,sha256=YGApHfeUyu5P0Pdth-mqQCQftWHDxz6bugDlvDXDhOE,1942
6
+ clarifai/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ clarifai/cli/__main__.py,sha256=utJ2F40cl0jPHcYdTlGZRqpPfZ0CtVYB-8Ft0b2fWD4,72
8
+ clarifai/cli/base.py,sha256=eaUsp7S1e2dslC437Hjk7gUBQsng13ID3N3lkYotB2U,3403
9
+ clarifai/cli/compute_cluster.py,sha256=N2dNQNJEPg9nxsb8x2igEzYuGRzjn7l4kNttjFIxmhI,1827
10
+ clarifai/cli/deployment.py,sha256=sUEuz5-rtozMx8deVcJXLi6lHsP2jc8x3y2MpUAVfqY,2506
11
+ clarifai/cli/model.py,sha256=ShFUgYep4_CbOn6cK4FdOBiw2vpcqlPUf-LX_TZ0fYo,11265
12
+ clarifai/cli/nodepool.py,sha256=yihxS_rIFoBBKzRlqBX8Ab42iPpBMJrJFsk8saph6ms,3049
13
+ clarifai/client/__init__.py,sha256=xI1U0l5AZdRThvQAXCLsd9axxyFzXXJ22m8LHqVjQRU,662
14
+ clarifai/client/app.py,sha256=6pckYme1urV2YJjLIYfeZ-vH0Z5YSQa51jzIMcEfwug,38342
15
+ clarifai/client/base.py,sha256=hSHOqkXbSKyaRDeylMMnkhUHCAHhEqno4KI0CXGziBA,7536
16
+ clarifai/client/compute_cluster.py,sha256=EvW9TJjPvInUlggfg1A98sxoWH8_PY5rCVXZhsj6ac0,8705
17
+ clarifai/client/dataset.py,sha256=y3zKT_VhP1gyN3OO-b3cPeW21ZXyKbQ7ZJkEG06bsTU,32096
18
+ clarifai/client/deployment.py,sha256=w7Y6pA1rYG4KRK1SwusRZc2sQRXlG8wezuVdzSWpCo0,2586
19
+ clarifai/client/input.py,sha256=obMAHMDU1OwfXZ8KraOnGFlWzlW-3F7Ob_2lcOQMlhY,46339
20
+ clarifai/client/lister.py,sha256=03KGMvs5RVyYqxLsSrWhNc34I8kiF1Ph0NeyEwu7nMU,2082
21
+ clarifai/client/model.py,sha256=vkp8hrCMcKWzEVBN68RzSVTkN3qZn342wcaj_a6qu0M,88599
22
+ clarifai/client/module.py,sha256=FTkm8s9m-EaTKN7g9MnLhGJ9eETUfKG7aWZ3o1RshYs,4204
23
+ clarifai/client/nodepool.py,sha256=la3vTFrO4LX8zm2eQ5jqf2L0-kQ63Dano8FibadoZbk,10152
24
+ clarifai/client/search.py,sha256=GaPWN6JmTQGZaCHr6U1yv0zqR6wKFl7i9IVLg2ul1CI,14254
25
+ clarifai/client/user.py,sha256=WOv66ww2wx9isIge3V-xTHCkqC6akl2jEGAxzT_Ugfs,17642
26
+ clarifai/client/workflow.py,sha256=5VjZ2D8cudLznR8yhrwNawOmjxUhkJllZMKM6pn-4gs,12170
27
+ clarifai/client/auth/__init__.py,sha256=7EwR0NrozkAUwpUnCsqXvE_p0wqx_SelXlSpKShKJK0,136
28
+ clarifai/client/auth/helper.py,sha256=Ngw5IDkOWvnOz5YwViVk55z3mC52MyezLc0G3WxLqok,14643
29
+ clarifai/client/auth/register.py,sha256=2CMdBsoVLoTfjyksE6j7BM2tiEc73WKYvxnwDDgNn1k,536
30
+ clarifai/client/auth/stub.py,sha256=xy4-fV0W8keCgXld4eOVzFQEIKxOktNwtL5bLztReug,4940
31
+ clarifai/constants/base.py,sha256=ogmFSZYoF0YhGjHg5aiOc3MLqPr_poKAls6xaD0_C3U,89
32
+ clarifai/constants/dataset.py,sha256=vjK3IlgXu31HycuvjRSzEQSqhU6xfj5TIgo6IpyUWoc,609
33
+ clarifai/constants/input.py,sha256=WcHwToUVIK9ItAhDefaSohQHCLNeR55PSjZ0BFnoZ3U,28
34
+ clarifai/constants/model.py,sha256=Um1hLfMFlh5R_vtP3Z6P-o6zon-tdbLcKVIl4PucrV4,438
35
+ clarifai/constants/rag.py,sha256=WcHwToUVIK9ItAhDefaSohQHCLNeR55PSjZ0BFnoZ3U,28
36
+ clarifai/constants/search.py,sha256=yYEqTaFg-KdnpJE_Ytp-EPVHIIC395iNtZrpVlLIf4o,101
37
+ clarifai/constants/workflow.py,sha256=cECq1xdvf44MCdtK2AbkiuuwhyL-6OWZdQfYbsLKy_o,33
38
+ clarifai/datasets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
+ clarifai/datasets/export/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
+ clarifai/datasets/export/inputs_annotations.py,sha256=3AtUBrMIjw8H3ehDsJFYcBFoAZ1QKQo1hXTMsHh8f20,10159
41
+ clarifai/datasets/upload/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
42
+ clarifai/datasets/upload/base.py,sha256=UIc0ufyIBCrb83_sFpv21L8FshsX4nwsLYQkdlJfzD4,2357
43
+ clarifai/datasets/upload/features.py,sha256=GK69WvUYnks5G26Z5L5XSisBIZILLv7lYhS2y8BJCt0,2031
44
+ clarifai/datasets/upload/image.py,sha256=HlCsfEMu_C4GVecGSv52RUJ6laLW8H64Pfj_FQyX6qg,8580
45
+ clarifai/datasets/upload/multimodal.py,sha256=_NpNQak9KMn0NOiOr48MYnXL0GQZ1LXKhwdYF1HhrHs,2377
46
+ clarifai/datasets/upload/text.py,sha256=dpRMNz49EyKau0kwksEaNV6TLBUf5lSr7t5g3pG2byM,2298
47
+ clarifai/datasets/upload/utils.py,sha256=BerWhq40ZUN30z6VImlc93eZtT-1vI18AMgSOuNzJEM,9647
48
+ clarifai/datasets/upload/loaders/README.md,sha256=aNRutSCTzLp2ruIZx74ZkN5AxpzwKOxMa7OzabnKpwg,2980
49
+ clarifai/datasets/upload/loaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
50
+ clarifai/datasets/upload/loaders/coco_captions.py,sha256=YfuNXplbdoH8N9ph7RyN9MfJTtOcJBG4ie1ow6-mELA,1516
51
+ clarifai/datasets/upload/loaders/coco_detection.py,sha256=_I_yThw435KS9SH7zheBbJDK3zFgjTImBsES__ijjMk,2831
52
+ clarifai/datasets/upload/loaders/imagenet_classification.py,sha256=i7W5F6FTB3LwLmhPgjZHmbCbS3l4LmjsuBFKtjxl1pU,1962
53
+ clarifai/datasets/upload/loaders/xview_detection.py,sha256=hk8cZdYZimm4KOaZvBjYcC6ikURZMn51xmn7pXZT3HE,6052
54
+ clarifai/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
+ clarifai/models/api.py,sha256=d3FQQlG0mNDLrfEvchqaVcq4Tgb_TqryNnJtwp3c7sE,10961
56
+ clarifai/modules/README.md,sha256=mx8pVx6cPp-pP4LcFPT_nX3ngGmhygVK0WiXeD3cbIo,367
57
+ clarifai/modules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
+ clarifai/modules/css.py,sha256=kadCEunmyh5h2yf0-4aysE3ZcZ6qaQcxuAgDXS96yF8,2020
59
+ clarifai/modules/pages.py,sha256=iOoM3RNRMgXlV0qBqcdQofxoXo2RuRQh0h9c9BIS0-I,1383
60
+ clarifai/modules/style.css,sha256=j7FNPZVhLPj35vvBksAJ90RuX5sLuqzDR5iM2WIEhiA,6073
61
+ clarifai/rag/__init__.py,sha256=wu3PzAzo7uqgrEzuaC9lY_3gj1HFiR3GU3elZIKTT5g,40
62
+ clarifai/rag/rag.py,sha256=bqUWnfdf91OYMucEK0_rJXDwg0oKjz5c7eda-9CPXu8,12680
63
+ clarifai/rag/utils.py,sha256=yr1jAcbpws4vFGBqlAwPPE7v1DRba48g8gixLFw8OhQ,4070
64
+ clarifai/runners/__init__.py,sha256=FcTqyCvPn9lJFDsi2eGZ-YL8LgPhJmRAS8K5Wobk03s,411
65
+ clarifai/runners/server.py,sha256=ekrC9nl_hyMmYoK-PnHlSoll0A0xClJLSzj_5YKBwww,3923
66
+ clarifai/runners/dockerfile_template/Dockerfile.template,sha256=NW73cPGtk0QmZsv2ikAgP_G7VQQbrUQilHtD6PtiLFs,2328
67
+ clarifai/runners/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
68
+ clarifai/runners/models/base_typed_model.py,sha256=0QCWxch8CcyJSKvE1D4PILd2RSnQZHTmx4DXlQQ6dpo,7856
69
+ clarifai/runners/models/model_builder.py,sha256=4aEAi0IkMVodhd7bhu35CwGyX7bjtI5sfV_j02ooW7M,32062
70
+ clarifai/runners/models/model_class.py,sha256=9JSPAr4U4K7xI0kSl-q0mHB06zknm2OR-8XIgBCto94,1611
71
+ clarifai/runners/models/model_run_locally.py,sha256=V770O-7yQQQlh80u48NZTEHkX3gj1HyclHbu1tjvaQ8,20864
72
+ clarifai/runners/models/model_runner.py,sha256=PyxwK-33hLlhkD07tTXkjWZ_iNlZHl9_8AZ2W7WfExI,6097
73
+ clarifai/runners/models/model_servicer.py,sha256=jtQmtGeQlvQ5ttMvVw7CMnNzq-rLkTaxR2IWF9SnHwk,2808
74
+ clarifai/runners/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
75
+ clarifai/runners/utils/const.py,sha256=bwj-Pcw558-pasdIFbNhnkn-9oiCdojYH1fNTTUG2gU,1048
76
+ clarifai/runners/utils/data_handler.py,sha256=sxy9zlAgI6ETuxCQhUgEXAn2GCsaW1GxpK6GTaMne0g,6966
77
+ clarifai/runners/utils/data_utils.py,sha256=R1iQ82TuQ9JwxCJk8yEB1Lyb0BYVhVbWJI9YDi1zGOs,318
78
+ clarifai/runners/utils/loader.py,sha256=SgNHMwRmCCymFQm8aDp73NmIUHhM-N60CBlTKbPzmVc,7470
79
+ clarifai/runners/utils/url_fetcher.py,sha256=v_8JOWmkyFAzsBulsieKX7Nfjy1Yg7wGSZeqfEvw2cg,1640
80
+ clarifai/schema/search.py,sha256=JjTi8ammJgZZ2OGl4K6tIA4zEJ1Fr2ASZARXavI1j5c,2448
81
+ clarifai/urls/helper.py,sha256=tjoMGGHuWX68DUB0pk4MEjrmFsClUAQj2jmVEM_Sy78,4751
82
+ clarifai/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
83
+ clarifai/utils/cli.py,sha256=CdcLsF00KdfA-BgMIbO-u88gUF9Ts1n0TDDZS-oImp8,1949
84
+ clarifai/utils/constants.py,sha256=MG_iHnSwNEyUZOpvsrTicNwaT4CIjmlK_Ixk_qqEX8g,142
85
+ clarifai/utils/logging.py,sha256=CVy8OsLrlbg-b8qe88kb1yO_9wi9wRYfF-QkIaN9xE8,11936
86
+ clarifai/utils/misc.py,sha256=4aNOHPTNdX-WGxuNab8qKePoCMUnscd-aN_dQEIVSWk,2933
87
+ clarifai/utils/model_train.py,sha256=Mndqy5GNu7kjQHjDyNVyamL0hQFLGSHcWhOuPyOvr1w,8005
88
+ clarifai/utils/evaluation/__init__.py,sha256=PYkurUrXrGevByj7RFb6CoU1iC7fllyQSfnnlo9WnY8,69
89
+ clarifai/utils/evaluation/helpers.py,sha256=aZeHLI7oSmU5YDWQp5GdkYW5qbHx37nV9xwunKTAwWM,18549
90
+ clarifai/utils/evaluation/main.py,sha256=sQAuMk0lPclXCYvy_rS7rYteo2xh9Ju13VNvbyGt_VM,15779
91
+ clarifai/utils/evaluation/testset_annotation_parser.py,sha256=iZfLw6oR1qgJ3MHMbOZXcGBLu7btSDn0VqdiAzpIm4g,5002
92
+ clarifai/workflows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
93
+ clarifai/workflows/export.py,sha256=vICRhIreqDSShxLKjHNM2JwzKsf1B4fdXB0ciMcA70k,1945
94
+ clarifai/workflows/utils.py,sha256=nGeB_yjVgUO9kOeKTg4OBBaBz-AwXI3m-huSVj-9W18,1924
95
+ clarifai/workflows/validate.py,sha256=yJq03MaJqi5AK3alKGJJBR89xmmjAQ31sVufJUiOqY8,2556
96
+ clarifai-11.1.5.dist-info/LICENSE,sha256=mUqF_d12-qE2n41g7C5_sq-BMLOcj6CNN-jevr15YHU,555
97
+ clarifai-11.1.5.dist-info/METADATA,sha256=g9oUOCn9hrX_ohdYCXiDGFZdJxJW-kmPm4PV4crMW7s,22419
98
+ clarifai-11.1.5.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
99
+ clarifai-11.1.5.dist-info/entry_points.txt,sha256=X9FZ4Z-i_r2Ud1RpZ9sNIFYuu_-9fogzCMCRUD9hyX0,51
100
+ clarifai-11.1.5.dist-info/top_level.txt,sha256=wUMdCQGjkxaynZ6nZ9FAnvBUCgp5RJUVFSy2j-KYo0s,9
101
+ clarifai-11.1.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: setuptools (75.8.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
Binary file
clarifai/cli/__main__.py~ DELETED
@@ -1,4 +0,0 @@
1
- from my_cli_tool.cli import main
2
-
3
- if __name__ == "__main__":
4
- main()