RapidataOrder(
order_id: str,
dataset: Optional[RapidataDataset],
openapi_service: OpenAPIService,
name: str,
)
Represents a Rapidata order.
:param name: The name of the order.
:type name: str
:param workflow: The workflow associated with the order.
:type workflow: Workflow
:param rapidata_service: The Rapidata service used to create and manage the order.
:type rapidata_service: RapidataService
Source code in src/rapidata/rapidata_client/order/rapidata_order.py
| def __init__(
self,
order_id: str,
dataset: Optional[RapidataDataset],
openapi_service: OpenAPIService,
name: str,
):
self.openapi_service = openapi_service
self.order_id = order_id
self._dataset = dataset
self.name = name
self._workflow_id = None
|
dataset
property
The dataset associated with the order.
:return: The RapidataDataset instance.
:rtype: RapidataDataset
submit
Submits the order for processing.
Source code in src/rapidata/rapidata_client/order/rapidata_order.py
| def submit(self):
"""
Submits the order for processing.
"""
self.openapi_service.order_api.order_submit_post(self.order_id)
|
approve
Approves the order for execution.
Source code in src/rapidata/rapidata_client/order/rapidata_order.py
| def approve(self):
"""
Approves the order for execution.
"""
self.openapi_service.order_api.order_approve_post(self.order_id)
|
get_status
Gets the status of the order.
:return: The status of the order.
:rtype: str
Source code in src/rapidata/rapidata_client/order/rapidata_order.py
| def get_status(self):
"""
Gets the status of the order.
:return: The status of the order.
:rtype: str
"""
return self.openapi_service.order_api.order_get_by_id_get(self.order_id)
|
display_progress_bar
display_progress_bar(refresh_rate=5)
Displays a progress bar for the order processing using tqdm.
:param refresh_rate: How often to refresh the progress bar, in seconds.
:type refresh_rate: float
Source code in src/rapidata/rapidata_client/order/rapidata_order.py
| def display_progress_bar(self, refresh_rate=5):
"""
Displays a progress bar for the order processing using tqdm.
:param refresh_rate: How often to refresh the progress bar, in seconds.
:type refresh_rate: float
"""
total_rapids = self._get_total_rapids()
with tqdm(total=total_rapids, desc="Processing order", unit="rapids") as pbar:
completed_rapids = 0
while True:
current_completed = self._get_completed_rapids()
if current_completed > completed_rapids:
pbar.update(current_completed - completed_rapids)
completed_rapids = current_completed
if completed_rapids >= total_rapids:
break
time.sleep(refresh_rate)
|
get_results
Gets the results of the order.
:return: The results of the order.
:rtype: dict
Source code in src/rapidata/rapidata_client/order/rapidata_order.py
| def get_results(self):
"""
Gets the results of the order.
:return: The results of the order.
:rtype: dict
"""
try:
# Get the raw result string
result_str = self.openapi_service.order_api.order_result_get(id=self.order_id)
# Parse the result string as JSON
return json.loads(result_str)
except ApiException as e:
# Handle API exceptions
raise Exception(f"Failed to get order results: {str(e)}") from e
except json.JSONDecodeError as e:
# Handle JSON parsing errors
raise Exception(f"Failed to parse order results: {str(e)}") from e
|