Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pydantic model compatibility #1

Merged
merged 32 commits into from
Jul 6, 2023
Merged

Conversation

expediamatt
Copy link

[All tests and lint checks are passing.]

What this PR does / why we need it:
This PR introduces Pydantic model conversions for Entity, DataSource, and FeatureView, so that they may be transmitted over the wire using FastAPI. This allows a Feast project to be broken up into a local SDK and a remote registry service.

Only RequestSource and SparkSource are supported for now. We plan to add support for FeatureService models in the near future.

William Parsley and others added 24 commits June 23, 2023 14:17
…rtial work for FeatureService pydantic model, and add unit tests for pydantic models.
…, fix FeatureView to not desroy some of its arguments
… on DataSource and Entity, so use those converters in the FeatureView converter. Also, fix a small SparkSource error which imports FeatureView into the SparkSource DataSource definition, breaking the hierarchy of FeatureService to FeatureView to DataSource and Entity, causing circular dependencies
Copy link
Collaborator

@EXPEbdodla EXPEbdodla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Moving pydantic models to expediagroup.models package
  2. conversion from pydantic model to feast and vice versa can be moved to pydantic models class so we will not be touching feast code.

.github/workflows/publish.yml Outdated Show resolved Hide resolved
sdk/python/feast/entity.py Outdated Show resolved Hide resolved
sdk/python/feast/feature_store.py Outdated Show resolved Hide resolved
sdk/python/feast/feature_service.py Outdated Show resolved Hide resolved
sdk/python/feast/base_feature_view.py Outdated Show resolved Hide resolved
sdk/python/feast/embedded_go/type_map.py Outdated Show resolved Hide resolved
@@ -78,7 +78,7 @@ babel==2.12.1
# via sphinx
backcall==0.2.0
# via ipython
backports-zoneinfo==0.2.1
backports-zoneinfo==0.2.1;python_version<"3.9"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed? I'm assuming these requirement files are auto generated.

Copy link
Author

@expediamatt expediamatt Jul 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a necessary change to get the py3.8 version of Feast to build.

I added this comment to the Feast dev guide:
feast-dev#2105 (comment)

backports-zoneinfo is only present in the 3.8 requirements, but this package fails with Python 3.9 or higher. Without this requirement, the makefile may choose to attempt to pull a 3.9 version, and fail to build.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at the ci-requirements.txt for py 3.9 and 3.10, you will not find that dependency. To install feast, we need to use make install-python-ci-dependencies

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It did not build for me when I removed the dependency. I'm not sure what it's covering though. I tend not to like removing items with being sure why I'm removing them.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makefile has a problem in getting your current version..PYTHON variable is not defined. Can you define the following variable in PYTHON:=$(shellpython-c'importsys;print(str(sys.version_info[0])+"."+str(sys.version_info[1]))') and run make install-python-ci-dependencies to try out

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it works for 3.10, which is what I have, but it didn't work for 3.8 until I fixed the above.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll verify and update it if necessary. Thank you.

@@ -134,6 +134,13 @@ def __init__(
self.name = name
self.entities = [e.name for e in entities] if entities else [DUMMY_ENTITY_NAME]
self.ttl = ttl

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does copy method solves your problem?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked into the code. I see they are not constructing Entity object. But we can actually use name to get Entity object. So no change to Feast code.
Please let me know if you see any issues with it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if you look at line 135, they actually overwrite entities with just the names of entities. We need to preserve the actual entities to convert back and forth. Either way this requires a change to feast code. It seems less destructive to make a new property, hence original_entities.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also use original_schema to avoid confusion with the @Property schema defined on line 277.

sdk/python/feast/feature_view.py Show resolved Hide resolved
@@ -134,6 +134,13 @@ def __init__(
self.name = name
self.entities = [e.name for e in entities] if entities else [DUMMY_ENTITY_NAME]
self.ttl = ttl

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked into the code. I see they are not constructing Entity object. But we can actually use name to get Entity object. So no change to Feast code.
Please let me know if you see any issues with it.

@expediamatt
Copy link
Author

  1. Moving pydantic models to expediagroup.models package
  2. conversion from pydantic model to feast and vice versa can be moved to pydantic models class so we will not be touching feast code.

Fixed!

@EXPEbdodla
Copy link
Collaborator

Please use Squash and Merge

@expediamatt expediamatt merged commit a8524a6 into master Jul 6, 2023
@expediamatt expediamatt deleted the pydantic-model-compatibility branch July 6, 2023 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants