def test_deprecated_class():
    class A:
        pass

    B = deprecated_class(A, "foo")
    with pytest.warns(DeprecationWarning):
        B()
        production_variants = endpoint_config["ProductionVariants"]
        return [d["ModelName"] for d in production_variants]

    @property
    def content_type(self):
        """The MIME type of the data sent to the inference endpoint."""
        return self.serializer.CONTENT_TYPE

    @property
    def accept(self):
        """The content type(s) that are expected from the inference endpoint."""
        return self.deserializer.ACCEPT

    @property
    def endpoint(self):
        """Deprecated attribute. Please use endpoint_name."""
        renamed_warning("The endpoint attribute")
        return self.endpoint_name


csv_serializer = deprecated_serialize(CSVSerializer(), "csv_serializer")
json_serializer = deprecated_serialize(JSONSerializer(), "json_serializer")
npy_serializer = deprecated_serialize(NumpySerializer(), "npy_serializer")
csv_deserializer = deprecated_deserialize(CSVDeserializer(),
                                          "csv_deserializer")
json_deserializer = deprecated_deserialize(JSONDeserializer(),
                                           "json_deserializer")
numpy_deserializer = deprecated_deserialize(NumpyDeserializer(),
                                            "numpy_deserializer")
RealTimePredictor = deprecated_class(Predictor, "RealTimePredictor")
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
#     http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
"""Deprecated module."""
from __future__ import absolute_import

from sagemaker.deprecations import deprecated_class
from sagemaker.tensorflow.model import (
    TensorFlowModel,
    TensorFlowPredictor,
)

Model = deprecated_class(TensorFlowModel, "sagemaker.tensorflow.serving.Model")
Predictor = deprecated_class(TensorFlowPredictor,
                             "sagemaker.tensorflow.serving.Predictor")
        try:
            (read_kmagic, ) = struct.unpack("I", f.read(4))
        except struct.error:
            return
        assert read_kmagic == _kmagic
        (len_record, ) = struct.unpack("I", f.read(4))
        pad = (((len_record + 3) >> 2) << 2) - len_record
        yield f.read(len_record)
        if pad:
            f.read(pad)


def _resolve_type(dtype):
    """
    Args:
        dtype:
    """
    if dtype == np.dtype(int):
        return "Int32"
    if dtype == np.dtype(float):
        return "Float64"
    if dtype == np.dtype("float32"):
        return "Float32"
    raise ValueError("Unsupported dtype {} on array".format(dtype))


numpy_to_record_serializer = deprecated_class(RecordSerializer,
                                              "numpy_to_record_serializer")
record_deserializer = deprecated_class(RecordDeserializer,
                                       "record_deserializer")
Beispiel #5
0
        steps.append(register_model_step)
        self.steps = steps

        # TODO: add public document link here once ready
        warnings.warn(
            (
                "We are deprecating the use of RegisterModel. "
                "Instead, please use the ModelStep, which simply takes in the step arguments "
                "generated by model.register()."
            ),
            DeprecationWarning,
        )


RegisterModel = deprecated_class(RegisterModel, "RegisterModel")


class EstimatorTransformer(StepCollection):
    """Creates a Transformer step collection for workflow."""

    def __init__(
        self,
        name: str,
        estimator: EstimatorBase,
        model_data,
        model_inputs,
        instance_count,
        instance_type,
        transform_inputs,
        description: str = None,
    Attributes:
        step (Step): The step from which to get the property file.
        property_file (Union[PropertyFile, str]): Either a PropertyFile instance
            or the name of a property file.
        json_path (str): The JSON path expression to the requested value.
    """

    step: Step = attr.ib()
    property_file: Union[PropertyFile, str] = attr.ib()
    json_path: str = attr.ib()

    @property
    def expr(self):
        """The expression dict for a `JsonGet` function."""
        if isinstance(self.property_file, PropertyFile):
            name = self.property_file.name
        else:
            name = self.property_file
        return {
            "Std:JsonGet": {
                "PropertyFile": {
                    "Get": f"Steps.{self.step.name}.PropertyFiles.{name}"
                },
                "Path": self.json_path,
            }
        }


JsonGet = deprecated_class(JsonGet, "JsonGet")