clarifai 10.9.1__tar.gz → 10.9.2__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 (112) hide show
  1. {clarifai-10.9.1/clarifai.egg-info → clarifai-10.9.2}/PKG-INFO +2 -2
  2. clarifai-10.9.2/clarifai/__init__.py +1 -0
  3. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/dataset.py +22 -0
  4. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/runners/dockerfile_template/Dockerfile.cuda.template +4 -0
  5. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/runners/models/model_run_locally.py +5 -3
  6. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/runners/models/model_upload.py +49 -25
  7. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/runners/utils/loader.py +37 -1
  8. {clarifai-10.9.1 → clarifai-10.9.2/clarifai.egg-info}/PKG-INFO +2 -2
  9. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai.egg-info/requires.txt +1 -1
  10. {clarifai-10.9.1 → clarifai-10.9.2}/requirements.txt +1 -1
  11. {clarifai-10.9.1 → clarifai-10.9.2}/tests/test_data_upload.py +7 -0
  12. clarifai-10.9.1/clarifai/__init__.py +0 -1
  13. {clarifai-10.9.1 → clarifai-10.9.2}/LICENSE +0 -0
  14. {clarifai-10.9.1 → clarifai-10.9.2}/MANIFEST.in +0 -0
  15. {clarifai-10.9.1 → clarifai-10.9.2}/README.md +0 -0
  16. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/cli.py +0 -0
  17. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/__init__.py +0 -0
  18. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/app.py +0 -0
  19. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/auth/__init__.py +0 -0
  20. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/auth/helper.py +0 -0
  21. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/auth/register.py +0 -0
  22. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/auth/stub.py +0 -0
  23. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/base.py +0 -0
  24. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/compute_cluster.py +0 -0
  25. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/deployment.py +0 -0
  26. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/input.py +0 -0
  27. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/lister.py +0 -0
  28. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/model.py +0 -0
  29. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/module.py +0 -0
  30. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/nodepool.py +0 -0
  31. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/search.py +0 -0
  32. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/user.py +0 -0
  33. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/client/workflow.py +0 -0
  34. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/constants/base.py +0 -0
  35. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/constants/dataset.py +0 -0
  36. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/constants/input.py +0 -0
  37. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/constants/model.py +0 -0
  38. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/constants/rag.py +0 -0
  39. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/constants/search.py +0 -0
  40. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/constants/workflow.py +0 -0
  41. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/datasets/__init__.py +0 -0
  42. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/datasets/export/__init__.py +0 -0
  43. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/datasets/export/inputs_annotations.py +0 -0
  44. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/datasets/upload/__init__.py +0 -0
  45. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/datasets/upload/base.py +0 -0
  46. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/datasets/upload/features.py +0 -0
  47. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/datasets/upload/image.py +0 -0
  48. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/datasets/upload/loaders/README.md +0 -0
  49. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/datasets/upload/loaders/__init__.py +0 -0
  50. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/datasets/upload/loaders/coco_captions.py +0 -0
  51. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/datasets/upload/loaders/coco_detection.py +0 -0
  52. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/datasets/upload/loaders/imagenet_classification.py +0 -0
  53. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/datasets/upload/loaders/xview_detection.py +0 -0
  54. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/datasets/upload/multimodal.py +0 -0
  55. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/datasets/upload/text.py +0 -0
  56. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/datasets/upload/utils.py +0 -0
  57. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/errors.py +0 -0
  58. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/models/__init__.py +0 -0
  59. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/models/api.py +0 -0
  60. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/modules/README.md +0 -0
  61. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/modules/__init__.py +0 -0
  62. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/modules/css.py +0 -0
  63. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/modules/pages.py +0 -0
  64. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/modules/style.css +0 -0
  65. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/rag/__init__.py +0 -0
  66. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/rag/rag.py +0 -0
  67. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/rag/utils.py +0 -0
  68. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/runners/__init__.py +0 -0
  69. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/runners/dockerfile_template/Dockerfile.cpu.template +0 -0
  70. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/runners/models/__init__.py +0 -0
  71. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/runners/models/base_typed_model.py +0 -0
  72. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/runners/models/model_class.py +0 -0
  73. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/runners/models/model_runner.py +0 -0
  74. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/runners/models/model_servicer.py +0 -0
  75. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/runners/server.py +0 -0
  76. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/runners/utils/__init__.py +0 -0
  77. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/runners/utils/data_handler.py +0 -0
  78. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/runners/utils/data_utils.py +0 -0
  79. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/runners/utils/url_fetcher.py +0 -0
  80. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/schema/search.py +0 -0
  81. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/urls/helper.py +0 -0
  82. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/utils/__init__.py +0 -0
  83. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/utils/constants.py +0 -0
  84. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/utils/evaluation/__init__.py +0 -0
  85. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/utils/evaluation/helpers.py +0 -0
  86. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/utils/evaluation/main.py +0 -0
  87. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/utils/evaluation/testset_annotation_parser.py +0 -0
  88. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/utils/logging.py +0 -0
  89. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/utils/misc.py +0 -0
  90. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/utils/model_train.py +0 -0
  91. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/versions.py +0 -0
  92. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/workflows/__init__.py +0 -0
  93. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/workflows/export.py +0 -0
  94. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/workflows/utils.py +0 -0
  95. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai/workflows/validate.py +0 -0
  96. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai.egg-info/SOURCES.txt +0 -0
  97. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai.egg-info/dependency_links.txt +0 -0
  98. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai.egg-info/entry_points.txt +0 -0
  99. {clarifai-10.9.1 → clarifai-10.9.2}/clarifai.egg-info/top_level.txt +0 -0
  100. {clarifai-10.9.1 → clarifai-10.9.2}/pyproject.toml +0 -0
  101. {clarifai-10.9.1 → clarifai-10.9.2}/setup.cfg +0 -0
  102. {clarifai-10.9.1 → clarifai-10.9.2}/setup.py +0 -0
  103. {clarifai-10.9.1 → clarifai-10.9.2}/tests/test_app.py +0 -0
  104. {clarifai-10.9.1 → clarifai-10.9.2}/tests/test_auth.py +0 -0
  105. {clarifai-10.9.1 → clarifai-10.9.2}/tests/test_eval.py +0 -0
  106. {clarifai-10.9.1 → clarifai-10.9.2}/tests/test_misc.py +0 -0
  107. {clarifai-10.9.1 → clarifai-10.9.2}/tests/test_model_predict.py +0 -0
  108. {clarifai-10.9.1 → clarifai-10.9.2}/tests/test_model_train.py +0 -0
  109. {clarifai-10.9.1 → clarifai-10.9.2}/tests/test_modules.py +0 -0
  110. {clarifai-10.9.1 → clarifai-10.9.2}/tests/test_rag.py +0 -0
  111. {clarifai-10.9.1 → clarifai-10.9.2}/tests/test_search.py +0 -0
  112. {clarifai-10.9.1 → clarifai-10.9.2}/tests/test_stub.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clarifai
3
- Version: 10.9.1
3
+ Version: 10.9.2
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.8.8
23
+ Requires-Dist: clarifai-grpc>=10.9.4
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
@@ -0,0 +1 @@
1
+ __version__ = "10.9.2"
@@ -628,6 +628,28 @@ class Dataset(Lister, BaseClient):
628
628
  if delete_version:
629
629
  self.delete_version(dataset_version_id)
630
630
 
631
+ def merge_dataset(self, merge_dataset_id: str) -> None:
632
+ """Merges the another dataset into current dataset.
633
+
634
+ Args:
635
+ merge_dataset_id (str): The dataset ID of the dataset to merge.
636
+
637
+ Example:
638
+ >>> from clarifai.client.dataset import Dataset
639
+ >>> dataset = Dataset(dataset_id='dataset_id', user_id='user_id', app_id='app_id')
640
+ >>> dataset.merge_dataset(merge_dataset_id='merge_dataset_id')
641
+ """
642
+ dataset_filter = resources_pb2.Filter(
643
+ input=resources_pb2.Input(dataset_ids=[merge_dataset_id]))
644
+ query = resources_pb2.Search(query=resources_pb2.Query(filters=[dataset_filter]))
645
+ request = service_pb2.PostDatasetInputsRequest(
646
+ user_app_id=self.user_app_id, dataset_id=self.id, search=query)
647
+
648
+ response = self._grpc_request(self.STUB.PostDatasetInputs, request)
649
+ if response.status.code != status_code_pb2.SUCCESS:
650
+ raise Exception(response.status)
651
+ self.logger.info("\nDataset Merged\n%s", response.status)
652
+
631
653
  def archive_zip(self, wait: bool = True) -> str:
632
654
  """Exports the dataset to a zip file URL."""
633
655
  request = service_pb2.PutDatasetVersionExportsRequest(
@@ -64,6 +64,10 @@ ENV CLARIFAI_NODEPOOL_ID=${CLARIFAI_NODEPOOL_ID}
64
64
  ENV CLARIFAI_COMPUTE_CLUSTER_ID=${CLARIFAI_COMPUTE_CLUSTER_ID}
65
65
  ENV CLARIFAI_API_BASE=${CLARIFAI_API_BASE}
66
66
 
67
+ # Set the NUMBA cache dir to /tmp
68
+ ENV NUMBA_CACHE_DIR=/tmp/numba_cache
69
+ ENV HOME=/tmp
70
+
67
71
  # Set the working directory to /app
68
72
  WORKDIR /app
69
73
 
@@ -22,8 +22,6 @@ class ModelRunLocally:
22
22
  def __init__(self, model_path):
23
23
  self.model_path = model_path
24
24
  self.requirements_file = os.path.join(self.model_path, "requirements.txt")
25
- self.venv_dir, self.temp_dir = self.create_temp_venv()
26
- self.python_executable = os.path.join(self.venv_dir, "bin", "python")
27
25
 
28
26
  def create_temp_venv(self):
29
27
  """Create a temporary virtual environment."""
@@ -32,6 +30,10 @@ class ModelRunLocally:
32
30
  venv_dir = os.path.join(temp_dir, "venv")
33
31
  venv.create(venv_dir, with_pip=True)
34
32
 
33
+ self.venv_dir = venv_dir
34
+ self.temp_dir = temp_dir
35
+ self.python_executable = os.path.join(venv_dir, "bin", "python")
36
+
35
37
  logger.info(f"Created temporary virtual environment at {venv_dir}")
36
38
  return venv_dir, temp_dir
37
39
 
@@ -125,7 +127,6 @@ class ModelRunLocally:
125
127
  nodepool_id="n/a",
126
128
  compute_cluster_id="n/a",
127
129
  )
128
- runner.load_model()
129
130
 
130
131
  # send an inference.
131
132
  response = self._run_model_inference(runner)
@@ -182,6 +183,7 @@ def main():
182
183
 
183
184
  model_path = args.model_path
184
185
  manager = ModelRunLocally(model_path)
186
+ manager.create_temp_venv()
185
187
 
186
188
  try:
187
189
  manager.install_requirements()
@@ -60,9 +60,6 @@ class ModelUploader:
60
60
  return config
61
61
 
62
62
  def _validate_config_checkpoints(self):
63
- if not self.config.get("checkpoints"):
64
- logger.info("No checkpoints specified in the config file")
65
- return None
66
63
 
67
64
  assert "type" in self.config.get("checkpoints"), "No loader type specified in the config file"
68
65
  loader_type = self.config.get("checkpoints").get("type")
@@ -201,15 +198,20 @@ class ModelUploader:
201
198
  return f"{self.folder}.tar.gz"
202
199
 
203
200
  def download_checkpoints(self):
201
+ if not self.config.get("checkpoints"):
202
+ logger.info("No checkpoints specified in the config file")
203
+ return True
204
+
204
205
  repo_id, hf_token = self._validate_config_checkpoints()
205
- if repo_id and hf_token:
206
- loader = HuggingFaceLoader(repo_id=repo_id, token=hf_token)
207
- success = loader.download_checkpoints(self.checkpoint_path)
208
206
 
209
- if not success:
210
- logger.error(f"Failed to download checkpoints for model {repo_id}")
211
- return
207
+ loader = HuggingFaceLoader(repo_id=repo_id, token=hf_token)
208
+ success = loader.download_checkpoints(self.checkpoint_path)
209
+
210
+ if not success:
211
+ logger.error(f"Failed to download checkpoints for model {repo_id}")
212
+ else:
212
213
  logger.info(f"Downloaded checkpoints for model {repo_id}")
214
+ return success
213
215
 
214
216
  def _concepts_protos_from_concepts(self, concepts):
215
217
  concept_protos = []
@@ -245,15 +247,23 @@ class ModelUploader:
245
247
  model_type_id = self.config.get('model').get('model_type_id')
246
248
  if model_type_id in self.CONCEPTS_REQUIRED_MODEL_TYPE:
247
249
 
248
- labels = HuggingFaceLoader.fetch_labels(self.checkpoint_path)
249
- # sort the concepts by id and then update the config file
250
- labels = sorted(labels.items(), key=lambda x: int(x[0]))
250
+ if 'concepts' in self.config:
251
+ labels = self.config.get('concepts')
252
+ logger.info(f"Found {len(labels)} concepts in the config file.")
253
+ for concept in labels:
254
+ concept_proto = json_format.ParseDict(concept, resources_pb2.Concept())
255
+ model_version_proto.output_info.data.concepts.append(concept_proto)
256
+ else:
257
+ labels = HuggingFaceLoader.fetch_labels(self.checkpoint_path)
258
+ logger.info(f"Found {len(labels)} concepts from the model checkpoints.")
259
+ # sort the concepts by id and then update the config file
260
+ labels = sorted(labels.items(), key=lambda x: int(x[0]))
251
261
 
252
- config_file = os.path.join(self.folder, 'config.yaml')
253
- self.hf_labels_to_config(labels, config_file)
262
+ config_file = os.path.join(self.folder, 'config.yaml')
263
+ self.hf_labels_to_config(labels, config_file)
254
264
 
255
- model_version_proto.output_info.data.concepts.extend(
256
- self._concepts_protos_from_concepts(labels))
265
+ model_version_proto.output_info.data.concepts.extend(
266
+ self._concepts_protos_from_concepts(labels))
257
267
  return model_version_proto
258
268
 
259
269
  def upload_model_version(self, download_checkpoints):
@@ -261,17 +271,31 @@ class ModelUploader:
261
271
  logger.info(f"Will tar it into file: {file_path}")
262
272
 
263
273
  model_type_id = self.config.get('model').get('model_type_id')
264
- repo_id, hf_token = self._validate_config_checkpoints()
265
-
266
- loader = HuggingFaceLoader(repo_id=repo_id, token=hf_token)
267
274
 
268
- if not download_checkpoints and not loader.validate_download(self.checkpoint_path) and (
269
- model_type_id in self.CONCEPTS_REQUIRED_MODEL_TYPE) and 'concepts' not in self.config:
270
- logger.error(
271
- f"Model type {model_type_id} requires concepts to be specified in the config file or download the model checkpoints to infer the concepts."
275
+ if (model_type_id in self.CONCEPTS_REQUIRED_MODEL_TYPE) and 'concepts' not in self.config:
276
+ logger.info(
277
+ f"Model type {model_type_id} requires concepts to be specified in the config.yaml file.."
272
278
  )
273
- input("Press Enter to download the checkpoints to infer the concepts and continue...")
274
- self.download_checkpoints()
279
+ if self.config.get("checkpoints"):
280
+ logger.info(
281
+ "Checkpoints specified in the config.yaml file, will download the HF model's config.json file to infer the concepts."
282
+ )
283
+
284
+ if not download_checkpoints and not HuggingFaceLoader.validate_config(
285
+ self.checkpoint_path):
286
+
287
+ input(
288
+ "Press Enter to download the HuggingFace model's config.json file to infer the concepts and continue..."
289
+ )
290
+ repo_id, hf_token = self._validate_config_checkpoints()
291
+ loader = HuggingFaceLoader(repo_id=repo_id, token=hf_token)
292
+ loader.download_config(self.checkpoint_path)
293
+
294
+ else:
295
+ logger.error(
296
+ "No checkpoints specified in the config.yaml file to infer the concepts. Please either specify the concepts directly in the config.yaml file or include a checkpoints section to download the HF model's config.json file to infer the concepts."
297
+ )
298
+ return
275
299
 
276
300
  model_version_proto = self.get_model_version_proto()
277
301
 
@@ -18,9 +18,17 @@ class HuggingFaceLoader:
18
18
  if importlib.util.find_spec("huggingface_hub") is None:
19
19
  raise ImportError(self.HF_DOWNLOAD_TEXT)
20
20
  os.environ['HF_TOKEN'] = token
21
+ from huggingface_hub import HfApi
22
+
23
+ api = HfApi()
24
+ api.whoami(token=token)
25
+
21
26
  subprocess.run(f'huggingface-cli login --token={os.environ["HF_TOKEN"]}', shell=True)
22
27
  except Exception as e:
23
- Exception("Error setting up Hugging Face token ", e)
28
+ logger.error(
29
+ f"Error setting up Hugging Face token, please make sure you have the correct token: {e}"
30
+ )
31
+ logger.info("Continuing without Hugging Face token")
24
32
 
25
33
  def download_checkpoints(self, checkpoint_path: str):
26
34
  # throw error if huggingface_hub wasn't installed
@@ -50,6 +58,28 @@ class HuggingFaceLoader:
50
58
  return False
51
59
  return True
52
60
 
61
+ def download_config(self, checkpoint_path: str):
62
+ # throw error if huggingface_hub wasn't installed
63
+ try:
64
+ from huggingface_hub import hf_hub_download
65
+ except ImportError:
66
+ raise ImportError(self.HF_DOWNLOAD_TEXT)
67
+ if os.path.exists(checkpoint_path) and os.path.exists(
68
+ os.path.join(checkpoint_path, 'config.json')):
69
+ logger.info("HF model's config.json already exists")
70
+ return True
71
+ os.makedirs(checkpoint_path, exist_ok=True)
72
+ try:
73
+ is_hf_model_exists = self.validate_hf_model()
74
+ if not is_hf_model_exists:
75
+ logger.error("Model %s not found on Hugging Face" % (self.repo_id))
76
+ return False
77
+ hf_hub_download(repo_id=self.repo_id, filename='config.json', local_dir=checkpoint_path)
78
+ except Exception as e:
79
+ logger.error(f"Error downloading model's config.json {e}")
80
+ return False
81
+ return True
82
+
53
83
  def validate_hf_model(self,):
54
84
  # check if model exists on HF
55
85
  try:
@@ -70,6 +100,12 @@ class HuggingFaceLoader:
70
100
  return (len(checkpoint_dir_files) >= len(list_repo_files(self.repo_id))) and len(
71
101
  list_repo_files(self.repo_id)) > 0
72
102
 
103
+ @staticmethod
104
+ def validate_config(checkpoint_path: str):
105
+ # check if downloaded config.json exists
106
+ return os.path.exists(checkpoint_path) and os.path.exists(
107
+ os.path.join(checkpoint_path, 'config.json'))
108
+
73
109
  @staticmethod
74
110
  def fetch_labels(checkpoint_path: str):
75
111
  # Fetch labels for classification, detection and segmentation models
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clarifai
3
- Version: 10.9.1
3
+ Version: 10.9.2
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.8.8
23
+ Requires-Dist: clarifai-grpc>=10.9.4
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
@@ -1,4 +1,4 @@
1
- clarifai-grpc>=10.8.8
1
+ clarifai-grpc>=10.9.4
2
2
  clarifai-protocol>=0.0.6
3
3
  numpy>=1.22.0
4
4
  tqdm>=4.65.0
@@ -1,4 +1,4 @@
1
- clarifai-grpc>=10.8.8
1
+ clarifai-grpc>=10.9.4
2
2
  clarifai-protocol>=0.0.6
3
3
  numpy>=1.22.0
4
4
  tqdm>=4.65.0
@@ -15,6 +15,7 @@ CREATE_APP_USER_ID = os.environ["CLARIFAI_USER_ID"]
15
15
  NOW = uuid.uuid4().hex[:10]
16
16
  CREATE_APP_ID = f"ci_input_app_{NOW}"
17
17
  CREATE_DATASET_ID = "ci_input_test_dataset"
18
+ CREATE_DATASET_NEW_ID = "ci_input_test_dataset_new"
18
19
 
19
20
  #assets
20
21
  IMAGE_URL = "https://samples.clarifai.com/metro-north.jpg"
@@ -60,6 +61,7 @@ class Testdataupload:
60
61
  self.app = create_app()
61
62
  self.input_object = self.app.inputs()
62
63
  self.dataset = self.app.create_dataset(dataset_id=CREATE_DATASET_ID)
64
+ self.dataset_new = self.app.create_dataset(dataset_id=CREATE_DATASET_NEW_ID)
63
65
 
64
66
  def test_upload_image_url(self, caplog):
65
67
  with caplog.at_level(logging.INFO):
@@ -265,6 +267,11 @@ class Testdataupload:
265
267
  assert len(uploaded_inputs) == 10 # 10 inputs are uploaded from the folder
266
268
  assert len(annotations) == 10 # Test for list annotations
267
269
 
270
+ def test_merge_datasets(self, caplog):
271
+ with caplog.at_level(logging.INFO):
272
+ self.dataset_new.merge_dataset(merge_dataset_id=CREATE_DATASET_ID)
273
+ assert "SUCCESS" in caplog.text
274
+
268
275
  def test_export_dataset(self):
269
276
  dataset_demo_version = self.dataset.create_version()
270
277
  time.sleep(5)
@@ -1 +0,0 @@
1
- __version__ = "10.9.1"
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