Skip to content

Commit b6314cd

Browse files
Apply ruff formatting fixes
Co-Authored-By: Francisco Javier Arceo <arceofrancisco@gmail.com>
1 parent 33acbd1 commit b6314cd

19 files changed

Lines changed: 97 additions & 102 deletions

File tree

‎sdk/python/feast/feature_view.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ def __init__(
196196
else:
197197
features.append(field)
198198

199-
assert len([f for f in features if f.vector_index]) < 2, (
200-
f"Only one vector feature is allowed per feature view. Please update {self.name}."
201-
)
199+
assert (
200+
len([f for f in features if f.vector_index]) < 2
201+
), f"Only one vector feature is allowed per feature view. Please update {self.name}."
202202

203203
# TODO(felixwang9817): Add more robust validation of features.
204204
cols = [field.name for field in schema]

‎sdk/python/feast/infra/compute_engines/snowflake/snowflake_engine.py‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ def __init__(
187187
online_store: OnlineStore,
188188
**kwargs,
189189
):
190-
assert repo_config.offline_store.type == "snowflake.offline", (
191-
"To use Snowflake Compute Engine, you must use Snowflake as an offline store."
192-
)
190+
assert (
191+
repo_config.offline_store.type == "snowflake.offline"
192+
), "To use Snowflake Compute Engine, you must use Snowflake as an offline store."
193193

194194
super().__init__(
195195
repo_config=repo_config,
@@ -210,11 +210,10 @@ def _materialize_one(
210210
project = task.project
211211
tqdm_builder = task.tqdm_builder if task.tqdm_builder else tqdm
212212

213-
assert isinstance(feature_view, BatchFeatureView) or isinstance(
214-
feature_view, FeatureView
215-
), (
216-
"Snowflake can only materialize FeatureView & BatchFeatureView feature view types."
217-
)
213+
assert (
214+
isinstance(feature_view, BatchFeatureView)
215+
or isinstance(feature_view, FeatureView)
216+
), "Snowflake can only materialize FeatureView & BatchFeatureView feature view types."
218217

219218
entities = []
220219
for entity_name in feature_view.entities:

‎sdk/python/feast/infra/offline_stores/dask.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ def evaluate_historical_retrieval():
191191
):
192192
# Make sure all event timestamp fields are tz-aware. We default tz-naive fields to UTC
193193
entity_df_with_features[entity_df_event_timestamp_col] = (
194-
entity_df_with_features[entity_df_event_timestamp_col].apply(
194+
entity_df_with_features[
195+
entity_df_event_timestamp_col
196+
].apply(
195197
lambda x: x
196198
if x.tzinfo is not None
197199
else x.replace(tzinfo=timezone.utc)

‎sdk/python/feast/infra/online_stores/milvus_online_store/milvus.py‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,7 @@ def online_read(
326326
assert all(
327327
field in [f["name"] for f in collection["fields"]]
328328
for field in output_fields
329-
), (
330-
f"field(s) [{[field for field in output_fields if field not in [f['name'] for f in collection['fields']]]}] not found in collection schema"
331-
)
329+
), f"field(s) [{[field for field in output_fields if field not in [f['name'] for f in collection['fields']]]}] not found in collection schema"
332330
composite_entities = []
333331
for entity_key in entity_keys:
334332
entity_key_str = serialize_entity_key(
@@ -522,9 +520,7 @@ def retrieve_online_documents_v2(
522520
assert all(
523521
field in [f["name"] for f in collection["fields"]]
524522
for field in output_fields
525-
), (
526-
f"field(s) [{[field for field in output_fields if field not in [f['name'] for f in collection['fields']]]}] not found in collection schema"
527-
)
523+
), f"field(s) [{[field for field in output_fields if field not in [f['name'] for f in collection['fields']]]}] not found in collection schema"
528524

529525
# Find the vector search field if we need it
530526
ann_search_field = None

‎sdk/python/feast/infra/online_stores/online_store.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,9 @@ def retrieve_online_documents_v2(
460460
where the first item is the event timestamp for the row, and the second item is a dict of feature
461461
name to embeddings.
462462
"""
463-
assert embedding is not None or query_string is not None, (
464-
"Either embedding or query_string must be specified"
465-
)
463+
assert (
464+
embedding is not None or query_string is not None
465+
), "Either embedding or query_string must be specified"
466466
raise NotImplementedError(
467467
f"Online store {self.__class__.__name__} does not support online retrieval"
468468
)

‎sdk/python/feast/infra/online_stores/qdrant_online_store/qdrant.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ def _get_client(self, config: RepoConfig) -> QdrantClient:
7373
if self._client:
7474
return self._client
7575
online_store_config = config.online_store
76-
assert isinstance(online_store_config, QdrantOnlineStoreConfig), (
77-
"Invalid type for online store config"
78-
)
76+
assert isinstance(
77+
online_store_config, QdrantOnlineStoreConfig
78+
), "Invalid type for online store config"
7979

8080
assert online_store_config.similarity and (
8181
online_store_config.similarity.lower() in DISTANCE_MAPPING

‎sdk/python/feast/infra/online_stores/sqlite.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -790,12 +790,12 @@ def _get_vector_field(table: FeatureView) -> str:
790790
vector_fields: List[Field] = [
791791
f for f in table.features if getattr(f, "vector_index", None)
792792
]
793-
assert len(vector_fields) > 0, (
794-
f"No vector field found, please update feature view = {table.name} to declare a vector field"
795-
)
796-
assert len(vector_fields) < 2, (
797-
"Only one vector field is supported, please update feature view = {table.name} to declare one vector field"
798-
)
793+
assert (
794+
len(vector_fields) > 0
795+
), f"No vector field found, please update feature view = {table.name} to declare a vector field"
796+
assert (
797+
len(vector_fields) < 2
798+
), "Only one vector field is supported, please update feature view = {table.name} to declare one vector field"
799799
vector_field: str = vector_fields[0].name
800800
return vector_field
801801

‎sdk/python/feast/offline_server.py‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,15 @@ def do_get(self, context: fl.ServerCallContext, ticket: fl.Ticket):
266266
return fl.RecordBatchStream(table)
267267

268268
def _validate_offline_write_batch_parameters(self, command: dict):
269-
assert "feature_view_names" in command, (
270-
"feature_view_names is a mandatory parameter"
271-
)
269+
assert (
270+
"feature_view_names" in command
271+
), "feature_view_names is a mandatory parameter"
272272
assert "name_aliases" in command, "name_aliases is a mandatory parameter"
273273

274274
feature_view_names = command["feature_view_names"]
275-
assert len(feature_view_names) == 1, (
276-
"feature_view_names list should only have one item"
277-
)
275+
assert (
276+
len(feature_view_names) == 1
277+
), "feature_view_names list should only have one item"
278278

279279
name_aliases = command["name_aliases"]
280280
assert len(name_aliases) == 1, "name_aliases list should only have one item"
@@ -316,9 +316,9 @@ def write_logged_features(self, command: dict, key: str):
316316
command["feature_service_name"]
317317
)
318318

319-
assert feature_service.logging_config is not None, (
320-
"feature service must have logging_config set"
321-
)
319+
assert (
320+
feature_service.logging_config is not None
321+
), "feature service must have logging_config set"
322322

323323
assert_permissions(
324324
resource=feature_service,
@@ -335,15 +335,15 @@ def write_logged_features(self, command: dict, key: str):
335335
)
336336

337337
def _validate_pull_all_from_table_or_query_parameters(self, command: dict):
338-
assert "data_source_name" in command, (
339-
"data_source_name is a mandatory parameter"
340-
)
341-
assert "join_key_columns" in command, (
342-
"join_key_columns is a mandatory parameter"
343-
)
344-
assert "feature_name_columns" in command, (
345-
"feature_name_columns is a mandatory parameter"
346-
)
338+
assert (
339+
"data_source_name" in command
340+
), "data_source_name is a mandatory parameter"
341+
assert (
342+
"join_key_columns" in command
343+
), "join_key_columns is a mandatory parameter"
344+
assert (
345+
"feature_name_columns" in command
346+
), "feature_name_columns is a mandatory parameter"
347347
assert "timestamp_field" in command, "timestamp_field is a mandatory parameter"
348348
assert "start_date" in command, "start_date is a mandatory parameter"
349349
assert "end_date" in command, "end_date is a mandatory parameter"
@@ -367,15 +367,15 @@ def pull_all_from_table_or_query(self, command: dict):
367367
)
368368

369369
def _validate_pull_latest_from_table_or_query_parameters(self, command: dict):
370-
assert "data_source_name" in command, (
371-
"data_source_name is a mandatory parameter"
372-
)
373-
assert "join_key_columns" in command, (
374-
"join_key_columns is a mandatory parameter"
375-
)
376-
assert "feature_name_columns" in command, (
377-
"feature_name_columns is a mandatory parameter"
378-
)
370+
assert (
371+
"data_source_name" in command
372+
), "data_source_name is a mandatory parameter"
373+
assert (
374+
"join_key_columns" in command
375+
), "join_key_columns is a mandatory parameter"
376+
assert (
377+
"feature_name_columns" in command
378+
), "feature_name_columns is a mandatory parameter"
379379
assert "timestamp_field" in command, "timestamp_field is a mandatory parameter"
380380
assert "start_date" in command, "start_date is a mandatory parameter"
381381
assert "end_date" in command, "end_date is a mandatory parameter"

‎sdk/python/feast/type_map.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,13 +463,13 @@ def _python_value_to_proto_value(
463463
# Numpy convert 0 to int. However, in the feature view definition, the type of column may be a float.
464464
# So, if value is 0, type validation must pass if scalar_types are either int or float.
465465
allowed_types = {np.int64, int, np.float64, float, decimal.Decimal}
466-
assert type(sample) in allowed_types, (
467-
f"Type `{type(sample)}` not in {allowed_types}"
468-
)
466+
assert (
467+
type(sample) in allowed_types
468+
), f"Type `{type(sample)}` not in {allowed_types}"
469469
else:
470-
assert type(sample) in valid_scalar_types, (
471-
f"Type `{type(sample)}` not in {valid_scalar_types}"
472-
)
470+
assert (
471+
type(sample) in valid_scalar_types
472+
), f"Type `{type(sample)}` not in {valid_scalar_types}"
473473
if feast_value_type == ValueType.BOOL:
474474
# ProtoValue does not support conversion of np.bool_ so we need to convert it to support np.bool_.
475475
return [

‎sdk/python/feast/types.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ def from_feast_to_pyarrow_type(feast_type: FeastType) -> pyarrow.DataType:
224224
Raises:
225225
ValueError: The conversion could not be performed.
226226
"""
227-
assert isinstance(feast_type, (ComplexFeastType, PrimitiveFeastType)), (
228-
f"Expected FeastType, got {type(feast_type)}"
229-
)
227+
assert isinstance(
228+
feast_type, (ComplexFeastType, PrimitiveFeastType)
229+
), f"Expected FeastType, got {type(feast_type)}"
230230
if isinstance(feast_type, PrimitiveFeastType):
231231
if feast_type in FEAST_TYPES_TO_PYARROW_TYPES:
232232
return FEAST_TYPES_TO_PYARROW_TYPES[feast_type]

0 commit comments

Comments
 (0)