Class EntityType (1.46.0)

EntityType(
    entity_type_name: str,
    featurestore_id: typing.Optional[str] = None,
    project: typing.Optional[str] = None,
    location: typing.Optional[str] = None,
    credentials: typing.Optional[google.auth.credentials.Credentials] = None,
)

Public managed EntityType resource for Vertex AI.

Properties

create_time

Time this resource was created.

display_name

Display name of this resource.

encryption_spec

Customer-managed encryption key options for this Vertex AI resource.

If this is set, then all resources created by this Vertex AI resource will be encrypted with the provided encryption key.

featurestore_name

Full qualified resource name of the managed featurestore in which this EntityType is.

gca_resource

The underlying resource proto representation.

labels

User-defined labels containing metadata about this resource.

Read more about labels at https://goo.gl/xmQnxf

name

Name of this resource.

preview

Exposes features available in preview for this class.

resource_name

Full qualified resource name.

update_time

Time this resource was last updated.

Methods

EntityType

EntityType(
    entity_type_name: str,
    featurestore_id: typing.Optional[str] = None,
    project: typing.Optional[str] = None,
    location: typing.Optional[str] = None,
    credentials: typing.Optional[google.auth.credentials.Credentials] = None,
)

Retrieves an existing managed entityType given an entityType resource name or an entity_type ID.

Example Usage:

my_entity_type = aiplatform.EntityType(
    entity_type_name='projects/123/locations/us-central1/featurestores/my_featurestore_id/                entityTypes/my_entity_type_id'
)
or
my_entity_type = aiplatform.EntityType(
    entity_type_name='my_entity_type_id',
    featurestore_id='my_featurestore_id',
)
Parameters
Name Description
entity_type_name str

Required. A fully-qualified entityType resource name or an entity_type ID. Example: "projects/123/locations/us-central1/featurestores/my_featurestore_id/entityTypes/my_entity_type_id" or "my_entity_type_id" when project and location are initialized or passed, with featurestore_id passed.

featurestore_id str

Optional. Featurestore ID of an existing featurestore to retrieve entityType from, when entity_type_name is passed as entity_type ID.

project str

Optional. Project to retrieve entityType from. If not set, project set in aiplatform.init will be used.

location str

Optional. Location to retrieve entityType from. If not set, location set in aiplatform.init will be used.

credentials auth_credentials.Credentials

Optional. Custom credentials to use to retrieve this EntityType. Overrides credentials set in aiplatform.init.

batch_create_features

batch_create_features(
    feature_configs: typing.Dict[
        str, typing.Dict[str, typing.Union[bool, int, typing.Dict[str, str], str]]
    ],
    request_metadata: typing.Optional[typing.Sequence[typing.Tuple[str, str]]] = (),
    sync: bool = True,
) -> google.cloud.aiplatform.featurestore._entity_type._EntityType

Batch creates Feature resources in this EntityType.

Example Usage:

my_entity_type = aiplatform.EntityType(
    entity_type_name='my_entity_type_id',
    featurestore_id='my_featurestore_id',
)
my_entity_type.batch_create_features(
    feature_configs={
        "my_feature_id1": {
                "value_type": "INT64",
            },
        "my_feature_id2": {
                "value_type": "BOOL",
            },
        "my_feature_id3": {
                "value_type": "STRING",
            },
    }
)
Parameters
Name Description
feature_configs Dict[str, Dict[str, Union[bool, int, Dict[str, str], str]]]

Required. A user defined Dict containing configurations for feature creation. The feature_configs Dict[str, Dict] i.e. {feature_id: feature_config} contains configuration for each creating feature: .. rubric:: Example feature_configs = { "my_feature_id_1": feature_config_1, "my_feature_id_2": feature_config_2, "my_feature_id_3": feature_config_3, } Each feature_config requires "value_type", and optional "description", "labels": .. rubric:: Example feature_config_1 = { "value_type": "INT64", } feature_config_2 = { "value_type": "BOOL", "description": "my feature id 2 description" } feature_config_3 = { "value_type": "STRING", "labels": { "my key": "my value", } }

request_metadata Sequence[Tuple[str, str]]

Optional. Strings which should be sent along with the request as metadata.

sync bool

Optional. Whether to execute this creation synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

create

create(
    entity_type_id: str,
    featurestore_name: str,
    description: typing.Optional[str] = None,
    labels: typing.Optional[typing.Dict[str, str]] = None,
    project: typing.Optional[str] = None,
    location: typing.Optional[str] = None,
    credentials: typing.Optional[google.auth.credentials.Credentials] = None,
    request_metadata: typing.Optional[typing.Sequence[typing.Tuple[str, str]]] = (),
    sync: bool = True,
    create_request_timeout: typing.Optional[float] = None,
) -> google.cloud.aiplatform.featurestore._entity_type._EntityType

Creates an EntityType resource in a Featurestore.

Example Usage:

my_entity_type = aiplatform.EntityType.create(
    entity_type_id='my_entity_type_id',
    featurestore_name='projects/123/locations/us-central1/featurestores/my_featurestore_id'
)
or
my_entity_type = aiplatform.EntityType.create(
    entity_type_id='my_entity_type_id',
    featurestore_name='my_featurestore_id',
)
Parameters
Name Description
entity_type_id str

Required. The ID to use for the EntityType, which will become the final component of the EntityType's resource name. This value may be up to 60 characters, and valid characters are [a-z0-9_]. The first character cannot be a number. The value must be unique within a featurestore.

featurestore_name str

Required. A fully-qualified featurestore resource name or a featurestore ID of an existing featurestore to create EntityType in. Example: "projects/123/locations/us-central1/featurestores/my_featurestore_id" or "my_featurestore_id" when project and location are initialized or passed.

description str

Optional. Description of the EntityType.

labels Dict[str, str]

Optional. The labels with user-defined metadata to organize your EntityTypes. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information on and examples of labels. No more than 64 user labels can be associated with one EntityType (System labels are excluded)." System reserved label keys are prefixed with "aiplatform.googleapis.com/" and are immutable.

project str

Optional. Project to create EntityType in if featurestore_name is passed an featurestore ID. If not set, project set in aiplatform.init will be used.

location str

Optional. Location to create EntityType in if featurestore_name is passed an featurestore ID. If not set, location set in aiplatform.init will be used.

credentials auth_credentials.Credentials

Optional. Custom credentials to use to create EntityTypes. Overrides credentials set in aiplatform.init.

request_metadata Sequence[Tuple[str, str]]

Optional. Strings which should be sent along with the request as metadata.

sync bool

Optional. Whether to execute this creation synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

create_request_timeout float

Optional. The timeout for the create request in seconds.

create_feature

create_feature(
    feature_id: str,
    value_type: str,
    description: typing.Optional[str] = None,
    labels: typing.Optional[typing.Dict[str, str]] = None,
    request_metadata: typing.Optional[typing.Sequence[typing.Tuple[str, str]]] = (),
    sync: bool = True,
    create_request_timeout: typing.Optional[float] = None,
) -> google.cloud.aiplatform.featurestore.feature.Feature

Creates a Feature resource in this EntityType.

Example Usage:

my_entity_type = aiplatform.EntityType(
    entity_type_name='my_entity_type_id',
    featurestore_id='my_featurestore_id',
)
my_feature = my_entity_type.create_feature(
    feature_id='my_feature_id',
    value_type='INT64',
)
Parameters
Name Description
feature_id str

Required. The ID to use for the Feature, which will become the final component of the Feature's resource name, which is immutable. This value may be up to 60 characters, and valid characters are [a-z0-9_]. The first character cannot be a number. The value must be unique within an EntityType.

value_type str

Required. Immutable. Type of Feature value. One of BOOL, BOOL_ARRAY, DOUBLE, DOUBLE_ARRAY, INT64, INT64_ARRAY, STRING, STRING_ARRAY, BYTES.

description str

Optional. Description of the Feature.

labels Dict[str, str]

Optional. The labels with user-defined metadata to organize your Features. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information on and examples of labels. No more than 64 user labels can be associated with one Feature (System labels are excluded)." System reserved label keys are prefixed with "aiplatform.googleapis.com/" and are immutable.

request_metadata Sequence[Tuple[str, str]]

Optional. Strings which should be sent along with the request as metadata.

sync bool

Optional. Whether to execute this creation synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

create_request_timeout float

Optional. The timeout for the create request in seconds.

delete

delete(sync: bool = True, force: bool = False) -> None

Deletes this EntityType resource. If force is set to True, all features in this EntityType will be deleted prior to entityType deletion.

WARNING: This deletion is permanent.

Parameters
Name Description
force bool

If set to true, any Features for this EntityType will also be deleted. (Otherwise, the request will only work if the EntityType has no Features.)

sync bool

Whether to execute this deletion synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

Exceptions
Type Description
FailedPrecondition If features are created in this EntityType and force = False.

delete_features

delete_features(feature_ids: typing.List[str], sync: bool = True) -> None

Deletes feature resources in this EntityType given their feature IDs. WARNING: This deletion is permanent.

Parameters
Name Description
feature_ids List[str]

Required. The list of feature IDs to be deleted.

sync bool

Optional. Whether to execute this deletion synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

get_feature

get_feature(
    feature_id: str,
) -> google.cloud.aiplatform.featurestore.feature.Feature

Retrieves an existing managed feature in this EntityType.

Parameter
Name Description
feature_id str

Required. The managed feature resource ID in this EntityType.

get_featurestore

get_featurestore() -> (
    google.cloud.aiplatform.featurestore.featurestore.Featurestore
)

Retrieves the managed featurestore in which this EntityType is.

ingest_from_bq

ingest_from_bq(
    feature_ids: typing.List[str],
    feature_time: typing.Union[str, datetime.datetime],
    bq_source_uri: str,
    feature_source_fields: typing.Optional[typing.Dict[str, str]] = None,
    entity_id_field: typing.Optional[str] = None,
    disable_online_serving: typing.Optional[bool] = None,
    worker_count: typing.Optional[int] = None,
    request_metadata: typing.Optional[typing.Sequence[typing.Tuple[str, str]]] = (),
    sync: bool = True,
    ingest_request_timeout: typing.Optional[float] = None,
) -> google.cloud.aiplatform.featurestore._entity_type._EntityType

Ingest feature values from BigQuery.

Parameters
Name Description
feature_ids List[str]

Required. IDs of the Feature to import values of. The Features must exist in the target EntityType, or the request will fail.

feature_time Union[str, datetime.datetime]

Required. The feature_time can be one of: - The source column that holds the Feature timestamp for all Feature values in each entity. - A single Feature timestamp for all entities being imported. The timestamp must not have higher than millisecond precision.

bq_source_uri str

Required. BigQuery URI to the input table. .. rubric:: Example 'bq://project.dataset.table_name'

feature_source_fields Dict[str, str]

Optional. User defined dictionary to map ID of the Feature for importing values of to the source column for getting the Feature values from. Specify the features whose ID and source column are not the same. If not provided, the source column need to be the same as the Feature ID. .. rubric:: Example feature_ids = ['my_feature_id_1', 'my_feature_id_2', 'my_feature_id_3'] feature_source_fields = { 'my_feature_id_1': 'my_feature_id_1_source_field', } Note: The source column of 'my_feature_id_1' is 'my_feature_id_1_source_field', The source column of 'my_feature_id_2' is the ID of the feature, same for 'my_feature_id_3'.

entity_id_field str

Optional. Source column that holds entity IDs. If not provided, entity IDs are extracted from the column named entity_id.

disable_online_serving bool

Optional. If set, data will not be imported for online serving. This is typically used for backfilling, where Feature generation timestamps are not in the timestamp range needed for online serving.

worker_count int

Optional. Specifies the number of workers that are used to write data to the Featurestore. Consider the online serving capacity that you require to achieve the desired import throughput without interfering with online serving. The value must be positive, and less than or equal to 100. If not set, defaults to using 1 worker. The low count ensures minimal impact on online serving performance.

request_metadata Sequence[Tuple[str, str]]

Optional. Strings which should be sent along with the request as metadata.

sync bool

Optional. Whether to execute this import synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

ingest_request_timeout float

Optional. The timeout for the ingest request in seconds.

ingest_from_df

ingest_from_df(
    feature_ids: typing.List[str],
    feature_time: typing.Union[str, datetime.datetime],
    df_source: pd.DataFrame,
    feature_source_fields: typing.Optional[typing.Dict[str, str]] = None,
    entity_id_field: typing.Optional[str] = None,
    request_metadata: typing.Optional[typing.Sequence[typing.Tuple[str, str]]] = (),
    ingest_request_timeout: typing.Optional[float] = None,
) -> _EntityType

Ingest feature values from DataFrame.

Parameters
Name Description
feature_ids List[str]

Required. IDs of the Feature to import values of. The Features must exist in the target EntityType, or the request will fail.

feature_time Union[str, datetime.datetime]

Required. The feature_time can be one of: - The source column that holds the Feature timestamp for all Feature values in each entity. Note: The dtype of the source column should be datetime64. - A single Feature timestamp for all entities being imported. The timestamp must not have higher than millisecond precision. Example: feature_time = datetime.datetime(year=2022, month=1, day=1, hour=11, minute=59, second=59) or feature_time_str = datetime.datetime.now().isoformat(sep=" ", timespec="milliseconds") feature_time = datetime.datetime.strptime(feature_time_str, "%Y-%m-%d %H:%M:%S.%f")

feature_source_fields Dict[str, str]

Optional. User defined dictionary to map ID of the Feature for importing values of to the source column for getting the Feature values from. Specify the features whose ID and source column are not the same. If not provided, the source column need to be the same as the Feature ID. .. rubric:: Example feature_ids = ['my_feature_id_1', 'my_feature_id_2', 'my_feature_id_3'] feature_source_fields = { 'my_feature_id_1': 'my_feature_id_1_source_field', } Note: The source column of 'my_feature_id_1' is 'my_feature_id_1_source_field', The source column of 'my_feature_id_2' is the ID of the feature, same for 'my_feature_id_3'.

entity_id_field str

Optional. Source column that holds entity IDs. If not provided, entity IDs are extracted from the column named entity_id.

request_metadata Sequence[Tuple[str, str]]

Optional. Strings which should be sent along with the request as metadata.

ingest_request_timeout float

Optional. The timeout for the ingest request in seconds.

df_source pd.DataFrame

Required. Pandas DataFrame containing the source data for ingestion.

ingest_from_gcs

ingest_from_gcs(
    feature_ids: typing.List[str],
    feature_time: typing.Union[str, datetime.datetime],
    gcs_source_uris: typing.Union[str, typing.List[str]],
    gcs_source_type: str,
    feature_source_fields: typing.Optional[typing.Dict[str, str]] = None,
    entity_id_field: typing.Optional[str] = None,
    disable_online_serving: typing.Optional[bool] = None,
    worker_count: typing.Optional[int] = None,
    request_metadata: typing.Optional[typing.Sequence[typing.Tuple[str, str]]] = (),
    sync: bool = True,
    ingest_request_timeout: typing.Optional[float] = None,
) -> google.cloud.aiplatform.featurestore._entity_type._EntityType

Ingest feature values from GCS.

Parameters
Name Description
feature_ids List[str]

Required. IDs of the Feature to import values of. The Features must exist in the target EntityType, or the request will fail.

feature_time Union[str, datetime.datetime]

Required. The feature_time can be one of: - The source column that holds the Feature timestamp for all Feature values in each entity. - A single Feature timestamp for all entities being imported. The timestamp must not have higher than millisecond precision.

gcs_source_uris Union[str, List[str]]

Required. Google Cloud Storage URI(-s) to the input file(s). May contain wildcards. For more information on wildcards, see https://cloud.google.com/storage/docs/gsutil/addlhelp/WildcardNames. .. rubric:: Example ["gs://my_bucket/my_file_1.csv", "gs://my_bucket/my_file_2.csv"] or "gs://my_bucket/my_file.avro"

gcs_source_type str

Required. The type of the input file(s) provided by gcs_source_uris, the value of gcs_source_type can only be either csv, or avro.

feature_source_fields Dict[str, str]

Optional. User defined dictionary to map ID of the Feature for importing values of to the source column for getting the Feature values from. Specify the features whose ID and source column are not the same. If not provided, the source column need to be the same as the Feature ID. .. rubric:: Example feature_ids = ['my_feature_id_1', 'my_feature_id_2', 'my_feature_id_3'] feature_source_fields = { 'my_feature_id_1': 'my_feature_id_1_source_field', } Note: The source column of 'my_feature_id_1' is 'my_feature_id_1_source_field', The source column of 'my_feature_id_2' is the ID of the feature, same for 'my_feature_id_3'.

entity_id_field str

Optional. Source column that holds entity IDs. If not provided, entity IDs are extracted from the column named entity_id.

disable_online_serving bool

Optional. If set, data will not be imported for online serving. This is typically used for backfilling, where Feature generation timestamps are not in the timestamp range needed for online serving.

worker_count int

Optional. Specifies the number of workers that are used to write data to the Featurestore. Consider the online serving capacity that you require to achieve the desired import throughput without interfering with online serving. The value must be positive, and less than or equal to 100. If not set, defaults to using 1 worker. The low count ensures minimal impact on online serving performance.

request_metadata Sequence[Tuple[str, str]]

Optional. Strings which should be sent along with the request as metadata.

sync bool

Optional. Whether to execute this import synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

ingest_request_timeout float

Optional. The timeout for the ingest request in seconds.

Exceptions
Type Description
ValueErro if gcs_source_type is not supported.:

list

list(
    featurestore_name: str,
    filter: typing.Optional[str] = None,
    order_by: typing.Optional[str] = None,
    project: typing.Optional[str] = None,
    location: typing.Optional[str] = None,
    credentials: typing.Optional[google.auth.credentials.Credentials] = None,
) -> typing.List[google.cloud.aiplatform.featurestore._entity_type._EntityType]

Lists existing managed entityType resources in a featurestore, given a featurestore resource name or a featurestore ID.

Example Usage:

my_entityTypes = aiplatform.EntityType.list(
    featurestore_name='projects/123/locations/us-central1/featurestores/my_featurestore_id'
)
or
my_entityTypes = aiplatform.EntityType.list(
    featurestore_name='my_featurestore_id'
)
Parameters
Name Description
featurestore_name str

Required. A fully-qualified featurestore resource name or a featurestore ID of an existing featurestore to list entityTypes in. Example: "projects/123/locations/us-central1/featurestores/my_featurestore_id" or "my_featurestore_id" when project and location are initialized or passed.

filter str

Optional. Lists the EntityTypes that match the filter expression. The following filters are supported: - create_time: Supports =, !=, <, >, >=, and <= comparisons. Values must be in RFC 3339 format. - update_time: Supports =, !=, <, >, >=, and <= comparisons. Values must be in RFC 3339 format. - labels: Supports key-value equality as well as key presence. Examples: - create_time > "2020-01-31T15:30:00.000000Z" OR update_time > "2020-01-31T15:30:00.000000Z" --> EntityTypes created or updated after 2020-01-31T15:30:00.000000Z. - labels.active = yes AND labels.env = prod --> EntityTypes having both (active: yes) and (env: prod) labels. - labels.env: * --> Any EntityType which has a label with 'env' as the key.

order_by str

Optional. A comma-separated list of fields to order by, sorted in ascending order. Use "desc" after a field name for descending. Supported fields: - entity_type_id - create_time - update_time

project str

Optional. Project to list entityTypes in. If not set, project set in aiplatform.init will be used.

location str

Optional. Location to list entityTypes in. If not set, location set in aiplatform.init will be used.

credentials auth_credentials.Credentials

Optional. Custom credentials to use to list entityTypes. Overrides credentials set in aiplatform.init.

list_features

list_features(
    filter: typing.Optional[str] = None, order_by: typing.Optional[str] = None
) -> typing.List[google.cloud.aiplatform.featurestore.feature.Feature]

Lists existing managed feature resources in this EntityType.

Example Usage:

my_entity_type = aiplatform.EntityType(
    entity_type_name='my_entity_type_id',
    featurestore_id='my_featurestore_id',
)
my_entityType.list_features()
Parameters
Name Description
filter str

Optional. Lists the Features that match the filter expression. The following filters are supported: - value_type: Supports = and != comparisons. - create_time: Supports =, !=, <, >, >=, and <= comparisons. Values must be in RFC 3339 format. - update_time: Supports =, !=, <, >, >=, and <= comparisons. Values must be in RFC 3339 format. - labels: Supports key-value equality as well as key presence. Examples: - value_type = DOUBLE --> Features whose type is DOUBLE. - create_time > "2020-01-31T15:30:00.000000Z" OR update_time > "2020-01-31T15:30:00.000000Z" --> EntityTypes created or updated after 2020-01-31T15:30:00.000000Z. - labels.active = yes AND labels.env = prod --> Features having both (active: yes) and (env: prod) labels. - labels.env: * --> Any Feature which has a label with 'env' as the key.

order_by str

Optional. A comma-separated list of fields to order by, sorted in ascending order. Use "desc" after a field name for descending. Supported fields: - feature_id - value_type - create_time - update_time

read

read(
    entity_ids: typing.Union[str, typing.List[str]],
    feature_ids: typing.Union[str, typing.List[str]] = "*",
    request_metadata: typing.Optional[typing.Sequence[typing.Tuple[str, str]]] = (),
    read_request_timeout: typing.Optional[float] = None,
) -> pd.DataFrame

Reads feature values for given feature IDs of given entity IDs in this EntityType.

Parameters
Name Description
entity_ids Union[str, List[str]]

Required. ID for a specific entity, or a list of IDs of entities to read Feature values of. The maximum number of IDs is 100 if a list.

feature_ids Union[str, List[str]]

Required. ID for a specific feature, or a list of IDs of Features in the EntityType for reading feature values. Default to "*", where value of all features will be read.

request_metadata Sequence[Tuple[str, str]]

Optional. Strings which should be sent along with the request as metadata.

read_request_timeout float

Optional. The timeout for the read request in seconds.

Returns
Type Description
pd.DataFrame entities' feature values in DataFrame

to_dict

to_dict() -> typing.Dict[str, typing.Any]

Returns the resource proto as a dictionary.

update

update(
    description: typing.Optional[str] = None,
    labels: typing.Optional[typing.Dict[str, str]] = None,
    request_metadata: typing.Sequence[typing.Tuple[str, str]] = (),
    update_request_timeout: typing.Optional[float] = None,
) -> google.cloud.aiplatform.featurestore._entity_type._EntityType

Updates an existing managed entityType resource.

Example Usage:

my_entity_type = aiplatform.EntityType(
    entity_type_name='my_entity_type_id',
    featurestore_id='my_featurestore_id',
)
my_entity_type.update(
    description='update my description',
)
Parameters
Name Description
description str

Optional. Description of the EntityType.

labels Dict[str, str]

Optional. The labels with user-defined metadata to organize your EntityTypes. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. See https://goo.gl/xmQnxf for more information on and examples of labels. No more than 64 user labels can be associated with one Feature (System labels are excluded)." System reserved label keys are prefixed with "aiplatform.googleapis.com/" and are immutable.

request_metadata Sequence[Tuple[str, str]]

Required. Strings which should be sent along with the request as metadata.

update_request_timeout float

Optional. The timeout for the update request in seconds.

wait

wait()

Helper method that blocks until all futures are complete.

write_feature_values

write_feature_values(
    instances: typing.Union[
        typing.List[
            google.cloud.aiplatform_v1.types.featurestore_online_service.WriteFeatureValuesPayload
        ],
        typing.Dict[
            str,
            typing.Dict[
                str,
                typing.Union[
                    int,
                    str,
                    float,
                    bool,
                    bytes,
                    typing.List[int],
                    typing.List[str],
                    typing.List[float],
                    typing.List[bool],
                ],
            ],
        ],
        pd.DataFrame,
    ],
    feature_time: typing.Union[str, datetime.datetime] = None,
) -> EntityType

Streaming ingestion. Write feature values directly to Feature Store.

my_entity_type = aiplatform.EntityType(
    entity_type_name="my_entity_type_id",
    featurestore_id="my_featurestore_id",
)

# writing feature values from a pandas DataFrame without feature timestamp column.
# In this case, current timestamp will be applied to all data.
my_dataframe = pd.DataFrame(
    data = [
        {"entity_id": "movie_01", "average_rating": 4.9}
    ],
    columns=["entity_id", "average_rating"],
)
my_dataframe = my_df.set_index("entity_id")

my_entity_type.write_feature_values(
    instances=my_df
)

# writing feature values from a pandas DataFrame with feature timestamp column
# Example of datetime creation.
feature_time = datetime.datetime(year=2022, month=1, day=1, hour=11, minute=59, second=59)
or
feature_time_str = datetime.datetime.now().isoformat(sep=" ", timespec="milliseconds")
feature_time = datetime.datetime.strptime(feature_time_str, "%Y-%m-%d %H:%M:%S.%f")

my_dataframe = pd.DataFrame(
    data = [
        {"entity_id": "movie_01", "average_rating": 4.9,
        "feature_timestamp": feature_time}
    ],
    columns=["entity_id", "average_rating", "feature_timestamp"],
)

my_dataframe = my_df.set_index("entity_id")
my_entity_type.write_feature_values(
    instances=my_df, feature_time="feature_timestamp"
)

# writing feature values with a timestamp. The timestamp will be applied to the entire Dataframe.
my_dataframe = pd.DataFrame(
    data = [
        {"entity_id": "movie_01", "average_rating": 4.9}
    ],
    columns=["entity_id", "average_rating"],
)
my_dataframe = my_df.set_index("entity_id")
my_entity_type.write_feature_values(
    instances=my_df, feature_time=feature_time
)

# writing feature values from a Python dict without timestamp column.
# In this case, current timestamp will be applied to all data.
my_data_dict = {
        "movie_02" : {"average_rating": 3.7}
}

my_entity_type.write_feature_values(
    instances=my_data_dict
)

# writing feature values from a Python dict with timestamp column
my_data_dict = {
        "movie_02" : {"average_rating": 3.7, "feature_timestamp": timestmap}}
}

my_entity_type.write_feature_values(
    instances=my_data_dict, feature_time="feature_timestamp"
)

# writing feature values from a Python dict and apply the same Feature_Timestamp
my_data_dict = {
        "movie_02" : {"average_rating": 3.7}
}

my_entity_type.write_feature_values(
    instances=my_data_dict, feature_time=feature_time
)

# writing feature values from a list of WriteFeatureValuesPayload objects
payloads = [
    gca_featurestore_online_service.WriteFeatureValuesPayload(
        entity_id="movie_03",
        feature_values={
                "average_rating": featurestore_online_service.FeatureValue(
                        string_value="test",
                        metadata=featurestore_online_service.FeatureValue.Metadata(
                                generate_time=timestmap
                        )
               }
        }
    )
]
# when instance is WriteFeatureValuesPayload,
# feature_time param of write_feature_values() is ignored.
my_entity_type.write_feature_values(
    instances=payloads
)

# reading back written feature values
my_entity_type.read(
    entity_ids=["movie_01", "movie_02", "movie_03"]
)