Skip to content

Commit

Permalink
fix: Populates project created_time correctly according to created ti… (
Browse files Browse the repository at this point in the history
#4686)

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

Signed-off-by: Bhargav Dodla <[email protected]>
Co-authored-by: Bhargav Dodla <[email protected]>
  • Loading branch information
EXPEbdodla and Bhargav Dodla authored Oct 29, 2024
1 parent c98c806 commit a61b93c
Showing 1 changed file with 16 additions and 5 deletions.
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 @@ -281,15 +281,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"]
)

if len(feast_metadata_projects) > 0:
with self.read_engine.begin() as conn:
Expand All @@ -299,9 +301,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 @@ -976,7 +986,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

0 comments on commit a61b93c

Please sign in to comment.