Skip to content

Throw ResourceNotFound error when deleting nonexistant model config #1634

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 28, 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
2 changes: 2 additions & 0 deletions libs/labelbox/src/labelbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,8 @@ def delete_model_config(self, id: str) -> bool:
}"""
params = {"id": id}
result = self.execute(query, params)
if not result:
raise labelbox.exceptions.ResourceNotFoundError(Entity.ModelConfig, params)
return result['deleteModelConfig']['success']

def create_dataset(self,
Expand Down
5 changes: 5 additions & 0 deletions libs/labelbox/tests/integration/test_model_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from labelbox.exceptions import ResourceNotFoundError

def test_create_model_config(client, valid_model_id):
model_config = client.create_model_config("model_config", valid_model_id, {"param": "value"})
Expand All @@ -10,3 +11,7 @@ def test_create_model_config(client, valid_model_id):
def test_delete_model_config(client, valid_model_id):
model_config_id = client.create_model_config("model_config", valid_model_id, {"param": "value"})
assert(client.delete_model_config(model_config_id.uid))

def test_delete_nonexistant_model_config(client):
with pytest.raises(ResourceNotFoundError):
client.delete_model_config("invalid_model_id")