Skip to content

Throw resource not found error for model config methods. #1623

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
May 23, 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
6 changes: 6 additions & 0 deletions libs/labelbox/src/labelbox/schema/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
LabelboxError,
ProcessingWaitTimeout,
ResourceConflict,
ResourceNotFoundError
)
from labelbox.orm import query
from labelbox.orm.db_object import DbObject, Deletable, Updateable, experimental
Expand All @@ -33,6 +34,7 @@
from labelbox.schema.identifiable import DataRowIdentifier, GlobalKey, UniqueId
from labelbox.schema.identifiables import DataRowIdentifiers, UniqueIds
from labelbox.schema.media_type import MediaType
from labelbox.schema.model_config import ModelConfig
from labelbox.schema.project_model_config import ProjectModelConfig
from labelbox.schema.queue_mode import QueueMode
from labelbox.schema.resource_tag import ResourceTag
Expand Down Expand Up @@ -1271,6 +1273,8 @@ def add_model_config(self, model_config_id: str) -> str:
"modelConfigId": model_config_id,
}
result = self.client.execute(query, params)
if not result:
raise ResourceNotFoundError(ModelConfig, params)
return result["createProjectModelConfig"]["projectModelConfigId"]

def delete_project_model_config(self, project_model_config_id: str) -> bool:
Expand All @@ -1292,6 +1296,8 @@ def delete_project_model_config(self, project_model_config_id: str) -> bool:
"id": project_model_config_id,
}
result = self.client.execute(query, params)
if not result:
raise ResourceNotFoundError(ProjectModelConfig, params)
return result["deleteProjectModelConfig"]["success"]

def set_labeling_parameter_overrides(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from labelbox.exceptions import ResourceNotFoundError

def test_add_single_model_config(configured_project, model_config):
project_model_config_id = configured_project.add_model_config(model_config.uid)
Expand All @@ -23,3 +24,7 @@ def test_add_multiple_model_config(client, rand_gen, configured_project, model_c
def test_delete_project_model_config(configured_project, model_config):
assert configured_project.delete_project_model_config(configured_project.add_model_config(model_config.uid))
assert not len(configured_project.project_model_configs())

def test_delete_nonexistant_project_model_config(configured_project):
with pytest.raises(ResourceNotFoundError):
configured_project.delete_project_model_config("nonexistant_project_model_config")
Loading