Skip to content

featurebyte.Target.save

save(
conflict_resolution: Literal["raise", "retrieve"]="raise"
)

Description

Save an object to the persistent data store. A conflict could be triggered when the object being saved has violated a uniqueness check at the persistent data store. For example, the same object ID could have been used by another record that is already stored.

In these scenarios, we can either raise an error or retrieve the object with the same name, depending on the conflict resolution parameter passed in. The default behavior is to raise an error.

Parameters

  • conflict_resolution: Literal["raise", "retrieve"]
    default: "raise"
    "raise" will raise an error when we encounter a conflict error.
    "retrieve" will handle the conflict error by retrieving the object with the same name.

Raises

  • DuplicatedRecordException
    When a record with the same key exists at the persistent data store.

  • RecordCreationException
    When we fail to save the new object (general failure).

Examples

Note that the examples below are not exhaustive.

Save a new Entity object.

>>> entity = fb.Entity(
...     name="grocerycustomer_example", serving_names=["GROCERYCUSTOMERGUID"]
... )  # doctest: +SKIP

>>> entity.save()
None
Calling save again returns an error.

>>> entity = fb.Entity(
...     name="grocerycustomer", serving_names=["GROCERYCUSTOMERGUID"]
... )  # doctest: +SKIP
>>> entity.save()
>>> entity.save()
Entity (id: <entity.id>) has been saved before.