-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: check optional keyword before accessing #1911
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 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f3027ca
fix: check optional keyword before accessing
2d53da5
Merge branch 'master' into network-config-keyword
icywang86rui 856dde2
refactor attach method
21c0bcb
Merge branch 'network-config-keyword' of github.com:ChuyangDeng/sagem…
b0e069b
Merge branch 'master' into network-config-keyword
chuyang-deng af618c1
Merge branch 'master' into network-config-keyword
chuyang-deng 0b5032c
Merge branch 'master' into network-config-keyword
ajaykarpur 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 | ||||
---|---|---|---|---|---|---|
|
@@ -63,6 +63,31 @@ | |||||
) | ||||||
"encrypt_inter_container_traffic=None when creating your NetworkConfig object." | ||||||
|
||||||
MONITORING_SCHEDULE_DESC = { | ||||||
"MonitoringScheduleArn": "arn:aws:monitoring-schedule", | ||||||
"MonitoringScheduleName": "my-monitoring-schedule", | ||||||
"MonitoringScheduleConfig": { | ||||||
"MonitoringJobDefinition": { | ||||||
"MonitoringOutputConfig": {}, | ||||||
"MonitoringResources": { | ||||||
"ClusterConfig": { | ||||||
"InstanceCount": 1, | ||||||
"InstanceType": "ml.t3.medium", | ||||||
"VolumeSizeInGB": 8, | ||||||
} | ||||||
}, | ||||||
"MonitoringAppSpecification": { | ||||||
"ImageUri": "image-uri", | ||||||
"ContainerEntrypoint": [ | ||||||
"entrypoint.py", | ||||||
], | ||||||
}, | ||||||
"RoleArn": ROLE, | ||||||
} | ||||||
}, | ||||||
"EndpointName": "my-endpoint", | ||||||
} | ||||||
|
||||||
|
||||||
# TODO-reinvent-2019: Continue to flesh these out. | ||||||
@pytest.fixture() | ||||||
|
@@ -80,6 +105,9 @@ def sagemaker_session(): | |||||
name="upload_data", return_value="mocked_s3_uri_from_upload_data" | ||||||
) | ||||||
session_mock.download_data = Mock(name="download_data") | ||||||
session_mock.describe_monitoring_schedule = Mock( | ||||||
name="describe_monitoring_schedule", return_value=MONITORING_SCHEDULE_DESC | ||||||
) | ||||||
return session_mock | ||||||
|
||||||
|
||||||
|
@@ -153,6 +181,17 @@ def test_default_model_monitor_with_invalid_network_config(sagemaker_session): | |||||
assert INTER_CONTAINER_ENCRYPTION_EXCEPTION_MSG in str(exception.value) | ||||||
|
||||||
|
||||||
def test_model_monitor_without_network_config(sagemaker_session): | ||||||
my_model_monitor = ModelMonitor( | ||||||
role=ROLE, | ||||||
image_uri=CUSTOM_IMAGE_URI, | ||||||
sagemaker_session=sagemaker_session, | ||||||
) | ||||||
model_monitor_schedule_name = "model-monitoring-without-netwotk-config" | ||||||
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.
Suggested change
|
||||||
attached = my_model_monitor.attach(model_monitor_schedule_name, sagemaker_session) | ||||||
assert attached.network_config is None | ||||||
|
||||||
|
||||||
def test_model_monitor_with_invalid_network_config(sagemaker_session): | ||||||
invalid_network_config = NetworkConfig(encrypt_inter_container_traffic=False) | ||||||
my_model_monitor = ModelMonitor( | ||||||
|
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.
should this be just
if network_config_dict is not None
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.
I would also put all the network_config parsing stuff in the same if block.
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.
That makes sense! I also refactored the
attach
method to make it more concise