Skip to content

Commit 4f3a6ae

Browse files
committed
update
1 parent ec54446 commit 4f3a6ae

11 files changed

Lines changed: 156 additions & 1553 deletions

‎examples/flowstate_simple_example.ipynb‎

Lines changed: 97 additions & 935 deletions
Large diffs are not rendered by default.

‎examples/toto_simple_example.ipynb‎

Lines changed: 0 additions & 558 deletions
This file was deleted.

‎faim_client/api/forecast/forecast_v1_ts_forecast_model_name_model_version_post.py‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from http import HTTPStatus
22
from io import BytesIO
3-
from typing import Any, Optional, Union, cast
3+
from typing import Any, cast
44

55
import httpx
66

@@ -32,8 +32,8 @@ def _get_kwargs(
3232

3333

3434
def _parse_response(
35-
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
36-
) -> Optional[Union[Any, File]]:
35+
*, client: AuthenticatedClient | Client, response: httpx.Response
36+
) -> Any | File | None:
3737
if response.status_code == 200:
3838
response_200 = File(payload=BytesIO(response.content))
3939

@@ -66,8 +66,8 @@ def _parse_response(
6666

6767

6868
def _build_response(
69-
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
70-
) -> Response[Union[Any, File]]:
69+
*, client: AuthenticatedClient | Client, response: httpx.Response
70+
) -> Response[Any | File]:
7171
return Response(
7272
status_code=HTTPStatus(response.status_code),
7373
content=response.content,
@@ -80,9 +80,9 @@ def sync_detailed(
8080
model_name: ModelName,
8181
model_version: str,
8282
*,
83-
client: Union[AuthenticatedClient, Client],
83+
client: AuthenticatedClient | Client,
8484
body: File,
85-
) -> Response[Union[Any, File]]:
85+
) -> Response[Any | File]:
8686
r"""Generate model forecast
8787
8888
Generate time series forecasts using the specified Triton model.
@@ -142,9 +142,9 @@ def sync(
142142
model_name: ModelName,
143143
model_version: str,
144144
*,
145-
client: Union[AuthenticatedClient, Client],
145+
client: AuthenticatedClient | Client,
146146
body: File,
147-
) -> Optional[Union[Any, File]]:
147+
) -> Any | File | None:
148148
r"""Generate model forecast
149149
150150
Generate time series forecasts using the specified Triton model.
@@ -199,9 +199,9 @@ async def asyncio_detailed(
199199
model_name: ModelName,
200200
model_version: str,
201201
*,
202-
client: Union[AuthenticatedClient, Client],
202+
client: AuthenticatedClient | Client,
203203
body: File,
204-
) -> Response[Union[Any, File]]:
204+
) -> Response[Any | File]:
205205
r"""Generate model forecast
206206
207207
Generate time series forecasts using the specified Triton model.
@@ -259,9 +259,9 @@ async def asyncio(
259259
model_name: ModelName,
260260
model_version: str,
261261
*,
262-
client: Union[AuthenticatedClient, Client],
262+
client: AuthenticatedClient | Client,
263263
body: File,
264-
) -> Optional[Union[Any, File]]:
264+
) -> Any | File | None:
265265
r"""Generate model forecast
266266
267267
Generate time series forecasts using the specified Triton model.

‎faim_client/api/health/health_check_health_get.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from http import HTTPStatus
2-
from typing import Any, Optional, Union
2+
from typing import Any
33

44
import httpx
55

@@ -17,7 +17,7 @@ def _get_kwargs() -> dict[str, Any]:
1717
return _kwargs
1818

1919

20-
def _parse_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Optional[Any]:
20+
def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Any | None:
2121
if response.status_code == 200:
2222
return None
2323

@@ -27,7 +27,7 @@ def _parse_response(*, client: Union[AuthenticatedClient, Client], response: htt
2727
return None
2828

2929

30-
def _build_response(*, client: Union[AuthenticatedClient, Client], response: httpx.Response) -> Response[Any]:
30+
def _build_response(*, client: AuthenticatedClient | Client, response: httpx.Response) -> Response[Any]:
3131
return Response(
3232
status_code=HTTPStatus(response.status_code),
3333
content=response.content,
@@ -38,7 +38,7 @@ def _build_response(*, client: Union[AuthenticatedClient, Client], response: htt
3838

3939
def sync_detailed(
4040
*,
41-
client: Union[AuthenticatedClient, Client],
41+
client: AuthenticatedClient | Client,
4242
) -> Response[Any]:
4343
"""Health check
4444
@@ -63,7 +63,7 @@ def sync_detailed(
6363

6464
async def asyncio_detailed(
6565
*,
66-
client: Union[AuthenticatedClient, Client],
66+
client: AuthenticatedClient | Client,
6767
) -> Response[Any]:
6868
"""Health check
6969

‎faim_client/client.py‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ssl
2-
from typing import Any, Optional, Union
2+
from typing import Any
33

44
import httpx
55
from attrs import define, evolve, field
@@ -38,12 +38,12 @@ class Client:
3838
_base_url: str = field(alias="base_url")
3939
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
4040
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
41-
_timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout")
42-
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl")
41+
_timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout")
42+
_verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl")
4343
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
4444
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
45-
_client: Optional[httpx.Client] = field(default=None, init=False)
46-
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
45+
_client: httpx.Client | None = field(default=None, init=False)
46+
_async_client: httpx.AsyncClient | None = field(default=None, init=False)
4747

4848
def with_headers(self, headers: dict[str, str]) -> "Client":
4949
"""Get a new client matching this one with additional headers"""
@@ -168,12 +168,12 @@ class AuthenticatedClient:
168168
_base_url: str = field(alias="base_url")
169169
_cookies: dict[str, str] = field(factory=dict, kw_only=True, alias="cookies")
170170
_headers: dict[str, str] = field(factory=dict, kw_only=True, alias="headers")
171-
_timeout: Optional[httpx.Timeout] = field(default=None, kw_only=True, alias="timeout")
172-
_verify_ssl: Union[str, bool, ssl.SSLContext] = field(default=True, kw_only=True, alias="verify_ssl")
171+
_timeout: httpx.Timeout | None = field(default=None, kw_only=True, alias="timeout")
172+
_verify_ssl: str | bool | ssl.SSLContext = field(default=True, kw_only=True, alias="verify_ssl")
173173
_follow_redirects: bool = field(default=False, kw_only=True, alias="follow_redirects")
174174
_httpx_args: dict[str, Any] = field(factory=dict, kw_only=True, alias="httpx_args")
175-
_client: Optional[httpx.Client] = field(default=None, init=False)
176-
_async_client: Optional[httpx.AsyncClient] = field(default=None, init=False)
175+
_client: httpx.Client | None = field(default=None, init=False)
176+
_async_client: httpx.AsyncClient | None = field(default=None, init=False)
177177

178178
token: str
179179
prefix: str = "Bearer"

‎faim_client/models/error_response.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections.abc import Mapping
2-
from typing import Any, TypeVar, Union, cast
2+
from typing import Any, TypeVar, cast
33

44
from attrs import define as _attrs_define
55
from attrs import field as _attrs_field
@@ -22,13 +22,13 @@ class ErrorResponse:
2222
"""
2323

2424
error: str
25-
detail: Union[None, Unset, str] = UNSET
25+
detail: None | Unset | str = UNSET
2626
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)
2727

2828
def to_dict(self) -> dict[str, Any]:
2929
error = self.error
3030

31-
detail: Union[None, Unset, str]
31+
detail: None | Unset | str
3232
if isinstance(self.detail, Unset):
3333
detail = UNSET
3434
else:
@@ -51,12 +51,12 @@ def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
5151
d = dict(src_dict)
5252
error = d.pop("error")
5353

54-
def _parse_detail(data: object) -> Union[None, Unset, str]:
54+
def _parse_detail(data: object) -> None | Unset | str:
5555
if data is None:
5656
return data
5757
if isinstance(data, Unset):
5858
return data
59-
return cast(Union[None, Unset, str], data)
59+
return cast(None | Unset | str, data)
6060

6161
detail = _parse_detail(d.pop("detail", UNSET))
6262

‎faim_client/types.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from collections.abc import Mapping, MutableMapping
44
from http import HTTPStatus
5-
from typing import IO, BinaryIO, Generic, Literal, Optional, TypeVar, Union
5+
from typing import IO, BinaryIO, Generic, Literal, TypeVar, Union
66

77
from attrs import define
88

@@ -18,9 +18,9 @@ def __bool__(self) -> Literal[False]:
1818
FileContent = Union[IO[bytes], bytes, str]
1919
FileTypes = Union[
2020
# (filename, file (or bytes), content_type)
21-
tuple[Optional[str], FileContent, Optional[str]],
21+
tuple[str | None, FileContent, str | None],
2222
# (filename, file (or bytes), content_type, headers)
23-
tuple[Optional[str], FileContent, Optional[str], Mapping[str, str]],
23+
tuple[str | None, FileContent, str | None, Mapping[str, str]],
2424
]
2525
RequestFiles = list[tuple[str, FileTypes]]
2626

@@ -30,8 +30,8 @@ class File:
3030
"""Contains information for file uploads"""
3131

3232
payload: BinaryIO
33-
file_name: Optional[str] = None
34-
mime_type: Optional[str] = None
33+
file_name: str | None = None
34+
mime_type: str | None = None
3535

3636
def to_tuple(self) -> FileTypes:
3737
"""Return a tuple representation that httpx will accept for multipart/form-data"""
@@ -48,7 +48,7 @@ class Response(Generic[T]):
4848
status_code: HTTPStatus
4949
content: bytes
5050
headers: MutableMapping[str, str]
51-
parsed: Optional[T]
51+
parsed: T | None
5252

5353

5454
__all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"]

‎faim_sdk/client.py‎

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

77
import io
88
import logging
9-
from typing import Optional
109

1110
import httpx
1211

@@ -59,7 +58,7 @@ def __init__(
5958
base_url: str,
6059
timeout: float = 120.0,
6160
verify_ssl: bool = True,
62-
api_key: Optional[str] = None,
61+
api_key: str | None = None,
6362
**httpx_kwargs,
6463
) -> None:
6564
"""Initialize FAIM forecast client.

‎faim_sdk/exceptions.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Provides a hierarchy of exceptions for precise error handling and debugging.
44
"""
55

6-
from typing import Any, Optional
6+
from typing import Any
77

88
from faim_client.models.error_response import ErrorResponse
99

@@ -15,7 +15,7 @@ class FAIMError(Exception):
1515
error handling when needed.
1616
"""
1717

18-
def __init__(self, message: str, details: Optional[dict[str, Any]] = None) -> None:
18+
def __init__(self, message: str, details: dict[str, Any] | None = None) -> None:
1919
"""Initialize FAIM error.
2020
2121
Args:
@@ -53,9 +53,9 @@ class APIError(FAIMError):
5353
def __init__(
5454
self,
5555
message: str,
56-
status_code: Optional[int] = None,
57-
response: Optional[ErrorResponse] = None,
58-
details: Optional[dict[str, Any]] = None,
56+
status_code: int | None = None,
57+
response: ErrorResponse | None = None,
58+
details: dict[str, Any] | None = None,
5959
) -> None:
6060
"""Initialize API error.
6161

‎faim_sdk/models.py‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66

77
from dataclasses import dataclass, field
8-
from typing import Any, Literal, Optional
8+
from typing import Any, Literal
99

1010
import numpy as np
1111

@@ -31,7 +31,7 @@ class ForecastRequest:
3131
model_version: str = "1"
3232
"""Model version to use for inference. Default: '1'"""
3333

34-
compression: Optional[str] = "zstd"
34+
compression: str | None = "zstd"
3535
"""Arrow compression algorithm. Options: 'zstd', 'lz4', None. Default: 'zstd'"""
3636

3737
def __post_init__(self) -> None:
@@ -74,19 +74,19 @@ class ToToForecastRequest(ForecastRequest):
7474
output_type: OutputType = "point"
7575
"""Output type to return. Options: 'point', 'quantiles', 'samples'. Default: 'point'."""
7676

77-
padding_mask: Optional[np.ndarray] = None
77+
padding_mask: np.ndarray | None = None
7878
"""Padding mask for variable-length sequences. Shape: same as x.
7979
1 for valid timesteps, 0 for padding."""
8080

81-
id_mask: Optional[np.ndarray] = None
81+
id_mask: np.ndarray | None = None
8282
"""Identifier mask for multi-series forecasting. Shape: (batch_size,).
8383
Each unique ID represents a different time series."""
8484

85-
num_samples: Optional[int] = None
85+
num_samples: int | None = None
8686
"""Number of forecast samples for probabilistic predictions.
8787
If set, returns sample-based distribution."""
8888

89-
quantiles: Optional[list[float]] = None
89+
quantiles: list[float] | None = None
9090
"""Quantile levels for probabilistic forecasting.
9191
Example: [0.1, 0.5, 0.9] for 10th, 50th (median), 90th percentiles."""
9292

@@ -142,11 +142,11 @@ class FlowStateForecastRequest(ForecastRequest):
142142
output_type: OutputType = "point"
143143
"""Output type to return. Options: 'point', 'quantiles', 'samples'. Default: 'point'."""
144144

145-
scale_factor: Optional[float] = None
145+
scale_factor: float | None = None
146146
"""Scaling factor for normalization/denormalization.
147147
Applied to inputs before inference and outputs after inference."""
148148

149-
prediction_type: Optional[Literal["mean", "median", "quantile"]] = None
149+
prediction_type: Literal["mean", "median", "quantile"] | None = None
150150
"""Prediction type for FlowState model.
151151
Options: 'mean', 'median' (requires output_type='point'),
152152
'quantile' (requires output_type='quantiles')."""
@@ -179,7 +179,7 @@ def __post_init__(self) -> None:
179179
)
180180
if self.output_type == "point" and self.prediction_type == "quantile":
181181
raise ValueError(
182-
f"output_type='point' conflicts with prediction_type='quantile'"
182+
"output_type='point' conflicts with prediction_type='quantile'"
183183
)
184184

185185
def to_arrays_and_metadata(self) -> tuple[dict[str, np.ndarray], dict[str, Any]]:
@@ -208,13 +208,13 @@ class ForecastResponse:
208208
"""Response metadata from backend (e.g., model_name, model_version)"""
209209

210210
# Backend outputs
211-
point: Optional[np.ndarray] = None
211+
point: np.ndarray | None = None
212212
"""Point predictions from FlowState. Shape: (batch_size, horizon, features)"""
213213

214-
quantiles: Optional[np.ndarray] = None
214+
quantiles: np.ndarray | None = None
215215
"""Quantile predictions from ToTo. Shape: (batch_size, horizon, num_quantiles)"""
216216

217-
samples: Optional[np.ndarray] = None
217+
samples: np.ndarray | None = None
218218
"""Sample predictions from ToTo. Shape: (batch_size, horizon, num_samples)"""
219219

220220
@classmethod

0 commit comments

Comments
 (0)