'aws sagemaker cannot import TensorFlowModel

from sagemaker.tensorflow import TensorFlowModel

throws

ImportError: cannot import name 'is_pipeline_variable' from 'sagemaker.workflow'

full error stack is:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-54-e8eac6a9c02f> in <module>
----> 1 from sagemaker.tensorflow import TensorFlowModel

/opt/conda/lib/python3.7/site-packages/sagemaker/tensorflow/__init__.py in <module>
     14 from __future__ import absolute_import
     15 
---> 16 from sagemaker.tensorflow.estimator import TensorFlow  # noqa: F401 (imported but unused)
     17 from sagemaker.tensorflow.model import TensorFlowModel, TensorFlowPredictor  # noqa: F401
     18 from sagemaker.tensorflow.processing import TensorFlowProcessor  # noqa: F401

/opt/conda/lib/python3.7/site-packages/sagemaker/tensorflow/estimator.py in <module>
     23 import sagemaker.fw_utils as fw
     24 from sagemaker.tensorflow import defaults
---> 25 from sagemaker.tensorflow.model import TensorFlowModel
     26 from sagemaker.transformer import Transformer
     27 from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT

/opt/conda/lib/python3.7/site-packages/sagemaker/tensorflow/model.py in <module>
     22 from sagemaker.predictor import Predictor
     23 from sagemaker.serializers import JSONSerializer
---> 24 from sagemaker.workflow import is_pipeline_variable
     25 
     26 

ImportError: cannot import name 'is_pipeline_variable' from 'sagemaker.workflow' (/opt/conda/lib/python3.7/site-packages/sagemaker/workflow/__init__.py)

following amazon's own documentation here: https://aws.amazon.com/blogs/machine-learning/deploy-trained-keras-or-tensorflow-models-using-amazon-sagemaker/

trying to accommodate the v2 api change documented here: https://sagemaker.readthedocs.io/en/stable/v2.html

TensorFlow Serving Model

sagemaker.tensorflow.serving.Model has been renamed to sagemaker.tensorflow.model.TensorFlowModel. (For the previous implementation of that class, see Remove Legacy TensorFlow).


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source