Skip to content

Commit cff3dc7

Browse files
committed
fix2
1 parent 76746c2 commit cff3dc7

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

submodel/api/ctl_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from typing import Optional
88

9-
from .api import run_api_query
9+
from .http import run_api_query
1010
from .mutations import container_register_auth as container_register_auth_mutations
1111
from .mutations import endpoints as endpoint_mutations
1212
from .mutations import pods as pod_mutations
File renamed without changes.

submodel/endpoint/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def _request(
6767
RuntimeError: If the response returns a 401 Unauthorized status.
6868
requests.HTTPError: If the response contains an unsuccessful status code.
6969
"""
70-
url = f"{self.endpoint_url_base}/{endpoint}"
70+
url = f"{self.endpoint_url_base}/sl/{endpoint}"
7171
response = self.sm_session.request(
7272
method, url, headers=self.headers, json=data, timeout=timeout
7373
)

tests/test_api/test_ctl_commands.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_get_user(self):
1313
"""
1414
Tests get_user
1515
"""
16-
with patch("submodel.api.requests.post") as patch_request:
16+
with patch("submodel.api.http.requests.post") as patch_request:
1717
patch_request.return_value.json.return_value = {
1818
"data": {
1919
"myself": {
@@ -29,7 +29,7 @@ def test_update_user_settings(self):
2929
"""
3030
Tests update_user_settings
3131
"""
32-
with patch("submodel.api.requests.post") as patch_request:
32+
with patch("submodel.api.http.requests.post") as patch_request:
3333
patch_request.return_value.json.return_value = {
3434
"data": {
3535
"updateUserSettings": {"id": "USER_ID", "publicKey": "PUBLIC_KEY"}
@@ -44,7 +44,7 @@ def test_get_gpus(self):
4444
"""
4545
Tests get_gpus
4646
"""
47-
with patch("submodel.api.requests.post") as patch_request:
47+
with patch("submodel.api.http.requests.post") as patch_request:
4848
patch_request.return_value.json.return_value = {
4949
"data": {
5050
"gpuTypes": [
@@ -66,7 +66,7 @@ def test_get_gpu(self):
6666
"""
6767
Tests get_gpu_by_id
6868
"""
69-
with patch("submodel.api.requests.post") as patch_request:
69+
with patch("submodel.api.http.requests.post") as patch_request:
7070
patch_request.return_value.json.return_value = {
7171
"data": {
7272
"gpuTypes": [
@@ -97,7 +97,7 @@ def test_create_pod(self):
9797
"""
9898
Tests create_pod
9999
"""
100-
with patch("submodel.api.requests.post") as patch_request, patch(
100+
with patch("submodel.api.http.requests.post") as patch_request, patch(
101101
"submodel.api.ctl_commands.get_gpu"
102102
) as patch_get_gpu, patch("submodel.api.ctl_commands.get_user") as patch_get_user:
103103
patch_request.return_value.json.return_value = {
@@ -140,7 +140,7 @@ def test_stop_pod(self):
140140
"""
141141
Test stop_pod
142142
"""
143-
with patch("submodel.api.requests.post") as patch_request:
143+
with patch("submodel.api.http.requests.post") as patch_request:
144144
patch_request.return_value.json.return_value = {
145145
"data": {"podStop": {"id": "POD_ID"}}
146146
}
@@ -153,7 +153,7 @@ def test_resume_pod(self):
153153
"""
154154
Test resume_pod
155155
"""
156-
with patch("submodel.api.requests.post") as patch_request:
156+
with patch("submodel.api.http.requests.post") as patch_request:
157157
patch_request.return_value.json.return_value = {
158158
"data": {"podResume": {"id": "POD_ID"}}
159159
}
@@ -166,7 +166,7 @@ def test_terminate_pod(self):
166166
"""
167167
Test terminate_pod
168168
"""
169-
with patch("submodel.api.requests.post") as patch_request:
169+
with patch("submodel.api.http.requests.post") as patch_request:
170170
patch_request.return_value.json.return_value = {
171171
"data": {"podTerminate": {"id": "POD_ID"}}
172172
}
@@ -177,7 +177,7 @@ def test_raised_error(self):
177177
"""
178178
Test raised_error
179179
"""
180-
with patch("submodel.api.requests.post") as patch_request:
180+
with patch("submodel.api.http.requests.post") as patch_request:
181181
patch_request.return_value.json.return_value = {
182182
"errors": [{"message": "Error Message"}]
183183
}
@@ -188,7 +188,7 @@ def test_raised_error(self):
188188
self.assertEqual(str(context.exception), "Error Message")
189189

190190
# Test Unauthorized with status code 401
191-
with patch("submodel.api.requests.post") as patch_request:
191+
with patch("submodel.api.http.requests.post") as patch_request:
192192
patch_request.return_value.status_code = 401
193193

194194
with self.assertRaises(Exception) as context:
@@ -203,7 +203,7 @@ def test_get_pods(self):
203203
"""
204204
Tests get_pods
205205
"""
206-
with patch("submodel.api.requests.post") as patch_request:
206+
with patch("submodel.api.http.requests.post") as patch_request:
207207
patch_request.return_value.json.return_value = {
208208
"data": {
209209
"myself": {
@@ -245,7 +245,7 @@ def test_get_pod(self):
245245
"""
246246
Tests get_pods
247247
"""
248-
with patch("submodel.api.requests.post") as patch_request:
248+
with patch("submodel.api.http.requests.post") as patch_request:
249249
patch_request.return_value.json.return_value = {
250250
"data": {
251251
"pod": {
@@ -282,7 +282,7 @@ def test_create_template(self):
282282
"""
283283
Tests create_template
284284
"""
285-
with patch("submodel.api.requests.post") as patch_request, patch(
285+
with patch("submodel.api.http.requests.post") as patch_request, patch(
286286
"submodel.api.ctl_commands.get_gpu"
287287
) as patch_get_gpu:
288288
patch_request.return_value.json.return_value = {
@@ -301,7 +301,7 @@ def test_get_endpoints(self):
301301
"""
302302
Tests get_endpoints
303303
"""
304-
with patch("submodel.api.requests.post") as patch_request:
304+
with patch("submodel.api.http.requests.post") as patch_request:
305305
patch_request.return_value.json.return_value = {
306306
"data": {
307307
"myself": {
@@ -328,7 +328,7 @@ def test_create_endpoint(self):
328328
"""
329329
Tests create_endpoint
330330
"""
331-
with patch("submodel.api.requests.post") as patch_request, patch(
331+
with patch("submodel.api.http.requests.post") as patch_request, patch(
332332
"submodel.api.ctl_commands.get_gpu"
333333
) as patch_get_gpu:
334334
patch_request.return_value.json.return_value = {
@@ -347,7 +347,7 @@ def test_update_endpoint_template(self):
347347
"""
348348
Tests update_endpoint_template
349349
"""
350-
with patch("submodel.api.requests.post") as patch_request, patch(
350+
with patch("submodel.api.http.requests.post") as patch_request, patch(
351351
"submodel.api.ctl_commands.get_gpu"
352352
) as patch_get_gpu:
353353
patch_request.return_value.json.return_value = {

tests/test_endpoint/test_runner.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def test_post_with_401(self, mock_post):
3535
with self.assertRaises(RuntimeError):
3636
submodel.api_key = "MOCK_API_KEY"
3737
client = SubModelClient()
38-
client.post("ENDPOINT_ID/run", {"input": {}})
38+
client.post("sl/ENDPOINT_ID/run", {"input": {}})
3939

4040
@patch.object(requests.Session, "request")
4141
def test_post(self, mock_post):
@@ -49,7 +49,7 @@ def test_post(self, mock_post):
4949

5050
submodel.api_key = "MOCK_API_KEY"
5151
client = SubModelClient()
52-
response = client.post("ENDPOINT_ID/run", {"input": {}})
52+
response = client.post("sl/ENDPOINT_ID/run", {"input": {}})
5353

5454
self.assertEqual(response, {"id": "123"})
5555

@@ -65,7 +65,7 @@ def test_get_with_401(self, mock_get):
6565
with self.assertRaises(RuntimeError):
6666
submodel.api_key = "MOCK_API_KEY"
6767
client = SubModelClient()
68-
client.get("ENDPOINT_ID/status/123")
68+
client.get("sl/ENDPOINT_ID/status/123")
6969

7070
@patch.object(requests.Session, "request")
7171
def test_get(self, mock_get):
@@ -79,7 +79,7 @@ def test_get(self, mock_get):
7979

8080
submodel.api_key = "MOCK_API_KEY"
8181
client = SubModelClient()
82-
response = client.get("ENDPOINT_ID/status/123")
82+
response = client.get("sl/ENDPOINT_ID/status/123")
8383

8484
self.assertEqual(response, {"status": "COMPLETED"})
8585

@@ -107,7 +107,7 @@ def test_endpoint_run(self, mock_client_request):
107107
# Tests
108108
mock_client_request.assert_called_once_with(
109109
"POST",
110-
f"{self.ENDPOINT_ID}/run",
110+
f"sl/{self.ENDPOINT_ID}/run",
111111
{"input": {"YOUR_MODEL_INPUT_JSON": "YOUR_MODEL_INPUT_VALUE"}},
112112
10,
113113
)
@@ -117,7 +117,7 @@ def test_endpoint_run(self, mock_client_request):
117117
self.assertEqual(run_request.status(), "IN_PROGRESS")
118118

119119
mock_client_request.assert_called_with(
120-
"GET", f"{self.ENDPOINT_ID}/status/123", timeout=10
120+
"GET", f"sl/{self.ENDPOINT_ID}/status/123", timeout=10
121121
)
122122

123123
@patch("submodel.endpoint.runner.SubModelClient._request")

0 commit comments

Comments
 (0)