rapidata 0.1.25__py3-none-any.whl → 0.2.0__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.
@@ -11,6 +11,8 @@ from rapidata.api_client.models.upload_text_sources_to_dataset_model import (
11
11
  from rapidata.rapidata_client.metadata.base_metadata import Metadata
12
12
  from rapidata.service import LocalFileService
13
13
  from rapidata.service.openapi_service import OpenAPIService
14
+ from concurrent.futures import ThreadPoolExecutor, as_completed
15
+ from tqdm import tqdm
14
16
 
15
17
 
16
18
  class RapidataDataset:
@@ -32,19 +34,18 @@ class RapidataDataset:
32
34
  self,
33
35
  image_paths: list[str | list[str]],
34
36
  metadata: list[Metadata] | None = None,
37
+ max_workers: int = 10,
35
38
  ):
36
39
  if metadata is not None and len(metadata) != len(image_paths):
37
40
  raise ValueError(
38
41
  "metadata must be None or have the same length as image_paths"
39
42
  )
40
43
 
41
- for media_paths_rapid, meta in zip_longest(image_paths, metadata or []):
42
-
44
+ def upload_datapoint(media_paths_rapid: str | list[str], meta: Metadata | None) -> None:
43
45
  if isinstance(media_paths_rapid, list) and not all(
44
46
  os.path.exists(media_path) for media_path in media_paths_rapid
45
47
  ):
46
48
  raise FileNotFoundError(f"File not found: {media_paths_rapid}")
47
-
48
49
  elif isinstance(media_paths_rapid, str) and not os.path.exists(
49
50
  media_paths_rapid
50
51
  ):
@@ -60,4 +61,19 @@ class RapidataDataset:
60
61
  ),
61
62
  )
62
63
 
63
- self.openapi_service.dataset_api.dataset_create_datapoint_post(model=model, files=media_paths_rapid if isinstance(media_paths_rapid, list) else [media_paths_rapid]) # type: ignore
64
+ self.openapi_service.dataset_api.dataset_create_datapoint_post(
65
+ model=model,
66
+ files=media_paths_rapid if isinstance(media_paths_rapid, list) else [media_paths_rapid] # type: ignore
67
+ )
68
+
69
+ total_uploads = len(image_paths)
70
+ with ThreadPoolExecutor(max_workers=max_workers) as executor:
71
+ futures = [
72
+ executor.submit(upload_datapoint, media_paths, meta)
73
+ for media_paths, meta in zip_longest(image_paths, metadata or [])
74
+ ]
75
+
76
+ with tqdm(total=total_uploads, desc="Uploading datapoints") as pbar:
77
+ for future in as_completed(futures):
78
+ future.result() # This will raise any exceptions that occurred during execution
79
+ pbar.update(1)
@@ -87,7 +87,7 @@ class RapidataOrderBuilder:
87
87
  ],
88
88
  )
89
89
 
90
- def create(self, submit=True) -> RapidataOrder:
90
+ def create(self, submit=True, max_workers=10) -> RapidataOrder:
91
91
  """Actually makes the API calls to create the order based on how the order builder was configured.
92
92
 
93
93
  Args:
@@ -113,7 +113,7 @@ class RapidataOrderBuilder:
113
113
  openapi_service=self._openapi_service,
114
114
  )
115
115
 
116
- order.dataset.add_media_from_paths(self._media_paths, self._metadata)
116
+ order.dataset.add_media_from_paths(self._media_paths, self._metadata, max_workers)
117
117
 
118
118
  if submit:
119
119
  order.submit()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rapidata
3
- Version: 0.1.25
3
+ Version: 0.2.0
4
4
  Summary: Rapidata package containing the Rapidata Python Client to interact with the Rapidata Web API in an easy way.
5
5
  License: Apache-2.0
6
6
  Author: Rapidata AG
@@ -222,7 +222,7 @@ rapidata/rapidata_client/config.py,sha256=tQLgN6k_ATOX1GzZh38At2rgBDLStV6rJ6z0vs
222
222
  rapidata/rapidata_client/country_codes/__init__.py,sha256=Y8qeG2IMjvMGvhaPydq0nhwRQHb6dQqilctlEXu0_PE,55
223
223
  rapidata/rapidata_client/country_codes/country_codes.py,sha256=Q0HMX7uHJQDeLCFPP5bq4iYi6pgcDWEcl2ONGhjgoeU,286
224
224
  rapidata/rapidata_client/dataset/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
225
- rapidata/rapidata_client/dataset/rapidata_dataset.py,sha256=J5jlSIbdswhqXHOq8Qf9gtzVF70cImq9sioDG7S9Mxs,2457
225
+ rapidata/rapidata_client/dataset/rapidata_dataset.py,sha256=QDsl7ZCZxuG02yfEpBSphfSDZh_qHz6m5HUCGwZflfw,3205
226
226
  rapidata/rapidata_client/dataset/rapidata_validation_set.py,sha256=YrnUzia9AXgq2z917FtztFxj4fD5EgTWXVPBzLVIujY,9374
227
227
  rapidata/rapidata_client/dataset/validation_rapid_parts.py,sha256=SIeQesEXPPOW5kclxYLNWaKllBXHm7DQKBdMU-GXnfc,2104
228
228
  rapidata/rapidata_client/dataset/validation_set_builder.py,sha256=B9D-uNCo_PO0NCUHju_7dsWtz_KcOmvFIsxUgQ67Q2M,7471
@@ -235,7 +235,7 @@ rapidata/rapidata_client/metadata/prompt_metadata.py,sha256=_FypjKWrC3iKUO_G2CVw
235
235
  rapidata/rapidata_client/metadata/transcription_metadata.py,sha256=THtDEVCON4UlcXHmXrjilaOLHys4TrktUOPGWnXaCcc,631
236
236
  rapidata/rapidata_client/order/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
237
237
  rapidata/rapidata_client/order/rapidata_order.py,sha256=VRDLTPBf2k6UihF0DnWq3nfBLWExfWHzh3T-cJgFF1w,2437
238
- rapidata/rapidata_client/order/rapidata_order_builder.py,sha256=qGfdmO3wdQMDwlW5NTM8x5ll8YmC0UUuUkGtyzGMObU,8105
238
+ rapidata/rapidata_client/order/rapidata_order_builder.py,sha256=Wx7lhThTd6SwJNSbXzhGCsEgMhizjsriGz2zMjbQyEI,8134
239
239
  rapidata/rapidata_client/rapidata_client.py,sha256=z3vz5_GNivnShj7kqii-eUff16rvwSy62zwi8WZqAWo,2776
240
240
  rapidata/rapidata_client/referee/__init__.py,sha256=x0AxGCsR6TlDjfqQ00lB9V7QVS9EZCJzweNEIzx42PI,207
241
241
  rapidata/rapidata_client/referee/base_referee.py,sha256=bMy7cw0a-pGNbFu6u_1_Jplu0A483Ubj4oDQzh8vu8k,493
@@ -259,7 +259,7 @@ rapidata/service/local_file_service.py,sha256=pgorvlWcx52Uh3cEG6VrdMK_t__7dacQ_5
259
259
  rapidata/service/openapi_service.py,sha256=-vrM2jEzQxr9KAerOYkVhpvMEeHwjzRwm9L_VFyzOT0,1537
260
260
  rapidata/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
261
261
  rapidata/utils/image_utils.py,sha256=TldO3eJWG8IhfJjm5MfNGO0mEDm1mQTsRoA0HLU1Uxs,404
262
- rapidata-0.1.25.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
263
- rapidata-0.1.25.dist-info/METADATA,sha256=bWrZHRwA8LYarK3LDoP4wLlV4vlDYqMsiuIXemQ6C-s,924
264
- rapidata-0.1.25.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
265
- rapidata-0.1.25.dist-info/RECORD,,
262
+ rapidata-0.2.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
263
+ rapidata-0.2.0.dist-info/METADATA,sha256=Oymi81UjDR9fM9f-axaTKUWOCnlExpeA1i1voXC7ruU,923
264
+ rapidata-0.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
265
+ rapidata-0.2.0.dist-info/RECORD,,