Skip to content

featurebyte.Treatment.get_by_id

get_by_id(
id: ObjectId
) -> ApiObjectT

Description

Retrieve the object from the persistent data store given the object's ID. This assumes that the object has been saved to the persistent data store. If the object has not been saved, an exception will be raised and you should create and save the object first.

Parameters

  • id: ObjectId
    Object ID value.

Returns

  • ApiObjectT
    ApiObject object of the given object ID.

Examples

Note that the examples below are not exhaustive.

Get an Entity object that is already saved.

>>> fb.Entity.get_by_id(grocery_customer_entity_id)
<featurebyte.api.entity.Entity at 0x7f511dda3bb0>
{
  'name': 'grocerycustomer',
  'created_at': '2023-03-22T04:08:21.668000',
  'updated_at': '2023-03-22T04:08:22.050000',
  'serving_names': [
    'GROCERYCUSTOMERGUID'
  ],
  'catalog_name': 'grocery'
}
Get an Entity object that is not saved.

>>> random_object_id = ObjectId()
>>> grocery_customer_entity = fb.Entity.get_by_id(random_object_id)
'Entity (id: <random_object_id.id>) not found. Please save the Entity object first.'
Get a Feature object that is already saved.

>>> feature_from_id = fb.Feature.get_by_id(invoice_count_60_days_feature_id)