Skip to content

[PLT-1982] Deprecated wait_until_done #1913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions libs/labelbox/src/labelbox/schema/annotation_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Union,
cast,
)
import warnings

import requests
from google.api_core import retry
Expand Down Expand Up @@ -72,7 +73,7 @@ def errors(self) -> List[Dict[str, Any]]:
See `AnnotationImport.statuses` for more details.
* This information will expire after 24 hours.
"""
self.wait_until_done()
self.wait_till_done()
return self._fetch_remote_ndjson(self.error_file_url)

@property
Expand Down Expand Up @@ -101,15 +102,20 @@ def statuses(self) -> List[Dict[str, Any]]:

* This information will expire after 24 hours.
"""
self.wait_until_done()
self.wait_till_done()
return self._fetch_remote_ndjson(self.status_file_url)

def wait_till_done(
def wait_until_done(
self, sleep_time_seconds: int = 10, show_progress: bool = False
) -> None:
self.wait_until_done(sleep_time_seconds, show_progress)
warnings.warn(
"The method wait_until_done for AnnotationImport is deprecated and will be removed in the next major release. Use the wait_till_done method instead.",
DeprecationWarning,
stacklevel=2,
)
self.wait_till_done(sleep_time_seconds, show_progress)

def wait_until_done(
def wait_till_done(
self, sleep_time_seconds: int = 10, show_progress: bool = False
) -> None:
"""Blocks import job until certain conditions are met.
Expand Down
6 changes: 6 additions & 0 deletions libs/labelbox/src/labelbox/schema/create_batches_task.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
from typing import TYPE_CHECKING, Callable, List, Optional, Dict, Any
import warnings

from labelbox.orm.model import Entity

Expand All @@ -23,6 +24,11 @@ def __init__(
]

def wait_until_done(self, timeout_seconds: int = 300) -> None:
warnings.warn(
"The method wait_until_done for CreateBatchesTask is deprecated and will be removed in the next major release. Use the wait_till_done method instead.",
DeprecationWarning,
stacklevel=2,
)
self.wait_till_done(timeout_seconds)

def wait_till_done(self, timeout_seconds: int = 300) -> None:
Expand Down
6 changes: 6 additions & 0 deletions libs/labelbox/src/labelbox/schema/export_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
TypeVar,
Union,
)
import warnings

import requests
from pydantic import BaseModel
Expand Down Expand Up @@ -484,6 +485,11 @@ def organization(self):
return self._task.organization

def wait_until_done(self, timeout_seconds: int = 7200) -> None:
warnings.warn(
"The method wait_until_done for ExportTask is deprecated and will be removed in the next major release. Use the wait_till_done method instead.",
DeprecationWarning,
stacklevel=2,
)
self.wait_till_done(timeout_seconds)

def wait_till_done(self, timeout_seconds: int = 7200) -> None:
Expand Down
10 changes: 5 additions & 5 deletions libs/labelbox/src/labelbox/schema/model_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _upsert_labels_by_label_ids(
MEALabelRegistrationTaskStatus(where: $where) {status errorMessage}
}
"""
return self._wait_until_done(
return self._wait_till_done(
lambda: self.client.execute(
status_query_str, {"where": {"id": task_id}}
)["MEALabelRegistrationTaskStatus"],
Expand All @@ -144,7 +144,7 @@ def _upsert_labels_by_project_id(
MEALabelRegistrationTaskStatus(where: $where) {status errorMessage}
}
"""
return self._wait_until_done(
return self._wait_till_done(
lambda: self.client.execute(
status_query_str, {"where": {"id": task_id}}
)["MEALabelRegistrationTaskStatus"],
Expand Down Expand Up @@ -182,14 +182,14 @@ def upsert_data_rows(
MEADataRowRegistrationTaskStatus(where: $where) {status errorMessage}
}
"""
return self._wait_until_done(
return self._wait_till_done(
lambda: self.client.execute(
status_query_str, {"where": {"id": task_id}}
)["MEADataRowRegistrationTaskStatus"],
timeout_seconds=timeout_seconds,
)

def _wait_until_done(self, status_fn, timeout_seconds=120, sleep_time=5):
def _wait_till_done(self, status_fn, timeout_seconds=120, sleep_time=5):
# Do not use this function outside of the scope of upsert_data_rows or upsert_labels. It could change.
original_timeout = timeout_seconds
while True:
Expand Down Expand Up @@ -419,7 +419,7 @@ def assign_data_rows_to_split(
assignDataRowsToDataSplitTaskStatus(where: {id : $id}){status errorMessage}}
"""

return self._wait_until_done(
return self._wait_till_done(
lambda: self.client.execute(
status_query_str, {"id": task_id}, experimental=True
)["assignDataRowsToDataSplitTaskStatus"],
Expand Down
6 changes: 6 additions & 0 deletions libs/labelbox/src/labelbox/schema/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import time
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Union
import warnings

import requests
from lbox.exceptions import ResourceNotFoundError
Expand Down Expand Up @@ -92,6 +93,11 @@ def has_errors(self) -> bool:
def wait_until_done(
self, timeout_seconds: float = 300.0, check_frequency: float = 2.0
) -> None:
warnings.warn(
"The method wait_until_done for Task is deprecated and will be removed in the next major release. Use the wait_till_done method instead.",
DeprecationWarning,
stacklevel=2,
)
self.wait_till_done(timeout_seconds, check_frequency)

def wait_till_done(
Expand Down
Loading