MCPcopy Index your code
hub / github.com/feast-dev/feast / test_diff_odfv

Function test_diff_odfv

sdk/python/tests/unit/diff/test_registry_diff.py:103–152  ·  view source on GitHub ↗
(simple_dataset_1)

Source from the content-addressed store, hash-verified

101
102
103def test_diff_odfv(simple_dataset_1):
104 with prep_file_source(df=simple_dataset_1, timestamp_field="ts_1") as file_source:
105 entity = Entity(name="id", join_keys=["id"])
106 fv = FeatureView(
107 name="fv2",
108 entities=[entity],
109 source=file_source,
110 tags={"when": "before"},
111 )
112
113 @on_demand_feature_view(
114 sources=[fv],
115 schema=[Field(name="first_char", dtype=String)],
116 )
117 def pre_changed(inputs: pd.DataFrame) -> pd.DataFrame:
118 df = pd.DataFrame()
119 df["first_char"] = inputs["string_col"].str[:1].astype("string")
120 return df
121
122 @on_demand_feature_view(
123 sources=[fv],
124 schema=[Field(name="first_char", dtype=String)],
125 )
126 def post_changed(inputs: pd.DataFrame) -> pd.DataFrame:
127 df = pd.DataFrame()
128 df["first_char"] = inputs["string_col"].str[:1].astype("string") + "hi"
129 return df
130
131 feast_object_diffs = diff_registry_objects(
132 pre_changed, pre_changed, "on demand feature view"
133 )
134 assert len(feast_object_diffs.feast_object_property_diffs) == 0
135
136 feast_object_diffs = diff_registry_objects(
137 pre_changed, post_changed, "on demand feature view"
138 )
139
140 # Note that user_defined_function.body is excluded because it always changes (dill is non-deterministic), even
141 # if no code is changed
142 assert len(feast_object_diffs.feast_object_property_diffs) == 3
143 assert feast_object_diffs.feast_object_property_diffs[0].property_name == "name"
144 # Note we should only now be looking at changes for the feature_transformation field
145 assert (
146 feast_object_diffs.feast_object_property_diffs[1].property_name
147 == "feature_transformation.name"
148 )
149 assert (
150 feast_object_diffs.feast_object_property_diffs[2].property_name
151 == "feature_transformation.body_text"
152 )
153
154
155def test_diff_registry_objects_batch_to_push_source(simple_dataset_1):

Callers

nothing calls this directly

Calls 4

prep_file_sourceFunction · 0.90
EntityClass · 0.90
FeatureViewClass · 0.90
diff_registry_objectsFunction · 0.90

Tested by

no test coverage detected