Skip to content

Provide ability to get model configs with a model id #1654

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

Closed
wants to merge 1 commit into from
Closed
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
23 changes: 23 additions & 0 deletions libs/labelbox/src/labelbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,29 @@ def delete_model_config(self, id: str) -> bool:
if not result:
raise labelbox.exceptions.ResourceNotFoundError(Entity.ModelConfig, params)
return result['deleteModelConfig']['success']

def get_model_configs(self, model_id: str) -> List[ModelConfig]:
""" Gets all model configs attached to a given model id

Args:
model_id (str): ID of the model associated with the model configs

Returns:
List[ModelConfig], list of ModelConfigs if the operation was a success.
"""

query = """query SearchModelConfigsPyApi($modelId: ID!) {
modelConfigs(
where: {modelId: $modelId}
) {
id
inferenceParams
name
}
}"""
params = {"modelId": model_id}
result = self.execute(query, params)
return [ModelConfig(self, {**model_config, "modelId":model_id}) for model_config in result["modelConfigs"]]

def create_dataset(self,
iam_integration=IAMIntegration._DEFAULT,
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
Expand Up @@ -15,3 +15,8 @@ def test_delete_model_config(client, valid_model_id):
def test_delete_nonexistant_model_config(client):
with pytest.raises(ResourceNotFoundError):
client.delete_model_config("invalid_model_id")

def test_get_model_configs(client, valid_model_id):
model_config = client.create_model_config("model_config_1", valid_model_id, {"param": "value"})
model_config = client.create_model_config("model_config_2", valid_model_id, {"param": "value"})
assert len(client.get_model_configs(valid_model_id)) == 2
Loading