Skip to content

Commit

Permalink
reformatted the file to resolve lint error.
Browse files Browse the repository at this point in the history
Signed-off-by: Lokesh Rangineni <lokeshforjava@gmail.com>
  • Loading branch information
lokeshrangineni committed Apr 25, 2024
1 parent 06d59bc commit d74cc3e
Showing 1 changed file with 65 additions and 62 deletions.
127 changes: 65 additions & 62 deletions sdk/python/tests/unit/test_sql_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ def mysql_registry():

# testing for the database to exist and ready to connect and start testing.
import sqlalchemy
engine = sqlalchemy.create_engine(container.get_connection_url(), pool_pre_ping=True)

engine = sqlalchemy.create_engine(
container.get_connection_url(), pool_pre_ping=True
)
engine.connect()

registry_config = RegistryConfig(
Expand Down Expand Up @@ -144,19 +147,19 @@ def test_apply_entity_success(sql_registry):

entity = entities[0]
assert (
len(entities) == 1
and entity.name == "driver_car_id"
and entity.description == "Car driver id"
and "team" in entity.tags
and entity.tags["team"] == "matchmaking"
len(entities) == 1
and entity.name == "driver_car_id"
and entity.description == "Car driver id"
and "team" in entity.tags
and entity.tags["team"] == "matchmaking"
)

entity = sql_registry.get_entity("driver_car_id", project)
assert (
entity.name == "driver_car_id"
and entity.description == "Car driver id"
and "team" in entity.tags
and entity.tags["team"] == "matchmaking"
entity.name == "driver_car_id"
and entity.description == "Car driver id"
and "team" in entity.tags
and entity.tags["team"] == "matchmaking"
)

# After the first apply, the created_timestamp should be the same as the last_update_timestamp.
Expand Down Expand Up @@ -224,31 +227,31 @@ def test_apply_feature_view_success(sql_registry):

# List Feature Views
assert (
len(feature_views) == 1
and feature_views[0].name == "my_feature_view_1"
and feature_views[0].features[0].name == "fs1_my_feature_1"
and feature_views[0].features[0].dtype == Int64
and feature_views[0].features[1].name == "fs1_my_feature_2"
and feature_views[0].features[1].dtype == String
and feature_views[0].features[2].name == "fs1_my_feature_3"
and feature_views[0].features[2].dtype == Array(String)
and feature_views[0].features[3].name == "fs1_my_feature_4"
and feature_views[0].features[3].dtype == Array(Bytes)
and feature_views[0].entities[0] == "fs1_my_entity_1"
len(feature_views) == 1
and feature_views[0].name == "my_feature_view_1"
and feature_views[0].features[0].name == "fs1_my_feature_1"
and feature_views[0].features[0].dtype == Int64
and feature_views[0].features[1].name == "fs1_my_feature_2"
and feature_views[0].features[1].dtype == String
and feature_views[0].features[2].name == "fs1_my_feature_3"
and feature_views[0].features[2].dtype == Array(String)
and feature_views[0].features[3].name == "fs1_my_feature_4"
and feature_views[0].features[3].dtype == Array(Bytes)
and feature_views[0].entities[0] == "fs1_my_entity_1"
)

feature_view = sql_registry.get_feature_view("my_feature_view_1", project)
assert (
feature_view.name == "my_feature_view_1"
and feature_view.features[0].name == "fs1_my_feature_1"
and feature_view.features[0].dtype == Int64
and feature_view.features[1].name == "fs1_my_feature_2"
and feature_view.features[1].dtype == String
and feature_view.features[2].name == "fs1_my_feature_3"
and feature_view.features[2].dtype == Array(String)
and feature_view.features[3].name == "fs1_my_feature_4"
and feature_view.features[3].dtype == Array(Bytes)
and feature_view.entities[0] == "fs1_my_entity_1"
feature_view.name == "my_feature_view_1"
and feature_view.features[0].name == "fs1_my_feature_1"
and feature_view.features[0].dtype == Int64
and feature_view.features[1].name == "fs1_my_feature_2"
and feature_view.features[1].dtype == String
and feature_view.features[2].name == "fs1_my_feature_3"
and feature_view.features[2].dtype == Array(String)
and feature_view.features[3].name == "fs1_my_feature_4"
and feature_view.features[3].dtype == Array(Bytes)
and feature_view.entities[0] == "fs1_my_entity_1"
)
assert feature_view.ttl == timedelta(minutes=5)

Expand Down Expand Up @@ -338,19 +341,19 @@ def location_features_from_push(inputs: pd.DataFrame) -> pd.DataFrame:

# List Feature Views
assert (
len(feature_views) == 1
and feature_views[0].name == "location_features_from_push"
and feature_views[0].features[0].name == "first_char"
and feature_views[0].features[0].dtype == String
len(feature_views) == 1
and feature_views[0].name == "location_features_from_push"
and feature_views[0].features[0].name == "first_char"
and feature_views[0].features[0].dtype == String
)

feature_view = sql_registry.get_on_demand_feature_view(
"location_features_from_push", project
)
assert (
feature_view.name == "location_features_from_push"
and feature_view.features[0].name == "first_char"
and feature_view.features[0].dtype == String
feature_view.name == "location_features_from_push"
and feature_view.features[0].name == "first_char"
and feature_view.features[0].dtype == String
)

sql_registry.delete_feature_view("location_features_from_push", project)
Expand Down Expand Up @@ -440,51 +443,51 @@ def odfv1(feature_df: pd.DataFrame) -> pd.DataFrame:
on_demand_feature_views = sql_registry.list_on_demand_feature_views(project)

assert (
len(on_demand_feature_views) == 1
and on_demand_feature_views[0].name == "odfv1"
and on_demand_feature_views[0].features[0].name == "odfv1_my_feature_1"
and on_demand_feature_views[0].features[0].dtype == Float32
and on_demand_feature_views[0].features[1].name == "odfv1_my_feature_2"
and on_demand_feature_views[0].features[1].dtype == Int32
len(on_demand_feature_views) == 1
and on_demand_feature_views[0].name == "odfv1"
and on_demand_feature_views[0].features[0].name == "odfv1_my_feature_1"
and on_demand_feature_views[0].features[0].dtype == Float32
and on_demand_feature_views[0].features[1].name == "odfv1_my_feature_2"
and on_demand_feature_views[0].features[1].dtype == Int32
)
request_schema = on_demand_feature_views[0].get_request_data_schema()
assert (
list(request_schema.keys())[0] == "my_input_1"
and list(request_schema.values())[0] == ValueType.INT32
list(request_schema.keys())[0] == "my_input_1"
and list(request_schema.values())[0] == ValueType.INT32
)

feature_view = sql_registry.get_on_demand_feature_view("odfv1", project)
assert (
feature_view.name == "odfv1"
and feature_view.features[0].name == "odfv1_my_feature_1"
and feature_view.features[0].dtype == Float32
and feature_view.features[1].name == "odfv1_my_feature_2"
and feature_view.features[1].dtype == Int32
feature_view.name == "odfv1"
and feature_view.features[0].name == "odfv1_my_feature_1"
and feature_view.features[0].dtype == Float32
and feature_view.features[1].name == "odfv1_my_feature_2"
and feature_view.features[1].dtype == Int32
)
request_schema = feature_view.get_request_data_schema()
assert (
list(request_schema.keys())[0] == "my_input_1"
and list(request_schema.values())[0] == ValueType.INT32
list(request_schema.keys())[0] == "my_input_1"
and list(request_schema.values())[0] == ValueType.INT32
)

# Make sure fv1 is untouched
feature_views = sql_registry.list_feature_views(project)

# List Feature Views
assert (
len(feature_views) == 1
and feature_views[0].name == "my_feature_view_1"
and feature_views[0].features[0].name == "fs1_my_feature_1"
and feature_views[0].features[0].dtype == Int64
and feature_views[0].entities[0] == "fs1_my_entity_1"
len(feature_views) == 1
and feature_views[0].name == "my_feature_view_1"
and feature_views[0].features[0].name == "fs1_my_feature_1"
and feature_views[0].features[0].dtype == Int64
and feature_views[0].entities[0] == "fs1_my_entity_1"
)

feature_view = sql_registry.get_feature_view("my_feature_view_1", project)
assert (
feature_view.name == "my_feature_view_1"
and feature_view.features[0].name == "fs1_my_feature_1"
and feature_view.features[0].dtype == Int64
and feature_view.entities[0] == "fs1_my_entity_1"
feature_view.name == "my_feature_view_1"
and feature_view.features[0].name == "fs1_my_feature_1"
and feature_view.features[0].dtype == Int64
and feature_view.entities[0] == "fs1_my_entity_1"
)

sql_registry.teardown()
Expand Down

0 comments on commit d74cc3e

Please sign in to comment.