Skip to content

Add Project get_labeling_service_status() #1753

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 1 commit into from
Jul 29, 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
19 changes: 17 additions & 2 deletions libs/labelbox/src/labelbox/schema/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import TYPE_CHECKING, Any, Dict, Iterable, List, Optional, Tuple, TypeVar, Union, overload
from urllib.parse import urlparse

from labelbox.schema.labeling_service import LabelingService
from labelbox.schema.labeling_service import LabelingService, LabelingServiceStatus
import requests

from labelbox import parser
Expand Down Expand Up @@ -1920,10 +1920,25 @@ def clone(self) -> "Project":
def get_labeling_service(self) -> LabelingService:
"""Get the labeling service for this project.
Raises:
ResourceNotFoundError if the project does not have a labeling service.
Returns:
LabelingService: The labeling service for this project.
"""
return LabelingService.get(self.client, self.uid) # type: ignore
return LabelingService.get(self.client, self.uid)

@experimental
def get_labeling_service_status(self) -> LabelingServiceStatus:
"""Get the labeling service status for this project.
Raises:
ResourceNotFoundError if the project does not have a labeling service.
Returns:
LabelingServiceStatus: The labeling service status for this project.
"""
return self.get_labeling_service().status

@experimental
def request_labeling_service(self) -> LabelingService:
Expand Down
5 changes: 5 additions & 0 deletions libs/labelbox/tests/integration/test_labeling_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
def test_get_labeling_service_throws_exception(project):
with pytest.raises(ResourceNotFoundError): # No labeling service by default
project.get_labeling_service()
with pytest.raises(ResourceNotFoundError): # No labeling service by default
project.get_labeling_service_status()


def test_start_labeling_service(project):
Expand All @@ -18,3 +20,6 @@ def test_start_labeling_service(project):
labeling_service = project.get_labeling_service()
assert labeling_service.status == LabelingServiceStatus.SetUp
assert labeling_service.project_id == project.uid

labeling_service_status = project.get_labeling_service_status()
assert labeling_service_status == LabelingServiceStatus.SetUp
Loading