Skip to content

CachedEndpoint

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 SageWorks Model Class makes it a breeze!

CachedEndpoint: Caches the method results for SageWorks Endpoints

CachedEndpoint

Bases: CachedArtifactMixin, EndpointCore

CachedEndpoint: Caches the method results for SageWorks Endpoints

Note: Cached method values may lag underlying Endpoint changes.

Common Usage
my_endpoint = CachedEndpoint(name)
my_endpoint.details()
my_endpoint.health_check()
my_endpoint.sageworks_meta()
Source code in src/sageworks/cached/cached_endpoint.py
class CachedEndpoint(CachedArtifactMixin, EndpointCore):
    """CachedEndpoint: Caches the method results for SageWorks Endpoints

    Note: Cached method values may lag underlying Endpoint changes.

    Common Usage:
        ```python
        my_endpoint = CachedEndpoint(name)
        my_endpoint.details()
        my_endpoint.health_check()
        my_endpoint.sageworks_meta()
        ```
    """

    def __init__(self, endpoint_uuid: str):
        """CachedEndpoint Initialization"""
        EndpointCore.__init__(self, endpoint_uuid=endpoint_uuid, use_cached_meta=True)

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

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

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

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

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

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

    @CachedArtifactMixin.cache_result
    def sageworks_meta(self) -> Union[str, None]:
        """Retrieve the Enumerated Model Type (REGRESSOR, CLASSIFER, etc).

        Returns:
            str: The Enumerated Model Type
        """
        return super().sageworks_meta()

    @CachedArtifactMixin.cache_result
    def endpoint_metrics(self) -> Union[str, None]:
        """Retrieve the Endpoint Metrics

        Returns:
            str: The Endpoint Metrics
        """
        return super().endpoint_metrics()

__init__(endpoint_uuid)

CachedEndpoint Initialization

Source code in src/sageworks/cached/cached_endpoint.py
def __init__(self, endpoint_uuid: str):
    """CachedEndpoint Initialization"""
    EndpointCore.__init__(self, endpoint_uuid=endpoint_uuid, use_cached_meta=True)

details(**kwargs)

Retrieve the CachedEndpoint Details.

Returns:

Name Type Description
dict dict

A dictionary of details about the CachedEndpoint

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

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

endpoint_metrics()

Retrieve the Endpoint Metrics

Returns:

Name Type Description
str Union[str, None]

The Endpoint Metrics

Source code in src/sageworks/cached/cached_endpoint.py
@CachedArtifactMixin.cache_result
def endpoint_metrics(self) -> Union[str, None]:
    """Retrieve the Endpoint Metrics

    Returns:
        str: The Endpoint Metrics
    """
    return super().endpoint_metrics()

health_check(**kwargs)

Retrieve the CachedEndpoint Health Check.

Returns:

Name Type Description
dict dict

A dictionary of health check details for the CachedEndpoint

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

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

sageworks_meta()

Retrieve the Enumerated Model Type (REGRESSOR, CLASSIFER, etc).

Returns:

Name Type Description
str Union[str, None]

The Enumerated Model Type

Source code in src/sageworks/cached/cached_endpoint.py
@CachedArtifactMixin.cache_result
def sageworks_meta(self) -> Union[str, None]:
    """Retrieve the Enumerated Model Type (REGRESSOR, CLASSIFER, etc).

    Returns:
        str: The Enumerated Model Type
    """
    return super().sageworks_meta()

summary(**kwargs)

Retrieve the CachedEndpoint Details.

Returns:

Name Type Description
dict dict

A dictionary of details about the CachedEndpoint

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

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

Examples

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

Get Endpoint Details

from sageworks.cached.cached_endpoint import CachedEndpoint

# Grab an Endpoint
end = CachedEndpoint("abalone-regression")

# Get the Details
 end.details()

{'uuid': 'abalone-regression-end',
 'health_tags': [],
 'status': 'InService',
 'instance': 'Serverless (2GB/5)',
 'instance_count': '-',
 'variant': 'AllTraffic',
 'model_name': 'abalone-regression',
 'model_type': 'regressor',
 'model_metrics':        RMSE     R2    MAPE  MedAE  NumRows
 1.64  2.246  0.502  16.393  1.209      834,
 'confusion_matrix': None,
 'predictions':      class_number_of_rings  prediction    id
 0                       16   10.516158     7
 1                        9    9.031365     8
 2                       10    9.264600    17
 3                        7    8.578638    18
 4                       12   10.492446    27
 ..                     ...         ...   ...
 829                     11   11.915862  4148
 830                      8    8.210898  4157
 831                      8    7.693689  4158
 832                      9    7.542521  4167
 833                      8    9.060015  4168