rapidata 1.4.3__py3-none-any.whl → 1.4.4__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.

Potentially problematic release.


This version of rapidata might be problematic. Click here for more details.

@@ -1,4 +1,4 @@
1
- import time
1
+ from time import sleep
2
2
  from rapidata.rapidata_client.dataset.rapidata_dataset import RapidataDataset
3
3
  from rapidata.service.openapi_service import OpenAPIService
4
4
  import json
@@ -61,11 +61,11 @@ class RapidataOrder:
61
61
  :param refresh_rate: How often to refresh the progress bar, in seconds.
62
62
  :type refresh_rate: float
63
63
  """
64
- total_rapids = self._get_total_rapids()
64
+ total_rapids = self._get_workflow_progress().total
65
65
  with tqdm(total=total_rapids, desc="Processing order", unit="rapids") as pbar:
66
66
  completed_rapids = 0
67
67
  while True:
68
- current_completed = self._get_completed_rapids()
68
+ current_completed = self._get_workflow_progress().completed
69
69
  if current_completed > completed_rapids:
70
70
  pbar.update(current_completed - completed_rapids)
71
71
  completed_rapids = current_completed
@@ -73,7 +73,7 @@ class RapidataOrder:
73
73
  if completed_rapids >= total_rapids:
74
74
  break
75
75
 
76
- time.sleep(refresh_rate)
76
+ sleep(refresh_rate)
77
77
 
78
78
  def _get_workflow_id(self):
79
79
  if self._workflow_id:
@@ -86,31 +86,38 @@ class RapidataOrder:
86
86
  self._workflow_id = cast(WorkflowArtifactModel, pipeline.artifacts["workflow-artifact"].actual_instance).workflow_id
87
87
  break
88
88
  except Exception:
89
- time.sleep(2)
89
+ sleep(2)
90
90
  if not self._workflow_id:
91
- raise Exception("Order has not started yet. Please wait for a few seconds and try again.")
91
+ raise Exception("Order has not started yet. Please start it or wait for a few seconds and try again.")
92
92
  return self._workflow_id
93
-
94
- def _get_total_rapids(self):
95
- workflow_id = self._get_workflow_id()
96
- return self.openapi_service.workflow_api.workflow_get_progress_get(workflow_id).total
97
-
98
- def _get_completed_rapids(self):
93
+
94
+ def _get_workflow_progress(self):
99
95
  workflow_id = self._get_workflow_id()
100
- return self.openapi_service.workflow_api.workflow_get_progress_get(workflow_id).completed
96
+ progress = None
97
+ for _ in range(2):
98
+ try:
99
+ progress = self.openapi_service.workflow_api.workflow_get_progress_get(workflow_id)
100
+ break
101
+ except Exception:
102
+ sleep(5)
101
103
 
102
- def get_progress_percentage(self):
103
- workflow_id = self._get_workflow_id()
104
- progress = self.openapi_service.workflow_api.workflow_get_progress_get(workflow_id)
105
- return progress.completion_percentage
104
+ if not progress:
105
+ raise Exception(f"Failed to get progress. Please try again in a few seconds.")
106
+
107
+ return progress
106
108
 
109
+
107
110
  def get_results(self):
108
111
  """
109
- Gets the results of the order.
112
+ Gets the results of the order.
113
+ If the order is still processing, this method will block until the order is completed and then return the results.
110
114
 
111
115
  :return: The results of the order.
112
116
  :rtype: dict
113
117
  """
118
+ while self.get_status().state == "Processing":
119
+ sleep(5)
120
+
114
121
  try:
115
122
  # Get the raw result string
116
123
  result_str = self.openapi_service.order_api.order_result_get(id=self.order_id)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rapidata
3
- Version: 1.4.3
3
+ Version: 1.4.4
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
@@ -341,7 +341,7 @@ rapidata/rapidata_client/metadata/prompt_metadata.py,sha256=_FypjKWrC3iKUO_G2CVw
341
341
  rapidata/rapidata_client/metadata/public_text_metadata.py,sha256=LTiBQHs6izxQ6-C84d6Pf7lL4ENTDgg__HZnDKvzvMc,511
342
342
  rapidata/rapidata_client/metadata/transcription_metadata.py,sha256=THtDEVCON4UlcXHmXrjilaOLHys4TrktUOPGWnXaCcc,631
343
343
  rapidata/rapidata_client/order/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
344
- rapidata/rapidata_client/order/rapidata_order.py,sha256=u0VhNgnbT0dn3AJiITqjtqn_OWgdwUcXrgU4iblPXZI,4663
344
+ rapidata/rapidata_client/order/rapidata_order.py,sha256=IMozRlrYK_yqGLk0GQbLNYL_RRb7gUcSgDe6NUjOEEE,4812
345
345
  rapidata/rapidata_client/order/rapidata_order_builder.py,sha256=QvICzduLAuAkf8qFKxHV3zAag838WnV9lEzWdD4dxI0,15926
346
346
  rapidata/rapidata_client/rapidata_client.py,sha256=UKFDbck3TOcSIRM31gHpl7vpSCHd3jPrjiTODfBPH44,6956
347
347
  rapidata/rapidata_client/referee/__init__.py,sha256=Ow9MQsONhF4sX2wFK9jbvSBrpcJgtq3OglIQMkBUdIY,167
@@ -372,7 +372,7 @@ rapidata/service/local_file_service.py,sha256=pgorvlWcx52Uh3cEG6VrdMK_t__7dacQ_5
372
372
  rapidata/service/openapi_service.py,sha256=pGcOCttKZW0PVCSM7Kfehe5loh7CxmmDDbu4UJbamnI,2770
373
373
  rapidata/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
374
374
  rapidata/utils/image_utils.py,sha256=TldO3eJWG8IhfJjm5MfNGO0mEDm1mQTsRoA0HLU1Uxs,404
375
- rapidata-1.4.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
376
- rapidata-1.4.3.dist-info/METADATA,sha256=AgMjhm057wT3bZqvDtZZstb1jHm8o3OKxMhiiVL18og,1012
377
- rapidata-1.4.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
378
- rapidata-1.4.3.dist-info/RECORD,,
375
+ rapidata-1.4.4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
376
+ rapidata-1.4.4.dist-info/METADATA,sha256=7i3T_HJVJpDWZuwxdzjy7al08xAY_yZCxZjMhdllncc,1012
377
+ rapidata-1.4.4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
378
+ rapidata-1.4.4.dist-info/RECORD,,