Skip to content

Commit 0b802ef

Browse files
committed
fixed integration tests and added back usage_type filtering since PR got merged togethercomputer/together-dedicated-endpoints#92
1 parent 8a50bb7 commit 0b802ef

File tree

4 files changed

+45
-14
lines changed

4 files changed

+45
-14
lines changed

poetry.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ numpy = [
4343
{ version = ">=1.26.0", python = ">=3.12" },
4444
]
4545
pillow = "^11.1.0"
46+
black = "^25.9.0"
4647

4748
[tool.poetry.extras]
4849
pyarrow = ["pyarrow"]

src/together/cli/api/endpoints.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,16 +343,24 @@ def delete(client: Together, endpoint_id: str) -> None:
343343
default=None,
344344
help="true (only mine), false (exclude mine), default=all",
345345
)
346+
@click.option(
347+
"--usage-type",
348+
type=click.Choice(["on-demand", "reserved"]),
349+
help="Filter by endpoint usage type",
350+
)
346351
@click.pass_obj
347352
@handle_api_errors
348353
def list(
349-
client: Together,
350-
json: bool,
354+
client: Together,
355+
json: bool,
351356
type: Literal["dedicated", "serverless"] | None,
357+
usage_type: Literal["on-demand", "reserved"] | None,
352358
mine: bool | None,
353359
) -> None:
354360
"""List all inference endpoints (includes both dedicated and serverless endpoints)."""
355-
endpoints: List[ListEndpoint] = client.endpoints.list(type=type, mine=mine)
361+
endpoints: List[ListEndpoint] = client.endpoints.list(
362+
type=type, usage_type=usage_type, mine=mine
363+
)
356364

357365
if not endpoints:
358366
click.echo("No dedicated endpoints found", err=True)

src/together/resources/endpoints.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ def __init__(self, client: TogetherClient) -> None:
1515
def list(
1616
self,
1717
type: Optional[Literal["dedicated", "serverless"]] = None,
18+
usage_type: Optional[Literal["on-demand", "reserved"]] = None,
1819
mine: Optional[bool] = None,
1920
) -> List[ListEndpoint]:
2021
"""
2122
List all endpoints, can be filtered by endpoint type and ownership.
2223
2324
Args:
2425
type (str, optional): Filter endpoints by endpoint type ("dedicated" or "serverless"). Defaults to None.
26+
usage_type (str, optional): Filter endpoints by usage type ("on-demand" or "reserved"). Defaults to None.
2527
mine (bool, optional): If True, return only endpoints owned by the caller. If False, return endpoints not owned by the caller. Defaults to None.
2628
2729
Returns:
@@ -31,9 +33,18 @@ def list(
3133
client=self._client,
3234
)
3335

34-
params = {}
36+
params: Dict[
37+
str,
38+
Union[
39+
Literal["dedicated", "serverless"],
40+
Literal["on-demand", "reserved"],
41+
bool,
42+
],
43+
] = {}
3544
if type is not None:
3645
params["type"] = type
46+
if usage_type is not None:
47+
params["usage_type"] = usage_type
3748
if mine is not None:
3849
params["mine"] = mine
3950

@@ -270,13 +281,15 @@ def __init__(self, client: TogetherClient) -> None:
270281
async def list(
271282
self,
272283
type: Optional[Literal["dedicated", "serverless"]] = None,
284+
usage_type: Optional[Literal["on-demand", "reserved"]] = None,
273285
mine: Optional[bool] = None,
274286
) -> List[ListEndpoint]:
275287
"""
276288
List all endpoints, can be filtered by type and ownership.
277289
278290
Args:
279291
type (str, optional): Filter endpoints by type ("dedicated" or "serverless"). Defaults to None.
292+
usage_type (str, optional): Filter endpoints by usage type ("on-demand" or "reserved"). Defaults to None.
280293
mine (bool, optional): If True, return only endpoints owned by the caller. If False, return endpoints not owned by the caller. Defaults to None.
281294
282295
Returns:
@@ -286,9 +299,18 @@ async def list(
286299
client=self._client,
287300
)
288301

289-
params = {}
302+
params: Dict[
303+
str,
304+
Union[
305+
Literal["dedicated", "serverless"],
306+
Literal["on-demand", "reserved"],
307+
bool,
308+
],
309+
] = {}
290310
if type is not None:
291311
params["type"] = type
312+
if usage_type is not None:
313+
params["usage_type"] = usage_type
292314
if mine is not None:
293315
params["mine"] = mine
294316

0 commit comments

Comments
 (0)