|
13 | 13 | """Placeholder docstring"""
|
14 | 14 | from __future__ import print_function, absolute_import
|
15 | 15 |
|
| 16 | +import abc |
| 17 | +from typing import Any, Tuple |
| 18 | + |
16 | 19 | from sagemaker.deprecations import (
|
17 | 20 | deprecated_class,
|
18 | 21 | deprecated_deserialize,
|
|
51 | 54 | from sagemaker.lineage.context import EndpointContext
|
52 | 55 |
|
53 | 56 |
|
54 |
| -class Predictor(object): |
| 57 | +class PredictorBase(abc.ABC): |
| 58 | + """An object that encapsulates a deployed model.""" |
| 59 | + |
| 60 | + @abc.abstractmethod |
| 61 | + def predict(self, *args, **kwargs) -> Any: |
| 62 | + """Perform inference on the provided data and return a prediction.""" |
| 63 | + |
| 64 | + @abc.abstractmethod |
| 65 | + def destroy(self, *args, **kwargs) -> None: |
| 66 | + """Destroy resources associated with this predictor.""" |
| 67 | + |
| 68 | + @property |
| 69 | + @abc.abstractmethod |
| 70 | + def content_type(self) -> str: |
| 71 | + """The MIME type of the data sent to the inference server.""" |
| 72 | + |
| 73 | + @property |
| 74 | + @abc.abstractmethod |
| 75 | + def accept(self) -> Tuple[str]: |
| 76 | + """The content type(s) that are expected from the inference server.""" |
| 77 | + |
| 78 | + |
| 79 | +class Predictor(PredictorBase): |
55 | 80 | """Make prediction requests to an Amazon SageMaker endpoint."""
|
56 | 81 |
|
57 | 82 | def __init__(
|
@@ -305,6 +330,8 @@ def delete_endpoint(self, delete_endpoint_config=True):
|
305 | 330 |
|
306 | 331 | self.sagemaker_session.delete_endpoint(self.endpoint_name)
|
307 | 332 |
|
| 333 | + destroy = delete_endpoint |
| 334 | + |
308 | 335 | def delete_model(self):
|
309 | 336 | """Deletes the Amazon SageMaker models backing this predictor."""
|
310 | 337 | request_failed = False
|
|
0 commit comments