From 9e3a0c8992491615730ed3e99ab6cd9747a1ddfd Mon Sep 17 00:00:00 2001 From: Samuel Fendell Date: Mon, 8 Jul 2024 19:03:59 -0700 Subject: [PATCH] [PLT-1135] Alias these commands to each other so users don't have to remember which one is valid. --- libs/labelbox/src/labelbox/schema/annotation_import.py | 5 +++++ libs/labelbox/src/labelbox/schema/bulk_import_request.py | 3 +++ libs/labelbox/src/labelbox/schema/create_batches_task.py | 3 +++ libs/labelbox/src/labelbox/schema/export_task.py | 3 +++ libs/labelbox/src/labelbox/schema/task.py | 5 +++++ 5 files changed, 19 insertions(+) diff --git a/libs/labelbox/src/labelbox/schema/annotation_import.py b/libs/labelbox/src/labelbox/schema/annotation_import.py index 68c6eb034..2d1fd8582 100644 --- a/libs/labelbox/src/labelbox/schema/annotation_import.py +++ b/libs/labelbox/src/labelbox/schema/annotation_import.py @@ -92,6 +92,11 @@ def statuses(self) -> List[Dict[str, Any]]: self.wait_until_done() return self._fetch_remote_ndjson(self.status_file_url) + def wait_till_done(self, + sleep_time_seconds: int = 10, + show_progress: bool = False) -> None: + self.wait_until_done(sleep_time_seconds, show_progress) + def wait_until_done(self, sleep_time_seconds: int = 10, show_progress: bool = False) -> None: diff --git a/libs/labelbox/src/labelbox/schema/bulk_import_request.py b/libs/labelbox/src/labelbox/schema/bulk_import_request.py index 65b71a310..9c282879e 100644 --- a/libs/labelbox/src/labelbox/schema/bulk_import_request.py +++ b/libs/labelbox/src/labelbox/schema/bulk_import_request.py @@ -181,6 +181,9 @@ def refresh(self) -> None: res = res[utils.camel_case(BulkImportRequest.type_name())] self._set_field_values(res) + def wait_till_done(self, sleep_time_seconds: int = 5) -> None: + self.wait_until_done(sleep_time_seconds) + def wait_until_done(self, sleep_time_seconds: int = 5) -> None: """Blocks import job until certain conditions are met. diff --git a/libs/labelbox/src/labelbox/schema/create_batches_task.py b/libs/labelbox/src/labelbox/schema/create_batches_task.py index 919d30204..eb7b5d150 100644 --- a/libs/labelbox/src/labelbox/schema/create_batches_task.py +++ b/libs/labelbox/src/labelbox/schema/create_batches_task.py @@ -23,6 +23,9 @@ def __init__(self, client, project_id: str, batch_ids: List[str], Entity.Task.get_task(self.client, task_id) for task_id in task_ids ] + def wait_until_done(self, timeout_seconds: int = 300) -> None: + self.wait_till_done(timeout_seconds) + def wait_till_done(self, timeout_seconds: int = 300) -> None: """ Waits for the task to complete. diff --git a/libs/labelbox/src/labelbox/schema/export_task.py b/libs/labelbox/src/labelbox/schema/export_task.py index b00c9166a..06715748c 100644 --- a/libs/labelbox/src/labelbox/schema/export_task.py +++ b/libs/labelbox/src/labelbox/schema/export_task.py @@ -788,6 +788,9 @@ def organization(self): """Returns the organization of the task.""" return self._task.organization + def wait_until_done(self, timeout_seconds: int = 7200) -> None: + self.wait_till_done(timeout_seconds) + def wait_till_done(self, timeout_seconds: int = 7200) -> None: """Waits until the task is done.""" return self._task.wait_till_done(timeout_seconds) diff --git a/libs/labelbox/src/labelbox/schema/task.py b/libs/labelbox/src/labelbox/schema/task.py index 650472fab..95febc386 100644 --- a/libs/labelbox/src/labelbox/schema/task.py +++ b/libs/labelbox/src/labelbox/schema/task.py @@ -84,6 +84,11 @@ def has_errors(self) -> bool: return bool(self.failed_data_rows) return self.status == "FAILED" + def wait_until_done(self, + timeout_seconds: float = 300.0, + check_frequency: float = 2.0) -> None: + self.wait_till_done(timeout_seconds, check_frequency) + def wait_till_done(self, timeout_seconds: float = 300.0, check_frequency: float = 2.0) -> None: