Skip to content

Commit 0082406

Browse files
author
Zach Barnett
committed
fix: format python
1 parent ca9cfe5 commit 0082406

4 files changed

Lines changed: 70 additions & 53 deletions

File tree

sdk/python/feast/expediagroup/search.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,20 @@
77
from feast.project import Project
88
from feast.protos.feast.registry.RegistryServer_pb2 import (
99
ExpediaProjectAndRelatedFeatureViews as ExpediaProjectAndRelatedFeatureViewsProto,
10+
)
11+
from feast.protos.feast.registry.RegistryServer_pb2 import (
1012
ExpediaSearchFeatureViewsRequest as ExpediaSearchFeatureViewsRequestProto,
13+
)
14+
from feast.protos.feast.registry.RegistryServer_pb2 import (
1115
ExpediaSearchFeatureViewsResponse as ExpediaSearchFeatureViewsResponseProto,
16+
)
17+
from feast.protos.feast.registry.RegistryServer_pb2 import (
1218
ExpediaSearchProjectsRequest as ExpediaSearchProjectsRequestProto,
13-
ExpediaSearchProjectsResponse as ExpediaSearchProjectsResponseProto
1419
)
20+
from feast.protos.feast.registry.RegistryServer_pb2 import (
21+
ExpediaSearchProjectsResponse as ExpediaSearchProjectsResponseProto,
22+
)
23+
1524

1625
class ExpediaProjectAndRelatedFeatureViews:
1726
"""

sdk/python/feast/infra/registry/sql.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,7 @@ def expedia_search_feature_views(
15711571
with self.read_engine.begin() as conn:
15721572
if not in_memory_filtering_required:
15731573
stmt = select(feature_views).order_by(feature_views.c.feature_view_name)
1574-
1574+
15751575
if search_text: # Only add search filter if search_text is not empty
15761576
stmt = stmt.where(
15771577
feature_views.c.feature_view_name.like(
@@ -1582,7 +1582,9 @@ def expedia_search_feature_views(
15821582
stmt = stmt.limit(page_size).offset(offset)
15831583

15841584
if search_text:
1585-
rows = conn.execute(stmt, {"search_pattern": f"%{search_text}%"}).all()
1585+
rows = conn.execute(
1586+
stmt, {"search_pattern": f"%{search_text}%"}
1587+
).all()
15861588
else:
15871589
rows = conn.execute(stmt).all()
15881590

sdk/python/feast/registry_server.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from google.protobuf.empty_pb2 import Empty
88
from grpc_health.v1 import health, health_pb2, health_pb2_grpc
99
from grpc_reflection.v1alpha import reflection
10+
from sdk.python.feast.infra.registry.sql import SqlRegistry
11+
from sdk.python.feast.infra.registry.sql_fallback import SqlFallbackRegistry
1012

1113
from feast import FeatureService, FeatureStore
1214
from feast.base_feature_view import BaseFeatureView
@@ -44,9 +46,6 @@
4446
from feast.sorted_feature_view import SortedFeatureView
4547
from feast.stream_feature_view import StreamFeatureView
4648

47-
from sdk.python.feast.infra.registry.sql import SqlRegistry
48-
from sdk.python.feast.infra.registry.sql_fallback import SqlFallbackRegistry
49-
5049
_logger = logging.getLogger(__name__)
5150
_logger.setLevel(logging.INFO)
5251

@@ -811,7 +810,10 @@ def Proto(self, request, context):
811810
def ExpediaSearchProjects(
812811
self, request: RegistryServer_pb2.ExpediaSearchProjectsRequest, context
813812
):
814-
if not (isinstance(self.proxied_registry, SqlRegistry) or isinstance(self.proxied_registry, SqlFallbackRegistry)):
813+
if not (
814+
isinstance(self.proxied_registry, SqlRegistry)
815+
or isinstance(self.proxied_registry, SqlFallbackRegistry)
816+
):
815817
raise TypeError("Registry must be SqlRegistry or SqlFallbackRegistry")
816818

817819
# Using `type: ignore[attr-defined]` because this should only be implemented in sql registry.

sdk/python/tests/integration/registration/test_universal_registry.py

Lines changed: 50 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,22 +2037,22 @@ def test_registry_cache_expiration(test_registry):
20372037
)
20382038
def test_expedia_search_projects_success(test_registry):
20392039
from feast.expediagroup.search import ExpediaSearchProjectsRequest
2040-
2040+
20412041
# Create projects with different attributes
20422042
project1 = Project(
20432043
name="test_project_1",
20442044
description="Test project 1",
20452045
tags={"team": "team1", "application": "app1"},
20462046
owner="owner1@example.com",
20472047
)
2048-
2048+
20492049
project2 = Project(
2050-
name="search_project_2",
2050+
name="search_project_2",
20512051
description="Search project 2",
20522052
tags={"team": "team2", "application": "app2"},
20532053
owner="owner2@example.com",
20542054
)
2055-
2055+
20562056
project3 = Project(
20572057
name="another_project",
20582058
description="Another project",
@@ -2062,9 +2062,9 @@ def test_expedia_search_projects_success(test_registry):
20622062

20632063
# Apply projects
20642064
test_registry.apply_project(project1)
2065-
test_registry.apply_project(project2)
2065+
test_registry.apply_project(project2)
20662066
test_registry.apply_project(project3)
2067-
2067+
20682068
# Create feature views for projects
20692069
batch_source = FileSource(
20702070
name="test_source",
@@ -2073,25 +2073,25 @@ def test_expedia_search_projects_success(test_registry):
20732073
timestamp_field="ts_col",
20742074
created_timestamp_column="timestamp",
20752075
)
2076-
2076+
20772077
entity = Entity(name="test_entity", join_keys=["test"])
2078-
2078+
20792079
fv1 = FeatureView(
20802080
name="feature_view_1",
20812081
schema=[Field(name="test", dtype=Int64), Field(name="feature1", dtype=String)],
20822082
entities=[entity],
20832083
source=batch_source,
20842084
ttl=timedelta(minutes=5),
20852085
)
2086-
2086+
20872087
fv2 = FeatureView(
2088-
name="feature_view_2",
2088+
name="feature_view_2",
20892089
schema=[Field(name="test", dtype=Int64), Field(name="feature2", dtype=String)],
20902090
entities=[entity],
20912091
source=batch_source,
20922092
ttl=timedelta(minutes=5),
20932093
)
2094-
2094+
20952095
test_registry.apply_feature_view(fv1, project1.name)
20962096
test_registry.apply_feature_view(fv2, project2.name)
20972097

@@ -2103,29 +2103,33 @@ def test_expedia_search_projects_success(test_registry):
21032103
page_index=0,
21042104
)
21052105
response = test_registry.expedia_search_projects(request)
2106-
2106+
21072107
assert response.total_projects >= 3
21082108
assert len(response.projects_and_related_feature_views) >= 3
2109-
2109+
21102110
# Find our projects in the response
2111-
project_names = [p.project.name for p in response.projects_and_related_feature_views]
2111+
project_names = [
2112+
p.project.name for p in response.projects_and_related_feature_views
2113+
]
21122114
assert project1.name in project_names
21132115
assert project2.name in project_names
21142116
assert project3.name in project_names
2115-
2117+
21162118
# Test search with text filter
21172119
request = ExpediaSearchProjectsRequest(
21182120
search_text="test",
2119-
updated_at=None,
2121+
updated_at=None,
21202122
page_size=10,
21212123
page_index=0,
21222124
)
21232125
response = test_registry.expedia_search_projects(request)
2124-
2125-
project_names = [p.project.name for p in response.projects_and_related_feature_views]
2126+
2127+
project_names = [
2128+
p.project.name for p in response.projects_and_related_feature_views
2129+
]
21262130
assert project1.name in project_names
21272131
# Note: project2 and project3 may not contain "test" in their project_id
2128-
2132+
21292133
# Test pagination
21302134
request = ExpediaSearchProjectsRequest(
21312135
search_text="",
@@ -2134,10 +2138,10 @@ def test_expedia_search_projects_success(test_registry):
21342138
page_index=0,
21352139
)
21362140
response = test_registry.expedia_search_projects(request)
2137-
2141+
21382142
assert len(response.projects_and_related_feature_views) == 1
21392143
assert response.total_page_indices >= 3
2140-
2144+
21412145
# Test that feature views are included
21422146
for project_and_fvs in response.projects_and_related_feature_views:
21432147
if project_and_fvs.project.name == project1.name:
@@ -2159,11 +2163,11 @@ def test_expedia_search_projects_success(test_registry):
21592163
)
21602164
def test_expedia_search_feature_views_success(test_registry):
21612165
from feast.expediagroup.search import ExpediaSearchFeatureViewsRequest
2162-
2166+
21632167
# Create project
21642168
project = Project(name="test_project", description="Test project")
21652169
test_registry.apply_project(project)
2166-
2170+
21672171
# Create data sources
21682172
batch_source1 = FileSource(
21692173
name="source1",
@@ -2172,17 +2176,17 @@ def test_expedia_search_feature_views_success(test_registry):
21722176
timestamp_field="ts_col",
21732177
created_timestamp_column="timestamp",
21742178
)
2175-
2179+
21762180
batch_source2 = FileSource(
2177-
name="source2",
2181+
name="source2",
21782182
file_format=ParquetFormat(),
21792183
path="file://feast/source2/*",
21802184
timestamp_field="ts_col",
21812185
created_timestamp_column="timestamp",
21822186
)
2183-
2187+
21842188
entity = Entity(name="test_entity", join_keys=["test"])
2185-
2189+
21862190
# Create feature views with different attributes
21872191
fv1 = FeatureView(
21882192
name="search_feature_view_1",
@@ -2193,17 +2197,17 @@ def test_expedia_search_feature_views_success(test_registry):
21932197
online=True,
21942198
tags={"team": "team1", "application": "app1"},
21952199
)
2196-
2200+
21972201
fv2 = FeatureView(
21982202
name="test_feature_view_2",
21992203
schema=[Field(name="test", dtype=Int64), Field(name="feature2", dtype=String)],
2200-
entities=[entity],
2204+
entities=[entity],
22012205
source=batch_source2,
22022206
ttl=timedelta(minutes=5),
22032207
online=False,
22042208
tags={"team": "team2", "application": "app2"},
22052209
)
2206-
2210+
22072211
fv3 = FeatureView(
22082212
name="another_view",
22092213
schema=[Field(name="test", dtype=Int64), Field(name="feature3", dtype=String)],
@@ -2213,11 +2217,11 @@ def test_expedia_search_feature_views_success(test_registry):
22132217
online=True,
22142218
tags={"team": "team1", "application": "app3"},
22152219
)
2216-
2220+
22172221
test_registry.apply_feature_view(fv1, project.name)
22182222
test_registry.apply_feature_view(fv2, project.name)
22192223
test_registry.apply_feature_view(fv3, project.name)
2220-
2224+
22212225
# Test search without filters
22222226
request = ExpediaSearchFeatureViewsRequest(
22232227
search_text="",
@@ -2230,15 +2234,15 @@ def test_expedia_search_feature_views_success(test_registry):
22302234
page_index=0,
22312235
)
22322236
response = test_registry.expedia_search_feature_views(request)
2233-
2237+
22342238
assert response.total_feature_views >= 3
22352239
assert len(response.feature_views) >= 3
2236-
2240+
22372241
fv_names = [fv.name for fv in response.feature_views]
22382242
assert fv1.name in fv_names
22392243
assert fv2.name in fv_names
22402244
assert fv3.name in fv_names
2241-
2245+
22422246
# Test search with text filter
22432247
request = ExpediaSearchFeatureViewsRequest(
22442248
search_text="search",
@@ -2251,11 +2255,11 @@ def test_expedia_search_feature_views_success(test_registry):
22512255
page_index=0,
22522256
)
22532257
response = test_registry.expedia_search_feature_views(request)
2254-
2258+
22552259
fv_names = [fv.name for fv in response.feature_views]
22562260
assert fv1.name in fv_names # contains "search"
22572261
# Note: fv2 and fv3 may not contain "search" based on search implementation
2258-
2262+
22592263
# Test filter by online status
22602264
request = ExpediaSearchFeatureViewsRequest(
22612265
search_text="",
@@ -2268,12 +2272,12 @@ def test_expedia_search_feature_views_success(test_registry):
22682272
page_index=0,
22692273
)
22702274
response = test_registry.expedia_search_feature_views(request)
2271-
2275+
22722276
fv_names = [fv.name for fv in response.feature_views]
22732277
assert fv1.name in fv_names # online=True
22742278
assert fv2.name not in fv_names # online=False
22752279
assert fv3.name in fv_names # online=True
2276-
2280+
22772281
# Test filter by team
22782282
request = ExpediaSearchFeatureViewsRequest(
22792283
search_text="",
@@ -2286,12 +2290,12 @@ def test_expedia_search_feature_views_success(test_registry):
22862290
page_index=0,
22872291
)
22882292
response = test_registry.expedia_search_feature_views(request)
2289-
2293+
22902294
fv_names = [fv.name for fv in response.feature_views]
22912295
assert fv1.name in fv_names # team=team1
22922296
assert fv2.name not in fv_names # team=team2
22932297
assert fv3.name in fv_names # team=team1
2294-
2298+
22952299
# Test filter by application
22962300
request = ExpediaSearchFeatureViewsRequest(
22972301
search_text="",
@@ -2304,12 +2308,12 @@ def test_expedia_search_feature_views_success(test_registry):
23042308
page_index=0,
23052309
)
23062310
response = test_registry.expedia_search_feature_views(request)
2307-
2311+
23082312
fv_names = [fv.name for fv in response.feature_views]
23092313
assert fv1.name in fv_names # application=app1
23102314
assert fv2.name not in fv_names # application=app2
23112315
assert fv3.name not in fv_names # application=app3
2312-
2316+
23132317
# Test pagination
23142318
request = ExpediaSearchFeatureViewsRequest(
23152319
search_text="",
@@ -2322,10 +2326,10 @@ def test_expedia_search_feature_views_success(test_registry):
23222326
page_index=0,
23232327
)
23242328
response = test_registry.expedia_search_feature_views(request)
2325-
2329+
23262330
assert len(response.feature_views) == 1
23272331
assert response.total_page_indices >= 3
2328-
2332+
23292333
# Test combined filters
23302334
request = ExpediaSearchFeatureViewsRequest(
23312335
search_text="",
@@ -2338,7 +2342,7 @@ def test_expedia_search_feature_views_success(test_registry):
23382342
page_index=0,
23392343
)
23402344
response = test_registry.expedia_search_feature_views(request)
2341-
2345+
23422346
fv_names = [fv.name for fv in response.feature_views]
23432347
assert fv1.name in fv_names # online=True and team=team1
23442348
assert fv2.name not in fv_names # online=False

0 commit comments

Comments
 (0)