Skip to content

Commit 31ecf02

Browse files
Excavator: Upgrade API Version (#336)
1 parent cbebac6 commit 31ecf02

131 files changed

Lines changed: 261 additions & 13 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

foundry_sdk/_core/hostname_supplier.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from abc import ABC
1717
from abc import abstractmethod
1818
from enum import Enum
19+
from functools import cache
20+
from typing import Optional
1921

2022

2123
class EndpointType(Enum):
@@ -26,18 +28,25 @@ class EndpointType(Enum):
2628

2729
class HostnameSupplier(ABC):
2830
@abstractmethod
29-
def get_hostname(self, endpoint_type: EndpointType) -> str:
30-
"""Return the full base URL including scheme (e.g., 'https://example.com')."""
31+
def get_hostname(self, endpoint_type: Optional[EndpointType] = None) -> str:
32+
"""Return a base URL including scheme.
33+
34+
If endpoint_type is None, returns the base hostname (e.g., 'https://example.com').
35+
If endpoint_type is provided, returns the endpoint-specific URL.
36+
"""
3137
...
3238

3339

3440
class StaticHostnameSupplier(HostnameSupplier):
3541
def __init__(self, base_url: str) -> None:
42+
self._base_url = base_url
3643
self._api_gateway_url = base_url + "/api"
3744
self._multipass_url = base_url + "/multipass/api"
3845
self._stream_proxy_url = base_url + "/stream-proxy/api"
3946

40-
def get_hostname(self, endpoint_type: EndpointType) -> str:
47+
def get_hostname(self, endpoint_type: Optional[EndpointType] = None) -> str:
48+
if endpoint_type is None:
49+
return self._base_url
4150
if endpoint_type == EndpointType.GENERIC:
4251
return self._api_gateway_url
4352
elif endpoint_type == EndpointType.AUTH:
@@ -51,24 +60,23 @@ def get_hostname(self, endpoint_type: EndpointType) -> str:
5160
class ServiceDiscoveryHostnameSupplier(HostnameSupplier):
5261
def __init__(self, services: dict[str, list[str]]) -> None:
5362
self._services = services
54-
self._url_cache: dict[EndpointType, str] = {}
5563

56-
def get_hostname(self, endpoint_type: EndpointType) -> str:
57-
if endpoint_type in self._url_cache:
58-
return self._url_cache[endpoint_type]
64+
@cache
65+
def get_hostname( # pyright: ignore[reportIncompatibleMethodOverride]
66+
self, endpoint_type: Optional[EndpointType] = None
67+
) -> str:
68+
if endpoint_type is None:
69+
raise ValueError("ServiceDiscoveryHostnameSupplier requires an endpoint_type.")
5970

6071
if endpoint_type == EndpointType.GENERIC:
61-
url = self._find_service_url("api-gateway")
72+
return self._find_service_url("api-gateway")
6273
elif endpoint_type == EndpointType.AUTH:
63-
url = self._find_service_url("multipass")
74+
return self._find_service_url("multipass")
6475
elif endpoint_type == EndpointType.HIGH_SCALE:
65-
url = self._find_service_url("stream-proxy")
76+
return self._find_service_url("stream-proxy")
6677
else:
6778
raise ValueError(f"Unsupported endpoint type: {endpoint_type}")
6879

69-
self._url_cache[endpoint_type] = url
70-
return url
71-
7280
def _find_service_url(self, service_name: str) -> str:
7381
if service_name not in self._services:
7482
raise ValueError(f"Unable to discover service '{service_name}'.")

foundry_sdk/v1/datasets/_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def __init__(
3939
self._hostname_supplier = hostname
4040
else:
4141
self._hostname_supplier = core.create_hostname_supplier(hostname, config)
42+
self._hostname = self._hostname_supplier.get_hostname()
4243

4344
self._config = config
4445

foundry_sdk/v1/datasets/branch.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def __init__(
4545
self._hostname_supplier = hostname
4646
else:
4747
self._hostname_supplier = core.create_hostname_supplier(hostname, config)
48+
self._hostname = self._hostname_supplier.get_hostname()
4849
self._config = config
4950
self._api_client = core.ApiClient(
5051
auth=auth, hostname=self._hostname_supplier, config=config
@@ -317,6 +318,7 @@ def __init__(
317318
self._hostname_supplier = hostname
318319
else:
319320
self._hostname_supplier = core.create_hostname_supplier(hostname, config)
321+
self._hostname = self._hostname_supplier.get_hostname()
320322
self._config = config
321323
self._api_client = core.AsyncApiClient(
322324
auth=auth, hostname=self._hostname_supplier, config=config

foundry_sdk/v1/datasets/dataset.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def __init__(
4747
self._hostname_supplier = hostname
4848
else:
4949
self._hostname_supplier = core.create_hostname_supplier(hostname, config)
50+
self._hostname = self._hostname_supplier.get_hostname()
5051
self._config = config
5152
self._api_client = core.ApiClient(
5253
auth=auth, hostname=self._hostname_supplier, config=config
@@ -530,6 +531,7 @@ def __init__(
530531
self._hostname_supplier = hostname
531532
else:
532533
self._hostname_supplier = core.create_hostname_supplier(hostname, config)
534+
self._hostname = self._hostname_supplier.get_hostname()
533535
self._config = config
534536
self._api_client = core.AsyncApiClient(
535537
auth=auth, hostname=self._hostname_supplier, config=config

foundry_sdk/v1/datasets/file.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def __init__(
4646
self._hostname_supplier = hostname
4747
else:
4848
self._hostname_supplier = core.create_hostname_supplier(hostname, config)
49+
self._hostname = self._hostname_supplier.get_hostname()
4950
self._config = config
5051
self._api_client = core.ApiClient(
5152
auth=auth, hostname=self._hostname_supplier, config=config
@@ -592,6 +593,7 @@ def __init__(
592593
self._hostname_supplier = hostname
593594
else:
594595
self._hostname_supplier = core.create_hostname_supplier(hostname, config)
596+
self._hostname = self._hostname_supplier.get_hostname()
595597
self._config = config
596598
self._api_client = core.AsyncApiClient(
597599
auth=auth, hostname=self._hostname_supplier, config=config

foundry_sdk/v1/datasets/transaction.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def __init__(
4444
self._hostname_supplier = hostname
4545
else:
4646
self._hostname_supplier = core.create_hostname_supplier(hostname, config)
47+
self._hostname = self._hostname_supplier.get_hostname()
4748
self._config = config
4849
self._api_client = core.ApiClient(
4950
auth=auth, hostname=self._hostname_supplier, config=config
@@ -322,6 +323,7 @@ def __init__(
322323
self._hostname_supplier = hostname
323324
else:
324325
self._hostname_supplier = core.create_hostname_supplier(hostname, config)
326+
self._hostname = self._hostname_supplier.get_hostname()
325327
self._config = config
326328
self._api_client = core.AsyncApiClient(
327329
auth=auth, hostname=self._hostname_supplier, config=config

foundry_sdk/v1/ontologies/_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def __init__(
3939
self._hostname_supplier = hostname
4040
else:
4141
self._hostname_supplier = core.create_hostname_supplier(hostname, config)
42+
self._hostname = self._hostname_supplier.get_hostname()
4243

4344
self._config = config
4445

foundry_sdk/v1/ontologies/action.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def __init__(
4343
self._hostname_supplier = hostname
4444
else:
4545
self._hostname_supplier = core.create_hostname_supplier(hostname, config)
46+
self._hostname = self._hostname_supplier.get_hostname()
4647
self._config = config
4748
self._api_client = core.ApiClient(
4849
auth=auth, hostname=self._hostname_supplier, config=config
@@ -268,6 +269,7 @@ def __init__(
268269
self._hostname_supplier = hostname
269270
else:
270271
self._hostname_supplier = core.create_hostname_supplier(hostname, config)
272+
self._hostname = self._hostname_supplier.get_hostname()
271273
self._config = config
272274
self._api_client = core.AsyncApiClient(
273275
auth=auth, hostname=self._hostname_supplier, config=config

foundry_sdk/v1/ontologies/action_type.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def __init__(
4444
self._hostname_supplier = hostname
4545
else:
4646
self._hostname_supplier = core.create_hostname_supplier(hostname, config)
47+
self._hostname = self._hostname_supplier.get_hostname()
4748
self._config = config
4849
self._api_client = core.ApiClient(
4950
auth=auth, hostname=self._hostname_supplier, config=config
@@ -187,6 +188,7 @@ def __init__(
187188
self._hostname_supplier = hostname
188189
else:
189190
self._hostname_supplier = core.create_hostname_supplier(hostname, config)
191+
self._hostname = self._hostname_supplier.get_hostname()
190192
self._config = config
191193
self._api_client = core.AsyncApiClient(
192194
auth=auth, hostname=self._hostname_supplier, config=config

foundry_sdk/v1/ontologies/attachment.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def __init__(
4444
self._hostname_supplier = hostname
4545
else:
4646
self._hostname_supplier = core.create_hostname_supplier(hostname, config)
47+
self._hostname = self._hostname_supplier.get_hostname()
4748
self._config = config
4849
self._api_client = core.ApiClient(
4950
auth=auth, hostname=self._hostname_supplier, config=config
@@ -231,6 +232,7 @@ def __init__(
231232
self._hostname_supplier = hostname
232233
else:
233234
self._hostname_supplier = core.create_hostname_supplier(hostname, config)
235+
self._hostname = self._hostname_supplier.get_hostname()
234236
self._config = config
235237
self._api_client = core.AsyncApiClient(
236238
auth=auth, hostname=self._hostname_supplier, config=config

0 commit comments

Comments
 (0)