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

fix: Populates project created_time correctly according to created time in feast_metadata table #149

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions sdk/python/feast/infra/registry/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,15 +284,17 @@ def __init__(
)

def _sync_feast_metadata_to_projects_table(self):
feast_metadata_projects: set = []
feast_metadata_projects: dict = {}
projects_set: set = []
with self.read_engine.begin() as conn:
stmt = select(feast_metadata).where(
feast_metadata.c.metadata_key == FeastMetadataKeys.PROJECT_UUID.value
)
rows = conn.execute(stmt).all()
for row in rows:
feast_metadata_projects.append(row._mapping["project_id"])
feast_metadata_projects[row._mapping["project_id"]] = int(
row._mapping["last_updated_timestamp"]
)
Comment on lines -295 to +297
Copy link

Choose a reason for hiding this comment

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

Can you explain what this is doing? I don't really follow

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Feast is deprecating feast_metadata table in the favor of projects. We are doing a sync of projects from feast_metadata to projects table. Earlier we are creating projects but missing the create timestamp from feast_metadata to projects. It creates inconsistencies in registry. This fix avoids that inconsistency.


if len(feast_metadata_projects) > 0:
with self.read_engine.begin() as conn:
Expand All @@ -302,9 +304,17 @@ def _sync_feast_metadata_to_projects_table(self):
projects_set.append(row._mapping["project_id"])

# Find object in feast_metadata_projects but not in projects
projects_to_sync = set(feast_metadata_projects) - set(projects_set)
projects_to_sync = set(feast_metadata_projects.keys()) - set(projects_set)
for project_name in projects_to_sync:
self.apply_project(Project(name=project_name), commit=True)
self.apply_project(
Project(
name=project_name,
created_timestamp=datetime.fromtimestamp(
feast_metadata_projects[project_name], tz=timezone.utc
),
),
commit=True,
)

if self.purge_feast_metadata:
with self.write_engine.begin() as conn:
Expand Down Expand Up @@ -995,7 +1005,8 @@ def _apply_object(
if hasattr(obj_proto, "meta") and hasattr(
obj_proto.meta, "created_timestamp"
):
obj_proto.meta.created_timestamp.FromDatetime(update_datetime)
if not obj_proto.meta.HasField("created_timestamp"):
obj_proto.meta.created_timestamp.FromDatetime(update_datetime)

values = {
id_field_name: name,
Expand Down
Loading