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
Apply Python code formatting for document labeling files
- Format Python files according to ruff standards
- Fix whitespace and import ordering issues
- Ensure compliance with Feast coding standards

Co-Authored-By: Francisco Javier Arceo <arceofrancisco@gmail.com>
Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
  • Loading branch information
commit abf90928db3850919cbe5c1983edf8c6305b7671
15 changes: 8 additions & 7 deletions sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,8 @@ 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 @@ -2032,9 +2033,9 @@ def retrieve_online_documents_v2(
distance_metric: The distance metric to use for retrieval.
query_string: The query string to retrieve the closest document features using keyword search (bm25).
"""
assert query is not None or query_string is not None, (
"Either query or query_string must be provided."
)
assert (
query is not None or query_string is not None
), "Either query or query_string must be provided."

(
available_feature_views,
Expand Down Expand Up @@ -2347,9 +2348,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
6 changes: 3 additions & 3 deletions sdk/python/feast/feature_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ def __init__(
else:
features.append(field)

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

# TODO(felixwang9817): Add more robust validation of features.
cols = [field.name for field in schema]
Expand Down
15 changes: 7 additions & 8 deletions sdk/python/feast/infra/materialization/snowflake_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,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 @@ -243,11 +243,10 @@ 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: 3 additions & 1 deletion sdk/python/feast/infra/offline_stores/dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ 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 @@ -326,9 +326,7 @@ def online_read(
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"
composite_entities = []
for entity_key in entity_keys:
entity_key_str = serialize_entity_key(
Expand Down Expand Up @@ -522,9 +520,7 @@ 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"

# Find the vector search field if we need it
ann_search_field = None
Expand Down
6 changes: 3 additions & 3 deletions sdk/python/feast/infra/online_stores/online_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,9 @@ def retrieve_online_documents_v2(
where the first item is the event timestamp for the row, and the second item is a dict of feature
name to embeddings.
"""
assert embedding is not None or query_string is not None, (
"Either embedding or query_string must be specified"
)
assert (
embedding is not None or query_string is not None
), "Either embedding or query_string must be specified"
raise NotImplementedError(
f"Online store {self.__class__.__name__} does not support online retrieval"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,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/online_stores/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,12 +790,12 @@ def _get_vector_field(table: FeatureView) -> str:
vector_fields: List[Field] = [
f for f in table.features if getattr(f, "vector_index", None)
]
assert len(vector_fields) > 0, (
f"No vector field found, please update feature view = {table.name} to declare a vector field"
)
assert len(vector_fields) < 2, (
"Only one vector field is supported, please update feature view = {table.name} to declare one vector field"
)
assert (
len(vector_fields) > 0
), f"No vector field found, please update feature view = {table.name} to declare a vector field"
assert (
len(vector_fields) < 2
), "Only one vector field is supported, please update feature view = {table.name} to declare one vector field"
vector_field: str = vector_fields[0].name
return vector_field

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 @@ -496,9 +496,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 @@ -516,9 +516,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 @@ -366,15 +366,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
6 changes: 3 additions & 3 deletions sdk/python/feast/type_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,9 @@ def _python_value_to_proto_value(
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 @@ -224,9 +224,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
Empty file.
Empty file.
Empty file.
Empty file.
16 changes: 16 additions & 0 deletions ui/src/custom-tabs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@ interface DatasetCustomTabRegistrationInterface
}: DatasetCustomTabProps) => JSX.Element;
}

// Type for Document Labeling Custom Tabs
interface DocumentLabelingCustomTabProps {
id: string | undefined;
feastObjectQuery: RegularFeatureViewQueryReturnType;
}
interface DocumentLabelingCustomTabRegistrationInterface
extends CustomTabRegistrationInterface {
Component: ({
id,
feastObjectQuery,
...args
}: DocumentLabelingCustomTabProps) => JSX.Element;
}

export type {
CustomTabRegistrationInterface,
RegularFeatureViewQueryReturnType,
Expand All @@ -157,4 +171,6 @@ export type {
FeatureCustomTabProps,
DatasetCustomTabRegistrationInterface,
DatasetCustomTabProps,
DocumentLabelingCustomTabRegistrationInterface,
DocumentLabelingCustomTabProps,
};
Empty file.
Empty file.