Class EntityType (1.17.1)

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

Managed entityType resource for Vertex AI.

Inheritance

builtins.object > google.cloud.aiplatform.base.VertexAiResourceNoun > builtins.object > google.cloud.aiplatform.base.FutureManager > google.cloud.aiplatform.base.VertexAiResourceNounWithFutureManager > EntityType

Properties

featurestore_name

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

Methods

EntityType

EntityType(
    entity_type_name: str,
    featurestore_id: Optional[str] = None,
    project: Optional[str] = None,
    location: Optional[str] = None,
    credentials: 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: Dict[str, Dict[str, Union[bool, int, Dict[str, str], str]]],
    request_metadata: Optional[Sequence[Tuple[str, str]]] = (),
    sync: bool = True,
)

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: Optional[str] = None,
    labels: Optional[Dict[str, str]] = None,
    project: Optional[str] = None,
    location: Optional[str] = None,
    credentials: Optional[google.auth.credentials.Credentials] = None,
    request_metadata: Optional[Sequence[Tuple[str, str]]] = (),
    sync: bool = True,
    create_request_timeout: Optional[float] = None,
)

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: Optional[str] = None,
    labels: Optional[Dict[str, str]] = None,
    request_metadata: Optional[Sequence[Tuple[str, str]]] = (),
    sync: bool = True,
    create_request_timeout: Optional[float] = None,
)

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)

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: List[str], sync: bool = True)

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)

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()

Retrieves the managed featurestore in which this EntityType is.

ingest_from_bq

ingest_from_bq(
    feature_ids: List[str],
    feature_time: Union[str, datetime.datetime],
    bq_source_uri: str,
    feature_source_fields: Optional[Dict[str, str]] = None,
    entity_id_field: Optional[str] = None,
    disable_online_serving: Optional[bool] = None,
    worker_count: Optional[int] = None,
    request_metadata: Optional[Sequence[Tuple[str, str]]] = (),
    sync: bool = True,
    ingest_request_timeout: Optional[float] = None,
)

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: List[str],
    feature_time: Union[str, datetime.datetime],
    df_source: pd.DataFrame,
    feature_source_fields: Optional[Dict[str, str]] = None,
    entity_id_field: Optional[str] = None,
    request_metadata: Optional[Sequence[Tuple[str, str]]] = (),
    ingest_request_timeout: Optional[float] = None,
)

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: List[str],
    feature_time: Union[str, datetime.datetime],
    gcs_source_uris: Union[str, List[str]],
    gcs_source_type: str,
    feature_source_fields: Optional[Dict[str, str]] = None,
    entity_id_field: Optional[str] = None,
    disable_online_serving: Optional[bool] = None,
    worker_count: Optional[int] = None,
    request_metadata: Optional[Sequence[Tuple[str, str]]] = (),
    sync: bool = True,
    ingest_request_timeout: Optional[float] = None,
)

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: Optional[str] = None,
    order_by: Optional[str] = None,
    project: Optional[str] = None,
    location: Optional[str] = None,
    credentials: Optional[google.auth.credentials.Credentials] = None,
)

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: Optional[str] = None, order_by: Optional[str] = None)

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: Union[str, List[str]],
    feature_ids: Union[str, List[str]] = "*",
    request_metadata: Optional[Sequence[Tuple[str, str]]] = (),
    read_request_timeout: Optional[float] = None,
)

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

update

update(
    description: Optional[str] = None,
    labels: Optional[Dict[str, str]] = None,
    request_metadata: Sequence[Tuple[str, str]] = (),
    update_request_timeout: Optional[float] = None,
)

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.