Repository navigation
Conversation
BatchFeatureView inherited FeatureView.__eq__, which does not look at the UDF or mode, so two views that differ only in their transformation compared equal. The registries use this equality to reject a version pin that also changes the definition, so pinning a BatchFeatureView to an earlier version together with a new UDF restored the old version and dropped the new UDF without raising FeatureViewPinConflict. Compare the transformation the way _schema_or_udf_changed does, compare the raw protos for views loaded with skip_udf=True, and keep the class hashable. Signed-off-by: Lim-jooyoung <mmporong@gmail.com>
There was a problem hiding this comment.
Devin Review found 2 potential issues.
6 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| return not _transformation_changed( | ||
| self.feature_transformation, | ||
| getattr(other, "feature_transformation", None), | ||
| ) |
There was a problem hiding this comment.
🔴 Repeat apply fails after rollback
After a successful rollback to a different UDF, BatchFeatureView.__eq__ rejects the same pin declaration on the next apply. The pin check compares the declaration with the restored snapshot, not the definition it accepted before the rollback.
Learn more
To roll back a feature view, an operator changes only its version in the repository. The file registry and SQL registry validate that declaration against the active version, then replace the active definition with the older snapshot. They do not retain the declaration they accepted. On the next apply, the declaration is unchanged but the comparison target is now the older snapshot. Before this change, a UDF-only difference did not reject the repeat apply.
Example: Register v0 with UDF A, then v1 with UDF B. Set version="v0" without changing UDF B. The first apply activates A; the second apply of the same repository raises FeatureViewPinConflict.
Recommended fix: Make an exact repeat of an accepted pin a no-op in both registries. Retain the validated pin declaration or its stable fingerprint so the check can distinguish a repeat from a newly edited declaration. Do not bypass the guard solely because the requested version is already active, since that would silently discard new edits. Add a regression that repeats the successful pin and then attempts the same pin with a third UDF.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Reproduced on the file registry and a SQLite SqlRegistry. For a UDF-only rollback this is right: after version="v0" restores v0, applying the same declaration again raises FeatureViewPinConflict, where master accepted it.
The pin check already behaves this way on master for every field it compares. With v0 and v1 differing only in schema (plain FeatureView or BatchFeatureView), the first pin restores v0 and the identical second apply raises FeatureViewPinConflict on both registries:
| v0 -> v1 change | 2nd identical pin, master | 2nd identical pin, this PR | pin with a new edit, master | pin with a new edit, this PR |
|---|---|---|---|---|
| schema | FeatureViewPinConflict |
FeatureViewPinConflict |
FeatureViewPinConflict |
FeatureViewPinConflict |
| UDF only | ok | FeatureViewPinConflict |
ok, new UDF dropped | FeatureViewPinConflict |
The check compares the declaration with the active definition and does not keep the declaration it accepted, so it cannot tell a repeat from a new edit. Now that the UDF is compared, a UDF-only rollback behaves like a schema rollback. Keeping the accepted pin (or a fingerprint of it) would change the pin flow for all feature view types in both registries, so I left it out of this PR. I can open a follow-up for that if you want it.
| return not _transformation_changed( | ||
| self.feature_transformation, | ||
| getattr(other, "feature_transformation", None), | ||
| ) |
There was a problem hiding this comment.
🟡 False pin conflicts for unchanged UDFs
When a UDF has no source text, BatchFeatureView.__eq__ rejects valid pins after the function moves to another line. _udf_changed also treats identical NumPy arrays captured by separately loaded UDFs as a change.
Learn more
The constructor accepts a callable with no source string. Feast serializes that callable and restores it when loading the active view. The new equality check sends these functions through _udf_changed, which compares whole code objects and captured values. Code-object equality includes the first line number. Tuple equality also needs a single truth value for each capture, which a multi-element NumPy array comparison cannot supply. The helper reports a change in either case, so the pin guard rejects the rollback even though its transformation did not change.
Example: Declare a SQL UDF in a factory without udf_string and publish v0 and v1. Add a blank line before the factory while preparing a rollback to v0. The v1 callable and stored callable return the same query, but the shifted first line triggers FeatureViewPinConflict. A Pandas UDF capturing np.array([1, 2]) can hit the same conflict without moving any code, because the stored callable has its own copy of the array.
Recommended fix: Compare executable code and constants without source positions, including for nested code objects. Compare supported array captures and defaults explicitly by shape, dtype, and contents. Keep regression tests for changed constants, defaults, and closures so the pin guard still rejects real edits.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
Confirmed and fixed in 565de02.
For a UDF without udf_string that dill stores by value (closures, lambdas, functions defined in __main__), the pin raised FeatureViewPinConflict when the factory only moved down one line, and when the UDF captured np.array([1, 2]). On master the same comparison already made a plain re-apply store a new version for these UDFs.
_udf_changed now clears the source positions (first line number and line table, nested code included) before comparing code objects, and compares arrays by shape, dtype and contents. A moved, reformatted or array-capturing UDF no longer raises on a pin or stores a new version on re-apply. A changed constant, default, closure value or array still does. A module-level function in an importable module is pickled by reference and was not affected before or after.
Added test_pin_batch_feature_view_compares_udf_without_source (moved, reformatted, moved_and_edited, same_array, edited_array). moved, reformatted and same_array fail without the fix.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7240 +/- ##
==========================================
+ Coverage 54.10% 54.18% +0.07%
==========================================
Files 467 467
Lines 58940 58965 +25
Branches 8688 8694 +6
==========================================
+ Hits 31890 31949 +59
+ Misses 24892 24855 -37
- Partials 2158 2161 +3
... and 4 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
…atureView UDFs BatchFeatureView.__eq__ sends the version pin check through _udf_changed, which compared whole code objects and captured values. For a UDF without udf_string, a function that only moved within its file counted as changed, because the code object holds the first line number and the line table. A UDF that captures a NumPy array counted as changed too: the copy loaded from the registry holds its own array, and == on two arrays has no single truth value. Pinning such a view raised FeatureViewPinConflict although the UDF was unchanged, and a plain re-apply stored a new version. Clear the source positions of the code object and of the code nested in it before comparing, and compare arrays by shape, dtype and contents. Signed-off-by: Lim-jooyoung <mmporong@gmail.com>
franciscojavierarceo
left a comment
There was a problem hiding this comment.
the repeated pin finding still blocks this change. the existing schema limitation does not make it safe to introduce the same failure for UDF-only rollbacks: after the first apply restores v0, an identical second apply now raises FeatureViewPinConflict in both registries. we need to preserve an accepted pin declaration so its exact repeat succeeds while a newly edited UDF is rejected, with regressions for both file and SQL registries.
What this PR does / why we need it:
BatchFeatureViewhas no__eq__of its own, so it inheritsFeatureView.__eq__, which does not look at the UDF,udf_stringor mode. Two batch feature views that differ only in their transformation compare equal.Both registries use this equality when a view is applied with an explicit version that already exists: they compare the user's view against the active one (
user_fv_copy != active_fvininfra/registry/registry.pyandinfra/registry/sql.py) and raiseFeatureViewPinConflictif the definition was also changed. For aBatchFeatureView, pinningversion="v0"together with a new UDF passes that check, restores the v0 snapshot and drops the new UDF without an error. The same pin with a changed schema raisesFeatureViewPinConflicton both registries.This PR adds
BatchFeatureView.__eq__. It callsFeatureView.__eq__and then compares the transformation with_transformation_changed, the helper that_schema_or_udf_changeduses since #7191 (the UDF source text when both views have it, otherwise the code object, defaults and closure). The transformation class follows the mode, so a mode change with the same UDF is also caught. Views loaded withskip_udf=Trueonly hold the transformation proto, so for those the raw protos are compared.__hash__is kept, since defining__eq__alone would make the class unhashable. This is the same kind of fix as #7034 forStreamFeatureView.The second commit makes that helper ignore what is not part of the UDF. For a UDF without
udf_stringthat dill stores by value (closures, lambdas, functions defined in__main__),_udf_changedcompared whole code objects and captured values, so a function that only moved within its file counted as changed (the code object holds the first line number and line table), and so did a UDF that captures a NumPy array (the copy loaded from the registry holds its own array, and==on two arrays has no single truth value). Through the new__eq__such a pin raisedFeatureViewPinConflictfor an unchanged UDF, and on master the same comparison already made a plain re-apply store a new version._udf_changednow clears source positions (nested code included) before comparing code objects and compares arrays by shape, dtype and contents. A changed constant, default, closure value or array is still a change.batch_engineandaggregationsare not compared, becauseto_proto()does not store them and a view would no longer equal its ownfrom_proto(to_proto())round trip.The SQL registry's unchanged-write check in
_apply_objectis not reached for aBatchFeatureView(deserialize_registry_valuesonly matches the exactFeatureViewtype), so SQL registry writes behave as before.Not changed: after a pin restores a snapshot that differs from the declaration, applying the same declaration again raises
FeatureViewPinConflict, because the pin check compares the declaration with the active definition and does not keep the declaration it accepted. Master already does this for a schema rollback on both registries; with the UDF now compared, a UDF-only rollback behaves the same way.Which issue(s) this PR fixes:
No linked issue. This was found by reading the registry pin check after #7034 and #7191.
Checks
git commit -s)Testing Strategy
Python 3.12, offline container with the pinned
py3.12-requirements.txtplus the test, gRPC, BigQuery and AWS extras. pyspark was not installed.test_batch_feature_view_eq_compares_transformationintests/unit/test_feature_views.py(different UDFs,from_proto(to_proto())round trip,skip_udf=Trueviews, hashing) andtest_pin_batch_feature_view_rejects_changed_udfintests/unit/infra/registry/test_file_registry.py(pin plus a new UDF raises; pin with the active definition still restores v0). Withbatch_feature_view.pyrestored to master, both fail (views with different UDFs compare equal;DID NOT RAISE FeatureViewPinConflict). With this PR they pass.test_pin_batch_feature_view_compares_udf_without_sourceintests/unit/infra/registry/test_file_registry.pyfor UDFs withoutudf_string:moved,reformatted(blank line in the body) andsame_arraymust pin without a conflict and be seen as unchanged by_schema_or_udf_changed;moved_and_editedandedited_arraymust still raise. With the first commit only,moved,reformattedandsame_arrayfail; with the second commit all 5 pass.SqlRegistry: pin plus a new UDF gives no error on master andFeatureViewPinConflictwith this PR on both. For UDFs withoutudf_string, a moved factory UDF and one capturingnp.array([1, 2])pin without a conflict and do not create a new version on re-apply;np.array([1, 3])and a changed constant still raise on the pin. A module-level function in an importable module (pickled by reference) behaves the same on master and with this PR.from_proto(to_proto(v)) == vstill holds for pandas and python views and for sql views with and withoutudf_string.disable_feature_view-style re-apply and a state change on aBatchFeatureVieware stored on both registries, as on master.1from1.0and0.0from-0.0.tests/unit/test_feature_views.py,tests/unit/infra/registry/,test_stream_feature_view.py,test_eq_cross_type.py,test_feature_view_versioning.py,test_online_config_apply.py,test_label_view.py,test_materialize_version_forwarding.py,test_feature_view_state.py,test_unit_feature_store.py,local_feast_tests/,diff/andtransformation/: 352 passed, 5 failed with this PR; 345 passed, 5 failed on master. The difference is the 7 tests this PR adds. The 5 failures on both areStreamFeatureViewtests that needSparkTransformation(pyspark), and 2 modules (test_infra_diff.py,test_snowflake_registry.py) are not collected on both because of extras I did not install.tests/integration/registration/test_versioning.py: 43 passed on master and with this PR.ruff checkandruff format --check(0.17.6) on the 3 changed files, andmypy(1.11.2) onfeast/batch_feature_view.py: no issues.Misc
The first checkbox is left open: the full test suite was not run (see the failures above, which also happen on master).