MCPcopy
hub / github.com/feast-dev/feast / apply_entity

Method apply_entity

sdk/python/feast/infra/registry/registry.py:337–366  ·  view source on GitHub ↗
(self, entity: Entity, project: str, commit: bool = True)

Source from the content-addressed store, hash-verified

335 return Infra.from_proto(registry_proto.infra)
336
337 def apply_entity(self, entity: Entity, project: str, commit: bool = True):
338 entity.is_valid()
339
340 now = _utc_now()
341 if not entity.created_timestamp:
342 entity.created_timestamp = now
343 entity.last_updated_timestamp = now
344
345 entity_proto = entity.to_proto()
346 entity_proto.spec.project = project
347 self._prepare_registry_for_changes(project)
348 assert self.cached_registry_proto
349
350 for idx, existing_entity_proto in enumerate(
351 self.cached_registry_proto.entities
352 ):
353 if (
354 existing_entity_proto.spec.name == entity_proto.spec.name
355 and existing_entity_proto.spec.project == project
356 ):
357 entity.created_timestamp = (
358 existing_entity_proto.meta.created_timestamp.ToDatetime()
359 )
360 entity_proto = entity.to_proto()
361 entity_proto.spec.project = project
362 del self.cached_registry_proto.entities[idx]
363 break
364 self.cached_registry_proto.entities.append(entity_proto)
365 if commit:
366 self.commit()
367
368 def list_entities(
369 self,

Callers 2

test_commitFunction · 0.95

Calls 5

commitMethod · 0.95
_utc_nowFunction · 0.90
is_validMethod · 0.45
to_protoMethod · 0.45

Tested by 2

test_commitFunction · 0.76