-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feature: support Endpoint_type for TF transform #881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
0bd044c
Merge pull request #1 from aws/master
caxiaohu e3a34ea
Add endpoint_type support for TF transform
caxiaohu 12b5831
change: feedback
caxiaohu e687974
change back
caxiaohu 52292c5
change: minor changes based on feedback
caxiaohu 624c919
Merge branch 'master' into master
caxiaohu 0fa2a13
delete unimportant args
caxiaohu 356c5d1
change styling
caxiaohu a468d36
Merge pull request #2 from aws/master
caxiaohu 8b02fbb
change: refactor endpoint support for TF transformer
caxiaohu 20e52b9
change: update import modules
caxiaohu 9ea1785
Merge branch 'master' into master
caxiaohu 0c30c9e
change: fixed building failure
caxiaohu b42791d
change: merge to my branch
caxiaohu 7834d39
change: patch transformer function
caxiaohu b174e4e
change: change styles
caxiaohu e3081af
change: update
caxiaohu e695bb9
change: merge from aws master
caxiaohu f2ba96d
change: remove some arguments from creating model in testing
caxiaohu 373d850
Merge branch 'master' into master
laurenyu e490511
Merge branch 'master' into master
laurenyu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,11 +19,13 @@ | |
import pytest | ||
from mock import patch, Mock, MagicMock | ||
|
||
from sagemaker.estimator import _TrainingJob | ||
from sagemaker.fw_utils import create_image_uri | ||
from sagemaker.model import MODEL_SERVER_WORKERS_PARAM_NAME | ||
from sagemaker.session import s3_input | ||
from sagemaker.tensorflow import defaults, TensorFlow, TensorFlowModel, TensorFlowPredictor | ||
import sagemaker.tensorflow.estimator as tfe | ||
from sagemaker.transformer import Transformer | ||
|
||
DATA_DIR = os.path.join(os.path.dirname(__file__), '..', 'data') | ||
SCRIPT_FILE = 'dummy_script.py' | ||
|
@@ -264,12 +266,57 @@ def test_create_model_with_optional_params(sagemaker_session): | |
vpc_config = {'Subnets': ['foo'], 'SecurityGroupIds': ['bar']} | ||
model = tf.create_model(role=new_role, model_server_workers=model_server_workers, | ||
vpc_config_override=vpc_config) | ||
|
||
assert model.role == new_role | ||
assert model.model_server_workers == model_server_workers | ||
assert model.vpc_config == vpc_config | ||
|
||
|
||
@patch('sagemaker.tensorflow.estimator.TensorFlow._create_tfs_model') | ||
def test_transformer_creation_with_endpoint_type(create_tfs_model, sagemaker_session): | ||
container_log_level = '"logging.INFO"' | ||
source_dir = 's3://mybucket/source' | ||
enable_cloudwatch_metrics = 'true' | ||
base_name = 'foo' | ||
tf = TensorFlow(entry_point=SCRIPT_PATH, role=ROLE, sagemaker_session=sagemaker_session, | ||
training_steps=1000, evaluation_steps=10, train_instance_count=INSTANCE_COUNT, | ||
train_instance_type=INSTANCE_TYPE, container_log_level=container_log_level, base_job_name=base_name, | ||
source_dir=source_dir, enable_cloudwatch_metrics=enable_cloudwatch_metrics) | ||
tf.latest_training_job = _TrainingJob(sagemaker_session, JOB_NAME) | ||
assert isinstance(tf, TensorFlow) | ||
transformer = tf.transformer(INSTANCE_COUNT, INSTANCE_TYPE, endpoint_type='tensorflow-serving') | ||
create_tfs_model.assert_called_once() | ||
assert isinstance(transformer, Transformer) | ||
assert transformer.sagemaker_session == sagemaker_session | ||
assert transformer.instance_count == INSTANCE_COUNT | ||
assert transformer.instance_type == INSTANCE_TYPE | ||
assert transformer.tags is None | ||
assert tf.script_mode is True | ||
assert tf._script_mode_enabled() is True | ||
|
||
|
||
@patch('sagemaker.tensorflow.estimator.TensorFlow._create_default_model') | ||
def test_transformer_creation_without_endpoint_type(create_default_model, sagemaker_session): | ||
container_log_level = '"logging.INFO"' | ||
source_dir = 's3://mybucket/source' | ||
enable_cloudwatch_metrics = 'true' | ||
base_name = 'flo' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if these aren't being checked later, then there's no need to define them. I'd recommend specifying only the required args for |
||
tf = TensorFlow(entry_point=SCRIPT_PATH, role=ROLE, sagemaker_session=sagemaker_session, | ||
training_steps=1000, evaluation_steps=10, train_instance_count=INSTANCE_COUNT, | ||
train_instance_type=INSTANCE_TYPE, container_log_level=container_log_level, base_job_name=base_name, | ||
source_dir=source_dir, enable_cloudwatch_metrics=enable_cloudwatch_metrics) | ||
tf.latest_training_job = _TrainingJob(sagemaker_session, JOB_NAME) | ||
assert isinstance(tf, TensorFlow) | ||
transformer = tf.transformer(INSTANCE_COUNT, INSTANCE_TYPE) | ||
create_default_model.assert_called_once() | ||
assert isinstance(transformer, Transformer) | ||
assert transformer.sagemaker_session == sagemaker_session | ||
assert transformer.instance_count == INSTANCE_COUNT | ||
assert transformer.instance_type == INSTANCE_TYPE | ||
assert transformer.tags is None | ||
assert tf.script_mode is False | ||
assert tf._script_mode_enabled() is False | ||
|
||
|
||
def test_create_model_with_custom_image(sagemaker_session): | ||
container_log_level = '"logging.INFO"' | ||
source_dir = 's3://mybucket/source' | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the purpose of this line?