Visitar URL original
feat: Adding Milvus demo to examples by franciscojavierarceo · Pull Request #4910 · feast-dev/feast · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updated linter because of latest nistall
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
  • Loading branch information
franciscojavierarceo committed Jan 29, 2025
commit aa81350424bf10e4a5964662c1f0a347886c313c
9 changes: 4 additions & 5 deletions sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,7 @@ def apply(
views_to_update = [
ob
for ob in objects
if
(
if (
# BFVs are not handled separately from FVs right now.
(isinstance(ob, FeatureView) or isinstance(ob, BatchFeatureView))
and not isinstance(ob, StreamFeatureView)
Expand Down Expand Up @@ -2170,9 +2169,9 @@ def write_logged_features(
if not isinstance(source, FeatureService):
raise ValueError("Only feature service is currently supported as a source")

assert (
source.logging_config is not None
), "Feature service must be configured with logging config in order to use this functionality"
assert source.logging_config is not None, (
"Feature service must be configured with logging config in order to use this functionality"
)

assert isinstance(logs, (pa.Table, Path))

Expand Down
15 changes: 8 additions & 7 deletions sdk/python/feast/infra/materialization/snowflake_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ def __init__(
online_store: OnlineStore,
**kwargs,
):
assert (
repo_config.offline_store.type == "snowflake.offline"
), "To use SnowflakeMaterializationEngine, you must use Snowflake as an offline store."
assert repo_config.offline_store.type == "snowflake.offline", (
"To use SnowflakeMaterializationEngine, you must use Snowflake as an offline store."
)

super().__init__(
repo_config=repo_config,
Expand Down Expand Up @@ -241,10 +241,11 @@ def _materialize_one(
project: str,
tqdm_builder: Callable[[int], tqdm],
):
assert (
isinstance(feature_view, BatchFeatureView)
or isinstance(feature_view, FeatureView)
), "Snowflake can only materialize FeatureView & BatchFeatureView feature view types."
assert isinstance(feature_view, BatchFeatureView) or isinstance(
feature_view, FeatureView
), (
"Snowflake can only materialize FeatureView & BatchFeatureView feature view types."
)

entities = []
for entity_name in feature_view.entities:
Expand Down
4 changes: 1 addition & 3 deletions sdk/python/feast/infra/offline_stores/dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,7 @@ def evaluate_historical_retrieval():
):
# Make sure all event timestamp fields are tz-aware. We default tz-naive fields to UTC
entity_df_with_features[entity_df_event_timestamp_col] = (
entity_df_with_features[
entity_df_event_timestamp_col
].apply(
entity_df_with_features[entity_df_event_timestamp_col].apply(
lambda x: x
if x.tzinfo is not None
else x.replace(tzinfo=timezone.utc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,9 @@ def retrieve_online_documents_v2(
assert all(
field in [f["name"] for f in collection["fields"]]
for field in output_fields
), 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"
), (
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"
)
# Note we choose the first vector field as the field to search on. Not ideal but it's something.
ann_search_field = None
for field in collection["fields"]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def _get_client(self, config: RepoConfig) -> QdrantClient:
if self._client:
return self._client
online_store_config = config.online_store
assert isinstance(
online_store_config, QdrantOnlineStoreConfig
), "Invalid type for online store config"
assert isinstance(online_store_config, QdrantOnlineStoreConfig), (
"Invalid type for online store config"
)

assert online_store_config.similarity and (
online_store_config.similarity.lower() in DISTANCE_MAPPING
Expand Down
12 changes: 6 additions & 6 deletions sdk/python/feast/infra/passthrough_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,9 @@ def write_feature_service_logs(
config: RepoConfig,
registry: BaseRegistry,
):
assert (
feature_service.logging_config is not None
), "Logging should be configured for the feature service before calling this function"
assert feature_service.logging_config is not None, (
"Logging should be configured for the feature service before calling this function"
)

self.offline_store.write_logged_features(
config=config,
Expand All @@ -514,9 +514,9 @@ def retrieve_feature_service_logs(
config: RepoConfig,
registry: BaseRegistry,
) -> RetrievalJob:
assert (
feature_service.logging_config is not None
), "Logging should be configured for the feature service before calling this function"
assert feature_service.logging_config is not None, (
"Logging should be configured for the feature service before calling this function"
)

logging_source = FeatureServiceLoggingSource(feature_service, config.project)
schema = logging_source.get_schema(registry)
Expand Down
54 changes: 27 additions & 27 deletions sdk/python/feast/offline_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,15 +266,15 @@ def do_get(self, context: fl.ServerCallContext, ticket: fl.Ticket):
return fl.RecordBatchStream(table)

def _validate_offline_write_batch_parameters(self, command: dict):
assert (
"feature_view_names" in command
), "feature_view_names is a mandatory parameter"
assert "feature_view_names" in command, (
"feature_view_names is a mandatory parameter"
)
assert "name_aliases" in command, "name_aliases is a mandatory parameter"

feature_view_names = command["feature_view_names"]
assert (
len(feature_view_names) == 1
), "feature_view_names list should only have one item"
assert len(feature_view_names) == 1, (
"feature_view_names list should only have one item"
)

name_aliases = command["name_aliases"]
assert len(name_aliases) == 1, "name_aliases list should only have one item"
Expand Down Expand Up @@ -316,9 +316,9 @@ def write_logged_features(self, command: dict, key: str):
command["feature_service_name"]
)

assert (
feature_service.logging_config is not None
), "feature service must have logging_config set"
assert feature_service.logging_config is not None, (
"feature service must have logging_config set"
)

assert_permissions(
resource=feature_service,
Expand All @@ -335,15 +335,15 @@ def write_logged_features(self, command: dict, key: str):
)

def _validate_pull_all_from_table_or_query_parameters(self, command: dict):
assert (
"data_source_name" in command
), "data_source_name is a mandatory parameter"
assert (
"join_key_columns" in command
), "join_key_columns is a mandatory parameter"
assert (
"feature_name_columns" in command
), "feature_name_columns is a mandatory parameter"
assert "data_source_name" in command, (
"data_source_name is a mandatory parameter"
)
assert "join_key_columns" in command, (
"join_key_columns is a mandatory parameter"
)
assert "feature_name_columns" in command, (
"feature_name_columns is a mandatory parameter"
)
assert "timestamp_field" in command, "timestamp_field is a mandatory parameter"
assert "start_date" in command, "start_date is a mandatory parameter"
assert "end_date" in command, "end_date is a mandatory parameter"
Expand All @@ -364,15 +364,15 @@ def pull_all_from_table_or_query(self, command: dict):
)

def _validate_pull_latest_from_table_or_query_parameters(self, command: dict):
assert (
"data_source_name" in command
), "data_source_name is a mandatory parameter"
assert (
"join_key_columns" in command
), "join_key_columns is a mandatory parameter"
assert (
"feature_name_columns" in command
), "feature_name_columns is a mandatory parameter"
assert "data_source_name" in command, (
"data_source_name is a mandatory parameter"
)
assert "join_key_columns" in command, (
"join_key_columns is a mandatory parameter"
)
assert "feature_name_columns" in command, (
"feature_name_columns is a mandatory parameter"
)
assert "timestamp_field" in command, "timestamp_field is a mandatory parameter"
assert "start_date" in command, "start_date is a mandatory parameter"
assert "end_date" in command, "end_date is a mandatory parameter"
Expand Down
12 changes: 6 additions & 6 deletions sdk/python/feast/type_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,13 @@ def _python_value_to_proto_value(
# Numpy convert 0 to int. However, in the feature view definition, the type of column may be a float.
# So, if value is 0, type validation must pass if scalar_types are either int or float.
allowed_types = {np.int64, int, np.float64, float}
assert (
type(sample) in allowed_types
), f"Type `{type(sample)}` not in {allowed_types}"
assert type(sample) in allowed_types, (
f"Type `{type(sample)}` not in {allowed_types}"
)
else:
assert (
type(sample) in valid_scalar_types
), f"Type `{type(sample)}` not in {valid_scalar_types}"
assert type(sample) in valid_scalar_types, (
f"Type `{type(sample)}` not in {valid_scalar_types}"
)
if feast_value_type == ValueType.BOOL:
# ProtoValue does not support conversion of np.bool_ so we need to convert it to support np.bool_.
return [
Expand Down
6 changes: 3 additions & 3 deletions sdk/python/feast/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ def from_feast_to_pyarrow_type(feast_type: FeastType) -> pyarrow.DataType:
Raises:
ValueError: The conversion could not be performed.
"""
assert isinstance(
feast_type, (ComplexFeastType, PrimitiveFeastType)
), f"Expected FeastType, got {type(feast_type)}"
assert isinstance(feast_type, (ComplexFeastType, PrimitiveFeastType)), (
f"Expected FeastType, got {type(feast_type)}"
)
if isinstance(feast_type, PrimitiveFeastType):
if feast_type in FEAST_TYPES_TO_PYARROW_TYPES:
return FEAST_TYPES_TO_PYARROW_TYPES[feast_type]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ def test_snowflake_materialization_consistency_internal_with_lists(
assert actual_value is not None, f"Response: {response_dict}"
if feature_dtype == "float":
for actual_num, expected_num in zip(actual_value, expected_value):
assert (
abs(actual_num - expected_num) < 1e-6
), f"Response: {response_dict}, Expected: {expected_value}"
assert abs(actual_num - expected_num) < 1e-6, (
f"Response: {response_dict}, Expected: {expected_value}"
)
else:
assert actual_value == expected_value

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ def test_feature_get_online_features_types_match(
if config.feature_is_list:
for feature in online_features["value"]:
assert isinstance(feature, list), "Feature value should be a list"
assert (
config.has_empty_list or len(feature) > 0
), "List of values should not be empty"
assert config.has_empty_list or len(feature) > 0, (
"List of values should not be empty"
)
for element in feature:
assert isinstance(element, expected_dtype)
else:
Expand Down Expand Up @@ -224,7 +224,9 @@ def assert_expected_historical_feature_types(
dtype_checkers = feature_dtype_to_expected_historical_feature_dtype[feature_dtype]
assert any(
check(historical_features_df.dtypes["value"]) for check in dtype_checkers
), f"Failed to match feature type {historical_features_df.dtypes['value']} with checkers {dtype_checkers}"
), (
f"Failed to match feature type {historical_features_df.dtypes['value']} with checkers {dtype_checkers}"
)


def assert_feature_list_types(
Expand Down
6 changes: 3 additions & 3 deletions sdk/python/tests/unit/infra/offline_stores/test_snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ def test_to_remote_storage(retrieval_job):
retrieval_job, "_get_file_names_from_copy_into", return_value=stored_files
) as mock_get_file_names_from_copy,
):
assert (
retrieval_job.to_remote_storage() == stored_files
), "should return the list of files"
assert retrieval_job.to_remote_storage() == stored_files, (
"should return the list of files"
)
mock_to_snowflake.assert_called_once()
mock_get_file_names_from_copy.assert_called_once_with(ANY, ANY)
native_path = mock_get_file_names_from_copy.call_args[0][1]
Expand Down
6 changes: 3 additions & 3 deletions sdk/python/tests/unit/permissions/test_oidc_auth_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ def _assert_auth_requests_session(
"Authorization header is missing in object of class: "
"AuthenticatedRequestsSession "
)
assert (
auth_req_session.headers["Authorization"] == f"Bearer {expected_token}"
), "Authorization token is incorrect"
assert auth_req_session.headers["Authorization"] == f"Bearer {expected_token}", (
"Authorization token is incorrect"
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ def test_is_valid_name():
]

for name, expected in test_cases:
assert (
is_valid_name(name) == expected
), f"Failed for project invalid name: {name}"
assert is_valid_name(name) == expected, (
f"Failed for project invalid name: {name}"
)
6 changes: 3 additions & 3 deletions sdk/python/tests/utils/auth_permissions_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ def start_feature_server(
timeout_msg="Unable to start the Prometheus server in 60 seconds.",
)
else:
assert not check_port_open(
"localhost", 8000
), "Prometheus server is running when it should be disabled."
assert not check_port_open("localhost", 8000), (
"Prometheus server is running when it should be disabled."
)

online_server_url = (
f"https://localhost:{server_port}"
Expand Down
12 changes: 6 additions & 6 deletions sdk/python/tests/utils/cli_repo_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ def local_repo(
stderr = result.stderr.decode("utf-8")
print(f"Apply stdout:\n{stdout}")
print(f"Apply stderr:\n{stderr}")
assert (
result.returncode == 0
), f"stdout: {result.stdout}\nstderr: {result.stderr}"
assert result.returncode == 0, (
f"stdout: {result.stdout}\nstderr: {result.stderr}"
)

yield FeatureStore(repo_path=str(repo_path), config=None)

Expand All @@ -129,6 +129,6 @@ def local_repo(
stderr = result.stderr.decode("utf-8")
print(f"Apply stdout:\n{stdout}")
print(f"Apply stderr:\n{stderr}")
assert (
result.returncode == 0
), f"stdout: {result.stdout}\nstderr: {result.stderr}"
assert result.returncode == 0, (
f"stdout: {result.stdout}\nstderr: {result.stderr}"
)
12 changes: 6 additions & 6 deletions sdk/python/tests/utils/e2e_test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,17 @@ def _check_offline_and_online_features(
if full_feature_names:
if expected_value:
assert response_dict[f"{fv.name}__value"][0], f"Response: {response_dict}"
assert (
abs(response_dict[f"{fv.name}__value"][0] - expected_value) < 1e-6
), f"Response: {response_dict}, Expected: {expected_value}"
assert abs(response_dict[f"{fv.name}__value"][0] - expected_value) < 1e-6, (
f"Response: {response_dict}, Expected: {expected_value}"
)
else:
assert response_dict[f"{fv.name}__value"][0] is None
else:
if expected_value:
assert response_dict["value"][0], f"Response: {response_dict}"
assert (
abs(response_dict["value"][0] - expected_value) < 1e-6
), f"Response: {response_dict}, Expected: {expected_value}"
assert abs(response_dict["value"][0] - expected_value) < 1e-6, (
f"Response: {response_dict}, Expected: {expected_value}"
)
else:
assert response_dict["value"][0] is None

Expand Down