clarifai 10.8.0__py3-none-any.whl → 10.8.2__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.
clarifai/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "10.8.0"
1
+ __version__ = "10.8.2"
clarifai/client/model.py CHANGED
@@ -18,8 +18,9 @@ from clarifai.client.base import BaseClient
18
18
  from clarifai.client.dataset import Dataset
19
19
  from clarifai.client.input import Inputs
20
20
  from clarifai.client.lister import Lister
21
- from clarifai.constants.model import (MAX_MODEL_PREDICT_INPUTS, MODEL_EXPORT_TIMEOUT,
22
- TRAINABLE_MODEL_TYPES)
21
+ from clarifai.constants.model import (CHUNK_SIZE, MAX_CHUNK_SIZE, MAX_MODEL_PREDICT_INPUTS,
22
+ MAX_RANGE_SIZE, MIN_CHUNK_SIZE, MIN_RANGE_SIZE,
23
+ MODEL_EXPORT_TIMEOUT, RANGE_SIZE, TRAINABLE_MODEL_TYPES)
23
24
  from clarifai.errors import UserError
24
25
  from clarifai.urls.helper import ClarifaiUrlHelper
25
26
  from clarifai.utils.logging import get_logger
@@ -1296,20 +1297,52 @@ class Model(Lister, BaseClient):
1296
1297
  model_export_url = get_model_export_response.export.url
1297
1298
  model_export_file_size = get_model_export_response.export.size
1298
1299
 
1299
- session = requests.Session()
1300
- retries = Retry(total=10, backoff_factor=1, status_forcelist=[500, 502, 503, 504])
1301
- session.mount('https://', HTTPAdapter(max_retries=retries))
1302
- session.headers.update({'Authorization': self.metadata[0][1]})
1303
- response = session.get(model_export_url, stream=True)
1304
- response.raise_for_status()
1305
-
1306
1300
  with open(local_filepath, 'wb') as f:
1307
1301
  progress = tqdm(
1308
1302
  total=model_export_file_size, unit='B', unit_scale=True, desc="Exporting model")
1309
- for chunk in response.iter_content(chunk_size=8192):
1310
- f.write(chunk)
1311
- progress.update(len(chunk))
1312
- progress.close()
1303
+ downloaded_size = 0
1304
+ range_size = RANGE_SIZE
1305
+ chunk_size = CHUNK_SIZE
1306
+ retry = False
1307
+ retry_count = 0
1308
+ while downloaded_size < model_export_file_size:
1309
+ if downloaded_size + range_size >= model_export_file_size:
1310
+ range_header = f"bytes={downloaded_size}-"
1311
+ else:
1312
+ range_header = f"bytes={downloaded_size}-{(downloaded_size+range_size-1)}"
1313
+ try:
1314
+ session = requests.Session()
1315
+ retries = Retry(total=5, backoff_factor=0.1, status_forcelist=[500, 502, 503, 504])
1316
+ session.mount('https://', HTTPAdapter(max_retries=retries))
1317
+ session.headers.update({'Authorization': self.metadata[0][1], 'Range': range_header})
1318
+ response = session.get(model_export_url, stream=True)
1319
+ response.raise_for_status()
1320
+
1321
+ for chunk in response.iter_content(chunk_size=chunk_size):
1322
+ f.write(chunk)
1323
+ progress.update(len(chunk))
1324
+ f.flush()
1325
+ os.fsync(f.fileno())
1326
+ downloaded_size += range_size
1327
+ if not retry:
1328
+ range_size = (
1329
+ range_size * 2) if (range_size * 2) < MAX_RANGE_SIZE else MAX_RANGE_SIZE
1330
+ chunk_size = (
1331
+ chunk_size * 2) if (chunk_size * 2) < MAX_CHUNK_SIZE else MAX_CHUNK_SIZE
1332
+ except Exception as e:
1333
+ self.logger.error(f"Error downloading model: {e}")
1334
+ range_size = (
1335
+ range_size // 2) if (range_size // 2) > MIN_RANGE_SIZE else MIN_RANGE_SIZE
1336
+ chunk_size = (
1337
+ chunk_size // 2) if (chunk_size // 2) > MIN_CHUNK_SIZE else MIN_CHUNK_SIZE
1338
+ retry = True
1339
+ retry_count += 1
1340
+ f.seek(downloaded_size)
1341
+ progress.reset(total=model_export_file_size)
1342
+ progress.update(downloaded_size)
1343
+ if retry_count > 5:
1344
+ break
1345
+ progress.close()
1313
1346
 
1314
1347
  self.logger.info(
1315
1348
  f"Model ID {self.id} with version {self.model_info.model_version.id} exported successfully to {export_dir}/model.tar"
@@ -4,3 +4,9 @@ TRAINABLE_MODEL_TYPES = [
4
4
  ]
5
5
  MAX_MODEL_PREDICT_INPUTS = 128
6
6
  MODEL_EXPORT_TIMEOUT = 1800
7
+ MIN_RANGE_SIZE = 4194304 # 4MB
8
+ MAX_RANGE_SIZE = 314572800 # 300MB
9
+ MIN_CHUNK_SIZE = 131072 # 128KB
10
+ MAX_CHUNK_SIZE = 10485760 # 10MB
11
+ RANGE_SIZE = 31457280 # 30MB
12
+ CHUNK_SIZE = 1048576 # 1MB
@@ -196,7 +196,7 @@ class InputAnnotationDownloader:
196
196
 
197
197
  if data_dict.get("concepts") or data_dict.get("regions"):
198
198
  file_name = os.path.join(split, "annotations", input_.id + ".json")
199
- annot_data = data_dict.get("regions", []) + data_dict.get("concepts")
199
+ annot_data = data_dict.get("regions", []) + data_dict.get("concepts", [])
200
200
 
201
201
  self._save_annotation_to_archive(new_archive, annot_data, file_name)
202
202
  self.num_annotations += 1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: clarifai
3
- Version: 10.8.0
3
+ Version: 10.8.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.0
23
+ Requires-Dist: clarifai-grpc >=10.8.6
24
24
  Requires-Dist: numpy >=1.22.0
25
25
  Requires-Dist: tqdm >=4.65.0
26
26
  Requires-Dist: tritonclient >=2.34.0
@@ -30,6 +30,7 @@ Requires-Dist: schema ==0.7.5
30
30
  Requires-Dist: Pillow >=9.5.0
31
31
  Requires-Dist: inquirerpy ==0.3.4
32
32
  Requires-Dist: tabulate >=0.9.0
33
+ Requires-Dist: protobuf ==5.27.3
33
34
  Provides-Extra: all
34
35
  Requires-Dist: pycocotools ==2.0.6 ; extra == 'all'
35
36
 
@@ -162,7 +163,7 @@ app = client.create_app(app_id="demo_app", base_workflow="Universal")
162
163
  dataset = app.create_dataset(dataset_id="demo_dataset")
163
164
 
164
165
  # execute data upload to Clarifai app dataset
165
- from clarifai.datasets.upload.laoders.coco_detection import COCODetectionDataLoader
166
+ from clarifai.datasets.upload.loaders.coco_detection import COCODetectionDataLoader
166
167
  coco_dataloader = COCODetectionDataLoader("images_dir", "coco_annotation_filepath")
167
168
  dataset.upload_dataset(dataloader=coco_dataloader, get_upload_status=True)
168
169
 
@@ -1,4 +1,4 @@
1
- clarifai/__init__.py,sha256=x_bDnpR_W5o1ETeLzxk1ahCDd3RSOmf0Fs_F69i8AEo,23
1
+ clarifai/__init__.py,sha256=FG8GLi_82vIRb8Dfpf5CyID9RUNkh4jIYFUZwrkh_cI,23
2
2
  clarifai/cli.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  clarifai/errors.py,sha256=RwzTajwds51wLD0MVlMC5kcpBnzRpreDLlazPSBZxrg,2605
4
4
  clarifai/versions.py,sha256=jctnczzfGk_S3EnVqb2FjRKfSREkNmvNEwAAa_VoKiQ,222
@@ -8,7 +8,7 @@ clarifai/client/base.py,sha256=JXbbjg2CXo8rOdw-XgKWWtLVAhPv3OZua5LFT5w4U2Q,7380
8
8
  clarifai/client/dataset.py,sha256=XX-J-9Ict1CQrEycq-JbdxUTuucSgLeDSvnlHE1ucQY,29903
9
9
  clarifai/client/input.py,sha256=ZLqa1jGx4NgCbunOTpJxCq4lDQ5xAf4GQ0rsZY8AHCM,44456
10
10
  clarifai/client/lister.py,sha256=03KGMvs5RVyYqxLsSrWhNc34I8kiF1Ph0NeyEwu7nMU,2082
11
- clarifai/client/model.py,sha256=TsIiId2a1eqR8Ct83f8KbqBsxiDT9XNPxqLSQtr3i1A,72930
11
+ clarifai/client/model.py,sha256=-jwkuXKgKDGJJPSLj_b-b_yyHcSlBy_GS-9D-eHNf6s,74507
12
12
  clarifai/client/module.py,sha256=360JaOasX0DZCNE_Trj0LNTr-T_tUDZLfGpz0CdIi78,4248
13
13
  clarifai/client/search.py,sha256=GaPWN6JmTQGZaCHr6U1yv0zqR6wKFl7i9IVLg2ul1CI,14254
14
14
  clarifai/client/user.py,sha256=Fr3vDEHieqD7HRRKnlp9h-AIX4AuYBirRYtG4KLwSe8,11836
@@ -19,13 +19,13 @@ clarifai/client/auth/register.py,sha256=2CMdBsoVLoTfjyksE6j7BM2tiEc73WKYvxnwDDgN
19
19
  clarifai/client/auth/stub.py,sha256=xy4-fV0W8keCgXld4eOVzFQEIKxOktNwtL5bLztReug,4940
20
20
  clarifai/constants/dataset.py,sha256=Puz6_FfTm30G5FVBb1GJsobMkNtbg0Y2Soy7eyHjvtI,587
21
21
  clarifai/constants/input.py,sha256=WcHwToUVIK9ItAhDefaSohQHCLNeR55PSjZ0BFnoZ3U,28
22
- clarifai/constants/model.py,sha256=oTad43ncskVHfQ9vEbL2yy0Fac666dXr7QuO8zZXHAE,245
22
+ clarifai/constants/model.py,sha256=Um1hLfMFlh5R_vtP3Z6P-o6zon-tdbLcKVIl4PucrV4,438
23
23
  clarifai/constants/rag.py,sha256=WcHwToUVIK9ItAhDefaSohQHCLNeR55PSjZ0BFnoZ3U,28
24
24
  clarifai/constants/search.py,sha256=yYEqTaFg-KdnpJE_Ytp-EPVHIIC395iNtZrpVlLIf4o,101
25
25
  clarifai/constants/workflow.py,sha256=cECq1xdvf44MCdtK2AbkiuuwhyL-6OWZdQfYbsLKy_o,33
26
26
  clarifai/datasets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
27
27
  clarifai/datasets/export/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
28
- clarifai/datasets/export/inputs_annotations.py,sha256=X1Y1XjnJrPrlwqv2aM4a1mBPUpWgEpz5stq2Vq-mLaM,9740
28
+ clarifai/datasets/export/inputs_annotations.py,sha256=7c6HWdATI4aPCRoCPZetUBNNEz9dBhbyYX1QqX-xYe4,9744
29
29
  clarifai/datasets/upload/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
30
  clarifai/datasets/upload/base.py,sha256=IP4sdBRfThk2l0W1rDWciFrAJnKwVsM-gu4zEslJ2_E,2198
31
31
  clarifai/datasets/upload/features.py,sha256=oq0PGpAw8LEafiSkdMMl0yn-NJeZ7K_CKzpJ71b0H40,1731
@@ -107,9 +107,9 @@ clarifai/workflows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
107
107
  clarifai/workflows/export.py,sha256=vICRhIreqDSShxLKjHNM2JwzKsf1B4fdXB0ciMcA70k,1945
108
108
  clarifai/workflows/utils.py,sha256=nGeB_yjVgUO9kOeKTg4OBBaBz-AwXI3m-huSVj-9W18,1924
109
109
  clarifai/workflows/validate.py,sha256=yJq03MaJqi5AK3alKGJJBR89xmmjAQ31sVufJUiOqY8,2556
110
- clarifai-10.8.0.dist-info/LICENSE,sha256=mUqF_d12-qE2n41g7C5_sq-BMLOcj6CNN-jevr15YHU,555
111
- clarifai-10.8.0.dist-info/METADATA,sha256=4oERpF1zh5aLZU6ZUh4jh6XqXyl-4n9pnle4KlbwBOM,19372
112
- clarifai-10.8.0.dist-info/WHEEL,sha256=uCRv0ZEik_232NlR4YDw4Pv3Ajt5bKvMH13NUU7hFuI,91
113
- clarifai-10.8.0.dist-info/entry_points.txt,sha256=qZOr_MIPG0dBBE1zringDJS_wXNGTAA_SQ-zcbmDHOw,82
114
- clarifai-10.8.0.dist-info/top_level.txt,sha256=wUMdCQGjkxaynZ6nZ9FAnvBUCgp5RJUVFSy2j-KYo0s,9
115
- clarifai-10.8.0.dist-info/RECORD,,
110
+ clarifai-10.8.2.dist-info/LICENSE,sha256=mUqF_d12-qE2n41g7C5_sq-BMLOcj6CNN-jevr15YHU,555
111
+ clarifai-10.8.2.dist-info/METADATA,sha256=ckJDbErEFSTxwyILxVH4Grom2qN6dVjwX_F9zt7hlf0,19405
112
+ clarifai-10.8.2.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
113
+ clarifai-10.8.2.dist-info/entry_points.txt,sha256=qZOr_MIPG0dBBE1zringDJS_wXNGTAA_SQ-zcbmDHOw,82
114
+ clarifai-10.8.2.dist-info/top_level.txt,sha256=wUMdCQGjkxaynZ6nZ9FAnvBUCgp5RJUVFSy2j-KYo0s,9
115
+ clarifai-10.8.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (74.1.1)
2
+ Generator: setuptools (75.1.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5