diff options
Diffstat (limited to '.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set')
17 files changed, 764 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/__init__.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/__init__.py new file mode 100644 index 00000000..fdf8caba --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/__init__.py @@ -0,0 +1,5 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/data_availability_status.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/data_availability_status.py new file mode 100644 index 00000000..aa438f3b --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/data_availability_status.py @@ -0,0 +1,15 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class DataAvailabilityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """DataAvailabilityStatus.""" + + NONE = "None" + PENDING = "Pending" + INCOMPLETE = "Incomplete" + COMPLETE = "Complete" diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/delay_metadata.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/delay_metadata.py new file mode 100644 index 00000000..66599605 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/delay_metadata.py @@ -0,0 +1,17 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +# pylint: disable=unused-argument + + +from typing import Any, Optional + + +class DelayMetadata(object): + def __init__( + self, *, days: Optional[int] = None, hours: Optional[int] = None, minutes: Optional[int] = None, **kwargs: Any + ): + self.days = days + self.hours = hours + self.minutes = minutes diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature.py new file mode 100644 index 00000000..2cc54815 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature.py @@ -0,0 +1,54 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +# pylint: disable=unused-argument + +from typing import Any, Dict, Optional + +from azure.ai.ml._restclient.v2023_10_01.models import Feature as RestFeature +from azure.ai.ml._restclient.v2023_10_01.models import FeatureProperties +from azure.ai.ml.entities._feature_store_entity.data_column_type import DataColumnType +from azure.ai.ml.entities._mixins import RestTranslatableMixin + + +class Feature(RestTranslatableMixin): + """Feature + + :param name: The name of the feature. + :type name: str + :param data_type: The data type of the feature. + :type data_type: ~azure.ai.ml.entities.DataColumnType + :param description: The description of the feature. Defaults to None. + :type description: Optional[str] + :param tags: Tag dictionary. Tags can be added, removed, and updated. Defaults to None. + :type tags: Optional[dict[str, str]] + :param kwargs: A dictionary of additional configuration parameters. + :type kwargs: dict + """ + + def __init__( + self, + *, + name: str, + data_type: DataColumnType, + description: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ): + self.name = name + self.data_type = data_type + self.description = description + self.tags = tags + + @classmethod + def _from_rest_object(cls, obj: RestFeature) -> Optional["Feature"]: + if not obj: + return None + feature_rest_object_details: FeatureProperties = obj.properties + return Feature( + name=feature_rest_object_details.feature_name, + data_type=feature_rest_object_details.data_type, + description=feature_rest_object_details.description, + tags=feature_rest_object_details.tags, + ) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_set_backfill_metadata.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_set_backfill_metadata.py new file mode 100644 index 00000000..652908e9 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_set_backfill_metadata.py @@ -0,0 +1,39 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +from typing import Any, List, Optional + +from azure.ai.ml._restclient.v2023_10_01.models import ( + FeaturesetVersionBackfillResponse as RestFeaturesetVersionBackfillResponse, +) +from azure.ai.ml.entities._mixins import RestTranslatableMixin + + +class FeatureSetBackfillMetadata(RestTranslatableMixin): + """Feature Set Backfill Metadata + + :param job_ids: A list of IDs of the backfill jobs. Defaults to None. + :type job_ids: Optional[List[str]] + :param type: The type of the backfill job. Defaults to None. + :type type: Optional[str] + :param kwargs: A dictionary of additional configuration parameters. + :type kwargs: dict + """ + + def __init__( + self, + *, + job_ids: Optional[List[str]] = None, + type: Optional[str] = None, # pylint: disable=redefined-builtin + # pylint: disable=unused-argument + **kwargs: Any + ) -> None: + self.type = type if type else "BackfillMaterialization" + self.job_ids = job_ids + + @classmethod + def _from_rest_object(cls, obj: RestFeaturesetVersionBackfillResponse) -> Optional["FeatureSetBackfillMetadata"]: + if not obj: + return None + return FeatureSetBackfillMetadata(job_ids=obj.job_ids) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_set_backfill_request.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_set_backfill_request.py new file mode 100644 index 00000000..0baebf4c --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_set_backfill_request.py @@ -0,0 +1,91 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +# pylint: disable=unused-argument + +from os import PathLike +from pathlib import Path +from typing import Any, Dict, List, Optional, Tuple, Union + +from azure.ai.ml._schema._feature_set.feature_set_backfill_schema import FeatureSetBackfillSchema +from azure.ai.ml.constants._common import BASE_PATH_CONTEXT_KEY, PARAMS_OVERRIDE_KEY +from azure.ai.ml.entities._feature_set.feature_window import FeatureWindow +from azure.ai.ml.entities._feature_set.materialization_compute_resource import MaterializationComputeResource +from azure.ai.ml.entities._mixins import RestTranslatableMixin +from azure.ai.ml.entities._util import load_from_dict + + +class FeatureSetBackfillRequest(RestTranslatableMixin): + """Feature Set Backfill Request + + :param name: The name of the backfill job request + :type name: str + :param version: The version of the backfill job request. + :type version: str + :param feature_window: The time window for the feature set backfill request. + :type feature_window: ~azure.ai.ml._restclient.v2023_04_01_preview.models.FeatureWindow + :param description: The description of the backfill job request. Defaults to None. + :type description: Optional[str] + :param tags: Tag dictionary. Tags can be added, removed, and updated. Defaults to None. + :type tags: Optional[dict[str, str]] + :keyword resource: The compute resource settings. Defaults to None. + :paramtype resource: Optional[~azure.ai.ml.entities.MaterializationComputeResource] + :param spark_configuration: Specifies the spark configuration. Defaults to None. + :type spark_configuration: Optional[dict[str, str]] + """ + + def __init__( + self, + *, + name: str, + version: str, + feature_window: Optional[FeatureWindow] = None, + description: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + resource: Optional[MaterializationComputeResource] = None, + spark_configuration: Optional[Dict[str, str]] = None, + data_status: Optional[List[str]] = None, + job_id: Optional[str] = None, + **kwargs: Any, + ): + self.name = name + self.version = version + self.feature_window = feature_window + self.description = description + self.resource = resource + self.tags = tags + self.spark_configuration = spark_configuration + self.data_status = data_status + self.job_id = job_id + + @classmethod + # pylint: disable=unused-argument + def _resolve_cls_and_type(cls, data: Dict, params_override: Tuple) -> Tuple: + """Resolve the class to use for deserializing the data. Return current class if no override is provided. + + :param data: Data to deserialize. + :type data: dict + :param params_override: Parameters to override, defaults to None + :type params_override: typing.Optional[list] + :return: Class to use for deserializing the data & its "type". Type will be None if no override is provided. + :rtype: tuple[class, typing.Optional[str]] + """ + return cls, None + + @classmethod + def _load( + cls, + data: Optional[Dict] = None, + yaml_path: Optional[Union[PathLike, str]] = None, + params_override: Optional[list] = None, + **kwargs: Any, + ) -> "FeatureSetBackfillRequest": + data = data or {} + params_override = params_override or [] + context = { + BASE_PATH_CONTEXT_KEY: Path(yaml_path).parent if yaml_path else Path("./"), + PARAMS_OVERRIDE_KEY: params_override, + } + loaded_schema = load_from_dict(FeatureSetBackfillSchema, data, context, **kwargs) + return FeatureSetBackfillRequest(**loaded_schema) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_set_materialization_metadata.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_set_materialization_metadata.py new file mode 100644 index 00000000..afcf3fd1 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_set_materialization_metadata.py @@ -0,0 +1,98 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +from datetime import datetime, timedelta +from typing import Any, Dict, Optional + +from azure.ai.ml._restclient.v2023_10_01.models import JobBase as RestJobBase +from azure.ai.ml.entities._mixins import RestTranslatableMixin +from azure.ai.ml.entities._system_data import SystemData + +from .materialization_type import MaterializationType + +FeaturestoreJobTypeMap: Dict[str, MaterializationType] = { + "BackfillMaterialization": MaterializationType.BACKFILL_MATERIALIZATION, + "RecurrentMaterialization": MaterializationType.RECURRENT_MATERIALIZATION, +} + + +class FeatureSetMaterializationMetadata(RestTranslatableMixin): + """Feature Set Materialization Metadata + + :param type: The type of the materialization job. + :type type: MaterializationType + :param feature_window_start_time: The feature window start time for the feature set materialization job. + :type feature_window_start_time: Optional[datetime] + :param feature_window_end_time: The feature window end time for the feature set materialization job. + :type feature_window_end_time: Optional[datetime] + :param name: The name of the feature set materialization job. + :type name: Optional[str] + :param display_name: The display name for the feature set materialization job. + :type display_name: Optional[str] + :param creation_context: The creation context of the feature set materialization job. + :type creation_context: Optional[~azure.ai.ml.entities.SystemData] + :param duration: current time elapsed for feature set materialization job. + :type duration: Optional[~datetime.timedelta] + :param status: The status of the feature set materialization job. + :type status: Optional[str] + :param tags: Tag dictionary. Tags can be added, removed, and updated. + :type tags: Optional[dict[str, str]] + :param kwargs: A dictionary of additional configuration parameters. + :type kwargs: dict + """ + + def __init__( + self, + *, + # pylint: disable=redefined-builtin + type: Optional[MaterializationType], + feature_window_start_time: Optional[datetime], + feature_window_end_time: Optional[datetime], + name: Optional[str], + display_name: Optional[str], + creation_context: Optional[SystemData], + duration: Optional[timedelta], + status: Optional[str], + tags: Optional[Dict[str, str]], + # pylint: disable=unused-argument + **kwargs: Any, + ): + self.type = type + self.feature_window_start_time = feature_window_start_time + self.feature_window_end_time = feature_window_end_time + self.name = name + self.display_name = display_name + self.creation_context = creation_context + self.duration = duration + self.status = status + self.tags = tags + + @classmethod + def _from_rest_object(cls, obj: RestJobBase) -> Optional["FeatureSetMaterializationMetadata"]: + if not obj: + return None + job_properties = obj.properties + job_type = job_properties.properties.get("azureml.FeatureStoreJobType", None) + feature_window_start_time = job_properties.properties.get("azureml.FeatureWindowStart", None) + feature_window_end_time = job_properties.properties.get("azureml.FeatureWindowEnd", None) + + time_format = "%Y-%m-%dT%H:%M:%SZ" + feature_window_start_time = ( + datetime.strptime(feature_window_start_time, time_format) if feature_window_start_time else None + ) + feature_window_end_time = ( + datetime.strptime(feature_window_end_time, time_format) if feature_window_end_time else None + ) + + return FeatureSetMaterializationMetadata( + type=FeaturestoreJobTypeMap.get(job_type), + feature_window_start_time=feature_window_start_time, + feature_window_end_time=feature_window_end_time, + name=obj.name, + display_name=job_properties.display_name, + creation_context=SystemData(created_at=obj.system_data.created_at), + status=job_properties.status, + tags=job_properties.tags, + duration=None, + ) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_set_specification.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_set_specification.py new file mode 100644 index 00000000..88ed093f --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_set_specification.py @@ -0,0 +1,46 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +from os import PathLike +from typing import Any, Optional, Union + +from azure.ai.ml._restclient.v2023_10_01.models import FeaturesetSpecification as RestFeaturesetSpecification +from azure.ai.ml.entities._mixins import RestTranslatableMixin + + +class FeatureSetSpecification(RestTranslatableMixin): + """Feature Set Specification + + :param path: Specifies the feature set spec path to file. Defaults to None. + :type path: Optional[str] + :param kwargs: A dictionary of additional configuration parameters. + :type kwargs: dict + + .. admonition:: Example: + + .. literalinclude:: ../samples/ml_samples_featurestore.py + :start-after: [START configure_feature_set] + :end-before: [END configure_feature_set] + :language: python + :dedent: 8 + :caption: Using Feature Set Spec to create Feature Set + """ + + def __init__( + self, *, path: Optional[Union[PathLike, str]] = None, **kwargs: Any + ): # pylint: disable=unused-argument + """ + :param path: Specifies the spec path. + :type path: str + """ + self.path = path + + def _to_rest_object(self) -> RestFeaturesetSpecification: + return RestFeaturesetSpecification(path=self.path) + + @classmethod + def _from_rest_object(cls, obj: RestFeaturesetSpecification) -> Optional["FeatureSetSpecification"]: + if not obj: + return None + return FeatureSetSpecification(path=obj.path) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_transformation_code_metadata.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_transformation_code_metadata.py new file mode 100644 index 00000000..5fd8544e --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_transformation_code_metadata.py @@ -0,0 +1,13 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +# pylint: disable=unused-argument + +from typing import Any, Optional + + +class FeatureTransformationCodeMetadata(object): + def __init__(self, *, path: str, transformer_class: Optional[str] = None, **kwargs: Any): + self.path = path + self.transformer_class = transformer_class diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_window.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_window.py new file mode 100644 index 00000000..758d1ecf --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/feature_window.py @@ -0,0 +1,34 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +from datetime import datetime +from typing import Any, Optional + +from azure.ai.ml._restclient.v2023_10_01.models import FeatureWindow as RestFeatureWindow +from azure.ai.ml.entities._mixins import RestTranslatableMixin + + +class FeatureWindow(RestTranslatableMixin): + """Feature window + :keyword feature_window_end: Specifies the feature window end time. + :paramtype feature_window_end: ~datetime.datetime + :keyword feature_window_start: Specifies the feature window start time. + :paramtype feature_window_start: ~datetime.datetime + """ + + # pylint: disable=unused-argument + def __init__(self, *, feature_window_start: datetime, feature_window_end: datetime, **kwargs: Any) -> None: + self.feature_window_start = feature_window_start + self.feature_window_end = feature_window_end + + def _to_rest_object(self) -> RestFeatureWindow: + return RestFeatureWindow( + feature_window_start=self.feature_window_start, feature_window_end=self.feature_window_end + ) + + @classmethod + def _from_rest_object(cls, obj: RestFeatureWindow) -> Optional["FeatureWindow"]: + if not obj: + return None + return FeatureWindow(feature_window_start=obj.feature_window_start, feature_window_end=obj.feature_window_end) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/featureset_spec_metadata.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/featureset_spec_metadata.py new file mode 100644 index 00000000..4178b074 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/featureset_spec_metadata.py @@ -0,0 +1,101 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + + +from os import PathLike +from pathlib import Path +from typing import Any, Dict, List, Optional, Union + +from marshmallow import INCLUDE + +from azure.ai.ml._schema._feature_set.featureset_spec_metadata_schema import FeaturesetSpecMetadataSchema +from azure.ai.ml._schema._feature_set.featureset_spec_properties_schema import FeaturesetSpecPropertiesSchema +from azure.ai.ml._utils.utils import load_yaml +from azure.ai.ml.constants._common import BASE_PATH_CONTEXT_KEY +from azure.ai.ml.entities._feature_store_entity.data_column import DataColumn +from azure.ai.ml.entities._util import load_from_dict +from azure.ai.ml.exceptions import ErrorCategory, ErrorTarget, ValidationErrorType, ValidationException + +from .delay_metadata import DelayMetadata +from .feature import Feature +from .feature_transformation_code_metadata import FeatureTransformationCodeMetadata +from .source_metadata import SourceMetadata + + +class FeaturesetSpecMetadata(object): + """FeaturesetSpecMetadata for feature-set.""" + + def __init__( + self, + *, + source: SourceMetadata, + feature_transformation_code: Optional[FeatureTransformationCodeMetadata] = None, + features: List[Feature], + index_columns: Optional[List[DataColumn]] = None, + source_lookback: Optional[DelayMetadata] = None, + temporal_join_lookback: Optional[DelayMetadata] = None, + **_kwargs: Any, + ): + if source.type == "featureset" and index_columns: + msg = f"You cannot provide index_columns for {source.type} feature source." + raise ValidationException( + message=msg, + no_personal_data_message=msg, + error_type=ValidationErrorType.INVALID_VALUE, + target=ErrorTarget.FEATURE_SET, + error_category=ErrorCategory.USER_ERROR, + ) + if not index_columns and source.type != "featureset": + msg = f"You need to provide index_columns for {source.type} feature source." + raise ValidationException( + message=msg, + no_personal_data_message=msg, + error_type=ValidationErrorType.INVALID_VALUE, + target=ErrorTarget.FEATURE_SET, + error_category=ErrorCategory.USER_ERROR, + ) + self.source = source + self.feature_transformation_code = feature_transformation_code + self.features = features + self.index_columns = index_columns + self.source_lookback = source_lookback + self.temporal_join_lookback = temporal_join_lookback + + @classmethod + def load( + cls, + yaml_path: Union[PathLike, str], + **kwargs: Any, + ) -> "FeaturesetSpecMetadata": + """Construct an FeaturesetSpecMetadata object from yaml file. + + :param yaml_path: Path to a local file as the source. + :type yaml_path: PathLike | str + + :return: Constructed FeaturesetSpecMetadata object. + :rtype: FeaturesetSpecMetadata + """ + yaml_dict = load_yaml(yaml_path) + return cls._load(yaml_data=yaml_dict, yaml_path=yaml_path, **kwargs) + + @classmethod + def _load( + cls, + yaml_data: Optional[Dict], + yaml_path: Optional[Union[PathLike, str]], + **kwargs: Any, + ) -> "FeaturesetSpecMetadata": + yaml_data = yaml_data or {} + context = { + BASE_PATH_CONTEXT_KEY: Path(yaml_path).parent if yaml_path else Path("./"), + } + res: FeaturesetSpecMetadata = load_from_dict( + FeaturesetSpecMetadataSchema, yaml_data, context, "", unknown=INCLUDE, **kwargs + ) + + return res + + def _to_dict(self) -> Dict: + res: dict = FeaturesetSpecPropertiesSchema(context={BASE_PATH_CONTEXT_KEY: "./"}, unknown=INCLUDE).dump(self) + return res diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/materialization_compute_resource.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/materialization_compute_resource.py new file mode 100644 index 00000000..5bcff24b --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/materialization_compute_resource.py @@ -0,0 +1,41 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +from typing import Any, Optional + +from azure.ai.ml._restclient.v2023_10_01.models import ( + MaterializationComputeResource as RestMaterializationComputeResource, +) +from azure.ai.ml.entities._mixins import RestTranslatableMixin + + +class MaterializationComputeResource(RestTranslatableMixin): + """Materialization Compute resource + + :keyword instance_type: The compute instance type. + :paramtype instance_type: str + :param kwargs: A dictionary of additional configuration parameters. + :type kwargs: dict + + .. admonition:: Example: + + .. literalinclude:: ../samples/ml_samples_compute.py + :start-after: [START materialization_compute_resource] + :end-before: [END materialization_compute_resource] + :language: python + :dedent: 8 + :caption: Creating a MaterializationComputeResource object. + """ + + def __init__(self, *, instance_type: str, **kwargs: Any): # pylint: disable=unused-argument + self.instance_type = instance_type + + def _to_rest_object(self) -> RestMaterializationComputeResource: + return RestMaterializationComputeResource(instance_type=self.instance_type) + + @classmethod + def _from_rest_object(cls, obj: RestMaterializationComputeResource) -> Optional["MaterializationComputeResource"]: + if not obj: + return None + return MaterializationComputeResource(instance_type=obj.instance_type) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/materialization_settings.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/materialization_settings.py new file mode 100644 index 00000000..cf6f12e0 --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/materialization_settings.py @@ -0,0 +1,100 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +from typing import Any, Dict, Optional + +from azure.ai.ml._restclient.v2023_10_01.models import MaterializationSettings as RestMaterializationSettings +from azure.ai.ml._restclient.v2023_10_01.models import MaterializationStoreType +from azure.ai.ml.entities._feature_set.materialization_compute_resource import MaterializationComputeResource +from azure.ai.ml.entities._mixins import RestTranslatableMixin +from azure.ai.ml.entities._notification.notification import Notification +from azure.ai.ml.entities._schedule.trigger import RecurrenceTrigger + + +class MaterializationSettings(RestTranslatableMixin): + """Defines materialization settings. + + :keyword schedule: The schedule details. Defaults to None. + :paramtype schedule: Optional[~azure.ai.ml.entities.RecurrenceTrigger] + :keyword offline_enabled: Boolean that specifies if offline store is enabled. Defaults to None. + :paramtype offline_enabled: Optional[bool] + :keyword online_enabled: Boolean that specifies if online store is enabled. Defaults to None. + :paramtype online_enabled: Optional[bool] + :keyword notification: The notification details. Defaults to None. + :paramtype notification: Optional[~azure.ai.ml.entities.Notification] + :keyword resource: The compute resource settings. Defaults to None. + :paramtype resource: Optional[~azure.ai.ml.entities.MaterializationComputeResource] + :keyword spark_configuration: The spark compute settings. Defaults to None. + :paramtype spark_configuration: Optional[dict[str, str]] + :param kwargs: A dictionary of additional configuration parameters. + :type kwargs: dict + + .. admonition:: Example: + + .. literalinclude:: ../samples/ml_samples_spark_configurations.py + :start-after: [START materialization_setting_configuration] + :end-before: [END materialization_setting_configuration] + :language: python + :dedent: 8 + :caption: Configuring MaterializationSettings. + """ + + def __init__( + self, + *, + schedule: Optional[RecurrenceTrigger] = None, + offline_enabled: Optional[bool] = None, + online_enabled: Optional[bool] = None, + notification: Optional[Notification] = None, + resource: Optional[MaterializationComputeResource] = None, + spark_configuration: Optional[Dict[str, str]] = None, + # pylint: disable=unused-argument + **kwargs: Any, + ) -> None: + self.schedule = schedule + self.offline_enabled = offline_enabled + self.online_enabled = online_enabled + self.notification = notification + self.resource = resource + self.spark_configuration = spark_configuration + + def _to_rest_object(self) -> RestMaterializationSettings: + store_type = None + if self.offline_enabled and self.online_enabled: + store_type = MaterializationStoreType.ONLINE_AND_OFFLINE + elif self.offline_enabled: + store_type = MaterializationStoreType.OFFLINE + elif self.online_enabled: + store_type = MaterializationStoreType.ONLINE + else: + store_type = MaterializationStoreType.NONE + + return RestMaterializationSettings( + schedule=self.schedule._to_rest_object() if self.schedule else None, # pylint: disable=protected-access + notification=( + self.notification._to_rest_object() if self.notification else None # pylint: disable=protected-access + ), + resource=self.resource._to_rest_object() if self.resource else None, # pylint: disable=protected-access + spark_configuration=self.spark_configuration, + store_type=store_type, + ) + + @classmethod + def _from_rest_object(cls, obj: RestMaterializationSettings) -> Optional["MaterializationSettings"]: + if not obj: + return None + return MaterializationSettings( + schedule=( + RecurrenceTrigger._from_rest_object(obj.schedule) # pylint: disable=protected-access + if obj.schedule + else None + ), + notification=Notification._from_rest_object(obj.notification), # pylint: disable=protected-access + resource=MaterializationComputeResource._from_rest_object(obj.resource), # pylint: disable=protected-access + spark_configuration=obj.spark_configuration, + offline_enabled=obj.store_type + in {MaterializationStoreType.OFFLINE, MaterializationStoreType.ONLINE_AND_OFFLINE}, + online_enabled=obj.store_type + in {MaterializationStoreType.ONLINE, MaterializationStoreType.ONLINE_AND_OFFLINE}, + ) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/materialization_type.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/materialization_type.py new file mode 100644 index 00000000..912d69fc --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/materialization_type.py @@ -0,0 +1,14 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +from enum import Enum + +from azure.core import CaseInsensitiveEnumMeta + + +class MaterializationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Materialization Type Enum""" + + RECURRENT_MATERIALIZATION = 1 + BACKFILL_MATERIALIZATION = 2 diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/source_metadata.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/source_metadata.py new file mode 100644 index 00000000..1c9e55fe --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/source_metadata.py @@ -0,0 +1,69 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +# pylint: disable=redefined-builtin,disable=unused-argument + +from typing import Any, Dict, Optional + +from azure.ai.ml.entities._feature_set.source_process_code_metadata import SourceProcessCodeMetadata +from azure.ai.ml.exceptions import ErrorCategory, ErrorTarget, ValidationErrorType, ValidationException + +from .delay_metadata import DelayMetadata +from .timestamp_column_metadata import TimestampColumnMetadata + + +class SourceMetadata(object): + def __init__( + self, + *, + type: str, + timestamp_column: Optional[TimestampColumnMetadata] = None, + path: Optional[str] = None, + source_delay: Optional[DelayMetadata] = None, + source_process_code: Optional[SourceProcessCodeMetadata] = None, + dict: Optional[Dict] = None, + **kwargs: Any, + ): + if type == "custom": + # For custom feature source + # Required: timestamp_column, dict and source_process_code. + # Not support: path. + if path: + self.throw_exception("path", type, should_provide=False) + if not (timestamp_column and dict and source_process_code): + self.throw_exception("timestamp_column/dict/source_process_code", type, should_provide=True) + elif type == "featureset": + # For featureset feature source + # Required: path. + # Not support: timestamp_column, source_delay and source_process_code. + if timestamp_column or source_delay or source_process_code: + self.throw_exception("timestamp_column/source_delay/source_process_code", type, should_provide=False) + if not path: + self.throw_exception("path", type, should_provide=True) + else: + # For other type feature source + # Required: timestamp_column, path. + # Not support: source_process_code, dict + if dict or source_process_code: + self.throw_exception("dict/source_process_code", type, should_provide=False) + if not (timestamp_column and path): + self.throw_exception("timestamp_column/path", type, should_provide=True) + self.type = type + self.path = path + self.timestamp_column = timestamp_column + self.source_delay = source_delay + self.source_process_code = source_process_code + self.kwargs = dict + + @staticmethod + def throw_exception(property_names: str, type: str, should_provide: bool): + should_or_not = "need to" if should_provide else "cannot" + msg = f"You {should_or_not} provide {property_names} for {type} feature source." + raise ValidationException( + message=msg, + no_personal_data_message=msg, + error_type=ValidationErrorType.INVALID_VALUE, + target=ErrorTarget.FEATURE_SET, + error_category=ErrorCategory.USER_ERROR, + ) diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/source_process_code_metadata.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/source_process_code_metadata.py new file mode 100644 index 00000000..415785da --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/source_process_code_metadata.py @@ -0,0 +1,13 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +# pylint: disable=unused-argument + +from typing import Any, Optional + + +class SourceProcessCodeMetadata(object): + def __init__(self, *, path: str, process_class: Optional[str] = None, **kwargs: Any): + self.path = path + self.process_class = process_class diff --git a/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/timestamp_column_metadata.py b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/timestamp_column_metadata.py new file mode 100644 index 00000000..833088af --- /dev/null +++ b/.venv/lib/python3.12/site-packages/azure/ai/ml/entities/_feature_set/timestamp_column_metadata.py @@ -0,0 +1,14 @@ +# --------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# --------------------------------------------------------- + +# pylint: disable=redefined-builtin,disable=unused-argument + + +from typing import Any, Optional + + +class TimestampColumnMetadata(object): + def __init__(self, *, name: str, format: Optional[str] = None, **kwargs: Any): + self.name = name + self.format = format |