Skip to content

CachedFeatureSet

Model Examples

Examples of using the Model Class are in the Examples section at the bottom of this page. AWS Model setup and deployment are quite complicated to do manually but the Workbench Model Class makes it a breeze!

CachedFeatureSet: Caches the method results for Workbench FeatureSets

CachedFeatureSet

Bases: CachedArtifactMixin, FeatureSetCore

CachedFeatureSet: Caches the method results for Workbench FeatureSets

Note: Cached method values may lag underlying FeatureSet changes.

Common Usage
my_features = CachedFeatureSet(name)
my_features.details()
my_features.health_check()
my_features.workbench_meta()
Source code in src/workbench/cached/cached_feature_set.py
class CachedFeatureSet(CachedArtifactMixin, FeatureSetCore):
    """CachedFeatureSet: Caches the method results for Workbench FeatureSets

    Note: Cached method values may lag underlying FeatureSet changes.

    Common Usage:
        ```python
        my_features = CachedFeatureSet(name)
        my_features.details()
        my_features.health_check()
        my_features.workbench_meta()
        ```
    """

    def __init__(self, feature_set_uuid: str, database: str = "workbench"):
        """CachedFeatureSet Initialization"""
        FeatureSetCore.__init__(self, feature_set_uuid=feature_set_uuid, use_cached_meta=True)

    @CachedArtifactMixin.cache_result
    def summary(self, **kwargs) -> dict:
        """Retrieve the FeatureSet Details.

        Returns:
            dict: A dictionary of details about the FeatureSet
        """
        return super().summary(**kwargs)

    @CachedArtifactMixin.cache_result
    def details(self, **kwargs) -> dict:
        """Retrieve the FeatureSet Details.

        Returns:
            dict: A dictionary of details about the FeatureSet
        """
        return super().details(**kwargs)

    @CachedArtifactMixin.cache_result
    def health_check(self, **kwargs) -> dict:
        """Retrieve the FeatureSet Health Check.

        Returns:
            dict: A dictionary of health check details for the FeatureSet
        """
        return super().health_check(**kwargs)

    @CachedArtifactMixin.cache_result
    def workbench_meta(self) -> Union[str, None]:
        """Retrieve the Workbench Metadata for this DataSource.

        Returns:
            Union[dict, None]: Dictionary of Workbench metadata for this Artifact
        """
        return super().workbench_meta()

    @CachedArtifactMixin.cache_result
    def smart_sample(self) -> pd.DataFrame:
        """Retrieve the Smart Sample for this FeatureSet.

        Returns:
            pd.DataFrame: The Smart Sample DataFrame
        """
        return super().smart_sample(recompute=False)

__init__(feature_set_uuid, database='workbench')

CachedFeatureSet Initialization

Source code in src/workbench/cached/cached_feature_set.py
def __init__(self, feature_set_uuid: str, database: str = "workbench"):
    """CachedFeatureSet Initialization"""
    FeatureSetCore.__init__(self, feature_set_uuid=feature_set_uuid, use_cached_meta=True)

details(**kwargs)

Retrieve the FeatureSet Details.

Returns:

Name Type Description
dict dict

A dictionary of details about the FeatureSet

Source code in src/workbench/cached/cached_feature_set.py
@CachedArtifactMixin.cache_result
def details(self, **kwargs) -> dict:
    """Retrieve the FeatureSet Details.

    Returns:
        dict: A dictionary of details about the FeatureSet
    """
    return super().details(**kwargs)

health_check(**kwargs)

Retrieve the FeatureSet Health Check.

Returns:

Name Type Description
dict dict

A dictionary of health check details for the FeatureSet

Source code in src/workbench/cached/cached_feature_set.py
@CachedArtifactMixin.cache_result
def health_check(self, **kwargs) -> dict:
    """Retrieve the FeatureSet Health Check.

    Returns:
        dict: A dictionary of health check details for the FeatureSet
    """
    return super().health_check(**kwargs)

smart_sample()

Retrieve the Smart Sample for this FeatureSet.

Returns:

Type Description
DataFrame

pd.DataFrame: The Smart Sample DataFrame

Source code in src/workbench/cached/cached_feature_set.py
@CachedArtifactMixin.cache_result
def smart_sample(self) -> pd.DataFrame:
    """Retrieve the Smart Sample for this FeatureSet.

    Returns:
        pd.DataFrame: The Smart Sample DataFrame
    """
    return super().smart_sample(recompute=False)

summary(**kwargs)

Retrieve the FeatureSet Details.

Returns:

Name Type Description
dict dict

A dictionary of details about the FeatureSet

Source code in src/workbench/cached/cached_feature_set.py
@CachedArtifactMixin.cache_result
def summary(self, **kwargs) -> dict:
    """Retrieve the FeatureSet Details.

    Returns:
        dict: A dictionary of details about the FeatureSet
    """
    return super().summary(**kwargs)

workbench_meta()

Retrieve the Workbench Metadata for this DataSource.

Returns:

Type Description
Union[str, None]

Union[dict, None]: Dictionary of Workbench metadata for this Artifact

Source code in src/workbench/cached/cached_feature_set.py
@CachedArtifactMixin.cache_result
def workbench_meta(self) -> Union[str, None]:
    """Retrieve the Workbench Metadata for this DataSource.

    Returns:
        Union[dict, None]: Dictionary of Workbench metadata for this Artifact
    """
    return super().workbench_meta()

Examples

All of the Workbench Examples are in the Workbench Repository under the examples/ directory. For a full code listing of any example please visit our Workbench Examples

Pull FeatureSet Details

from workbench.cached.cached_feature_set import CachedFeatureSet

# Grab a FeatureSet
fs = CachedFeatureSet("abalone_features")

# Show the details
fs.details()

> fs.details()

{'uuid': 'abalone_features',
 'health_tags': [],
 'aws_arn': 'arn:aws:glue:x:table/workbench/abalone_data',
 'size': 0.070272,
 'created': '2024-11-09T20:42:34.000Z',
 'modified': '2024-11-10T19:57:52.000Z',
 'input': 's3://workbench-public-data/common/aBaLone.CSV',
 'workbench_health_tags': '',
 'workbench_correlations': {'length': {'diameter': 0.9868115846024996,