Skip to content

Commit c980c52

Browse files
feat(types): replace List[str] with SequenceNotStr in params
1 parent 542f668 commit c980c52

File tree

5 files changed

+24
-14
lines changed

5 files changed

+24
-14
lines changed

src/openlayer/_utils/_transform.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
lru_cache,
1717
is_mapping,
1818
is_iterable,
19+
is_sequence,
1920
)
2021
from .._files import is_base64_file_input
2122
from ._typing import (
@@ -24,6 +25,7 @@
2425
extract_type_arg,
2526
is_iterable_type,
2627
is_required_type,
28+
is_sequence_type,
2729
is_annotated_type,
2830
strip_annotated_type,
2931
)
@@ -184,6 +186,8 @@ def _transform_recursive(
184186
(is_list_type(stripped_type) and is_list(data))
185187
# Iterable[T]
186188
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
189+
# Sequence[T]
190+
or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str))
187191
):
188192
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
189193
# intended as an iterable, so we don't transform it.
@@ -346,6 +350,8 @@ async def _async_transform_recursive(
346350
(is_list_type(stripped_type) and is_list(data))
347351
# Iterable[T]
348352
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
353+
# Sequence[T]
354+
or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str))
349355
):
350356
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
351357
# intended as an iterable, so we don't transform it.

src/openlayer/types/inference_pipelines/data_stream_params.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
from __future__ import annotations
44

5-
from typing import Dict, List, Union, Iterable, Optional
5+
from typing import Dict, Union, Iterable, Optional
66
from typing_extensions import Required, Annotated, TypeAlias, TypedDict
77

8+
from ..._types import SequenceNotStr
89
from ..._utils import PropertyInfo
910

1011
__all__ = [
@@ -60,7 +61,7 @@ class ConfigLlmData(TypedDict, total=False):
6061
provided, a unique id is generated by Openlayer.
6162
"""
6263

63-
input_variable_names: Annotated[List[str], PropertyInfo(alias="inputVariableNames")]
64+
input_variable_names: Annotated[SequenceNotStr[str], PropertyInfo(alias="inputVariableNames")]
6465
"""Array of input variable names. Each input variable should be a dataset column."""
6566

6667
latency_column_name: Annotated[str, PropertyInfo(alias="latencyColumnName")]
@@ -90,19 +91,19 @@ class ConfigLlmData(TypedDict, total=False):
9091

9192

9293
class ConfigTabularClassificationData(TypedDict, total=False):
93-
class_names: Required[Annotated[List[str], PropertyInfo(alias="classNames")]]
94+
class_names: Required[Annotated[SequenceNotStr[str], PropertyInfo(alias="classNames")]]
9495
"""List of class names indexed by label integer in the dataset.
9596
9697
E.g. ["Retained", "Exited"] when 0, 1 are in your label column.
9798
"""
9899

99-
categorical_feature_names: Annotated[List[str], PropertyInfo(alias="categoricalFeatureNames")]
100+
categorical_feature_names: Annotated[SequenceNotStr[str], PropertyInfo(alias="categoricalFeatureNames")]
100101
"""Array with the names of all categorical features in the dataset.
101102
102103
E.g. ["Age", "Geography"].
103104
"""
104105

105-
feature_names: Annotated[List[str], PropertyInfo(alias="featureNames")]
106+
feature_names: Annotated[SequenceNotStr[str], PropertyInfo(alias="featureNames")]
106107
"""Array with all input feature names."""
107108

108109
inference_id_column_name: Annotated[str, PropertyInfo(alias="inferenceIdColumnName")]
@@ -143,13 +144,13 @@ class ConfigTabularClassificationData(TypedDict, total=False):
143144

144145

145146
class ConfigTabularRegressionData(TypedDict, total=False):
146-
categorical_feature_names: Annotated[List[str], PropertyInfo(alias="categoricalFeatureNames")]
147+
categorical_feature_names: Annotated[SequenceNotStr[str], PropertyInfo(alias="categoricalFeatureNames")]
147148
"""Array with the names of all categorical features in the dataset.
148149
149150
E.g. ["Gender", "Geography"].
150151
"""
151152

152-
feature_names: Annotated[List[str], PropertyInfo(alias="featureNames")]
153+
feature_names: Annotated[SequenceNotStr[str], PropertyInfo(alias="featureNames")]
153154
"""Array with all input feature names."""
154155

155156
inference_id_column_name: Annotated[str, PropertyInfo(alias="inferenceIdColumnName")]
@@ -180,7 +181,7 @@ class ConfigTabularRegressionData(TypedDict, total=False):
180181

181182

182183
class ConfigTextClassificationData(TypedDict, total=False):
183-
class_names: Required[Annotated[List[str], PropertyInfo(alias="classNames")]]
184+
class_names: Required[Annotated[SequenceNotStr[str], PropertyInfo(alias="classNames")]]
184185
"""List of class names indexed by label integer in the dataset.
185186
186187
E.g. ["Retained", "Exited"] when 0, 1 are in your label column.

src/openlayer/types/projects/inference_pipeline_create_params.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Optional
5+
from typing import Optional
66
from typing_extensions import Literal, Required, Annotated, TypedDict
77

8+
from ..._types import SequenceNotStr
89
from ..._utils import PropertyInfo
910

1011
__all__ = ["InferencePipelineCreateParams", "Project", "Workspace"]
@@ -51,4 +52,4 @@ class Workspace(TypedDict, total=False):
5152
saml_only_access: Annotated[bool, PropertyInfo(alias="samlOnlyAccess")]
5253
"""Whether the workspace only allows SAML authentication."""
5354

54-
wildcard_domains: Annotated[List[str], PropertyInfo(alias="wildcardDomains")]
55+
wildcard_domains: Annotated[SequenceNotStr[str], PropertyInfo(alias="wildcardDomains")]

src/openlayer/types/projects/test_create_params.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Union, Iterable, Optional
5+
from typing import Union, Iterable, Optional
66
from typing_extensions import Literal, Required, Annotated, TypedDict
77

8+
from ..._types import SequenceNotStr
89
from ..._utils import PropertyInfo
910

1011
__all__ = ["TestCreateParams", "Threshold", "ThresholdInsightParameter"]
@@ -165,5 +166,5 @@ class Threshold(TypedDict, total=False):
165166
threshold_mode: Annotated[Literal["automatic", "manual"], PropertyInfo(alias="thresholdMode")]
166167
"""Whether to use automatic anomaly detection or manual thresholds"""
167168

168-
value: Union[float, bool, str, List[str]]
169+
value: Union[float, bool, str, SequenceNotStr[str]]
169170
"""The value to be compared."""

src/openlayer/types/projects/test_update_params.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
from __future__ import annotations
44

5-
from typing import List, Union, Iterable, Optional
5+
from typing import Union, Iterable, Optional
66
from typing_extensions import Literal, Required, Annotated, TypedDict
77

8+
from ..._types import SequenceNotStr
89
from ..._utils import PropertyInfo
910

1011
__all__ = ["TestUpdateParams", "Payload", "PayloadThreshold", "PayloadThresholdInsightParameter"]
@@ -82,7 +83,7 @@ class PayloadThreshold(TypedDict, total=False):
8283
threshold_mode: Annotated[Literal["automatic", "manual"], PropertyInfo(alias="thresholdMode")]
8384
"""Whether to use automatic anomaly detection or manual thresholds"""
8485

85-
value: Union[float, bool, str, List[str]]
86+
value: Union[float, bool, str, SequenceNotStr[str]]
8687
"""The value to be compared."""
8788

8889

0 commit comments

Comments
 (0)