Skip to content

Commit

Permalink
Merge pull request #974 from roboflow/benchmark-dedicated-fix
Browse files Browse the repository at this point in the history
send api key for model registry to make it work on dedicated deployments
  • Loading branch information
grzegorz-roboflow authored Jan 24, 2025
2 parents 7b989c2 + 940b7bc commit cf6e6d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
8 changes: 6 additions & 2 deletions inference_sdk/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,9 @@ def list_loaded_models(self) -> RegisteredModels:
HTTPClientError: If there is an error with the server connection.
"""
self.__ensure_v1_client_mode()
response = requests.get(f"{self.__api_url}/model/registry")
response = requests.get(
f"{self.__api_url}/model/registry?api_key={self.__api_key}"
)
response.raise_for_status()
response_payload = response.json()
return RegisteredModels.from_dict(response_payload)
Expand All @@ -840,7 +842,9 @@ async def list_loaded_models_async(self) -> RegisteredModels:
"""
self.__ensure_v1_client_mode()
async with aiohttp.ClientSession() as session:
async with session.get(f"{self.__api_url}/model/registry") as response:
async with session.get(
f"{self.__api_url}/model/registry?api_key={self.__api_key}"
) as response:
response.raise_for_status()
response_payload = await response.json()
return RegisteredModels.from_dict(response_payload)
Expand Down
16 changes: 8 additions & 8 deletions tests/inference_sdk/unit_tests/http/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ async def test_list_loaded_models_async_when_successful_response_expected() -> N

with aioresponses() as m:
m.get(
f"{api_url}/model/registry",
f"{api_url}/model/registry?api_key=my-api-key",
payload={
"models": [
{
Expand Down Expand Up @@ -892,7 +892,7 @@ async def test_list_loaded_models_when_unsuccessful_response_expected() -> None:

with aioresponses() as m:
m.get(
f"{api_url}/model/registry",
f"{api_url}/model/registry?api_key=my-api-key",
payload={"message": "Internal error."},
status=500,
)
Expand Down Expand Up @@ -951,7 +951,7 @@ async def test_get_model_description_async_when_model_when_error_occurs_in_model

with aioresponses() as m:
m.get(
f"{api_url}/model/registry",
f"{api_url}/model/registry?api_key=my-api-key",
payload={"message": "Internal error."},
status=500,
)
Expand Down Expand Up @@ -1004,7 +1004,7 @@ async def test_get_model_description_async_when_model_was_loaded_already() -> No

with aioresponses() as m:
m.get(
f"{api_url}/model/registry",
f"{api_url}/model/registry?api_key=my-api-key",
payload={"models": [{"model_id": "some/1", "task_type": "classification"}]},
)
# when
Expand All @@ -1024,7 +1024,7 @@ async def test_get_model_description_async_when_model_was_loaded_already_and_ali

with aioresponses() as m:
m.get(
f"{api_url}/model/registry",
f"{api_url}/model/registry?api_key=my-api-key",
payload={
"models": [{"model_id": "coco/3", "task_type": "object-detection"}]
},
Expand Down Expand Up @@ -1096,7 +1096,7 @@ async def test_get_model_description_async_when_model_was_not_loaded_before_and_

with aioresponses() as m:
m.get(
f"{api_url}/model/registry",
f"{api_url}/model/registry?api_key=my-api-key",
payload={"models": []},
)
m.post(
Expand All @@ -1121,7 +1121,7 @@ async def test_get_model_description_async_when_model_was_not_loaded_before_and_

with aioresponses() as m:
m.get(
f"{api_url}/model/registry",
f"{api_url}/model/registry?api_key=my-api-key",
payload={"models": []},
)
m.post(
Expand Down Expand Up @@ -1173,7 +1173,7 @@ async def test_get_model_description_async_when_model_was_not_loaded_before_and_

with aioresponses() as m:
m.get(
f"{api_url}/model/registry",
f"{api_url}/model/registry?api_key=my-api-key",
payload={"models": []},
)
m.post(
Expand Down

0 comments on commit cf6e6d8

Please sign in to comment.