Skip to content

Commit

Permalink
Merge pull request aws#3019 from joguSD/sagemaker-runtime
Browse files Browse the repository at this point in the history
Add alias to runtime.sagemaker for backwards compatibility
  • Loading branch information
joguSD authored Dec 12, 2017
2 parents b8ae78e + fe3d16c commit fc815d7
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/next-release/bugfix-sagemakerruntime-86051.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "sagemaker-runtime",
"description": "Renamed the runtime.sagemaker service to sagemaker-runtime to be more consistent with existing services. The old service name is now aliased to sagemaker-runtime to maintain backwards compatibility."
}
28 changes: 28 additions & 0 deletions awscli/customizations/sagemaker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2017 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.
from awscli.customizations.utils import make_hidden_command_alias


def register_alias_sagemaker_runtime_command(event_emitter):
event_emitter.register(
'building-command-table.main',
alias_sagemaker_runtime_command
)


def alias_sagemaker_runtime_command(command_table, **kwargs):
make_hidden_command_alias(
command_table,
existing_name='sagemaker-runtime',
alias_name='runtime.sagemaker',
)
2 changes: 2 additions & 0 deletions awscli/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
from awscli.customizations.waiters import register_add_waiters
from awscli.customizations.opsworkscm import register_alias_opsworks_cm
from awscli.customizations.mturk import register_alias_mturk_command
from awscli.customizations.sagemaker import register_alias_sagemaker_runtime_command
from awscli.customizations.servicecatalog import register_servicecatalog_commands


Expand Down Expand Up @@ -155,6 +156,7 @@ def awscli_initialize(event_handlers):
cloudformation_init(event_handlers)
register_alias_opsworks_cm(event_handlers)
register_alias_mturk_command(event_handlers)
register_alias_sagemaker_runtime_command(event_handlers)
register_servicecatalog_commands(event_handlers)
register_history_mode(event_handlers)
register_history_commands(event_handlers)
23 changes: 23 additions & 0 deletions tests/functional/sagemaker/test_alias.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2017 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.
from awscli.testutils import BaseAWSCommandParamsTest


class TestAlias(BaseAWSCommandParamsTest):
def test_alias(self):
# This command was aliased, both should work
command_template = '%s invoke-endpoint --endpoint-name foo --body bar f'
old_command = command_template % 'runtime.sagemaker'
new_command = command_template % 'sagemaker-runtime'
self.run_cmd(old_command, expected_rc=0)
self.run_cmd(new_command, expected_rc=0)

0 comments on commit fc815d7

Please sign in to comment.