Skip to content

Commit e2a0042

Browse files
author
Jonathan Esterhazy
committed
fix log-level and py3 tests, add copyright
1 parent ee741a5 commit e2a0042

File tree

6 files changed

+88
-12
lines changed

6 files changed

+88
-12
lines changed

src/sagemaker/cli/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.

src/sagemaker/cli/common.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
113
from __future__ import absolute_import
214

315
import json

src/sagemaker/cli/main.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
113
from __future__ import absolute_import
214

315
import argparse
@@ -10,6 +22,9 @@
1022

1123
logger = logging.getLogger(__name__)
1224

25+
DEFAULT_LOG_LEVEL = 'info'
26+
DEFAULT_BOTOCORE_LOG_LEVEL = 'warning'
27+
1328

1429
def parse_arguments(args):
1530
parser = argparse.ArgumentParser(description='Launch SageMaker training jobs or hosting endpoints')
@@ -29,10 +44,6 @@ def parse_arguments(args):
2944
instance_group.add_argument('--instance-type', type=str, help='instance type', default='ml.m4.xlarge')
3045
instance_group.add_argument('--instance-count', type=int, help='instance count', default=1)
3146

32-
log_group = common_parser.add_argument_group('optional log settings')
33-
log_group.add_argument('--log-level', help='log level for this command', type=str, default='info')
34-
log_group.add_argument('--botocore-log-level', help='log level for botocore', type=str, default='warning')
35-
3647
# common training args
3748
common_train_parser = argparse.ArgumentParser(add_help=False)
3849
common_train_parser.add_argument('--hyperparameters', help='path to training hyperparameters file',
@@ -73,6 +84,11 @@ def parse_arguments(args):
7384
parents=[common_parser, common_host_parser])
7485
tensorflow_host_parser.set_defaults(func=sagemaker.cli.tensorflow.host)
7586

87+
log_group = parser.add_argument_group('optional log settings')
88+
log_group.add_argument('--log-level', help='log level for this command', type=str, default=DEFAULT_LOG_LEVEL)
89+
log_group.add_argument('--botocore-log-level', help='log level for botocore', type=str,
90+
default=DEFAULT_BOTOCORE_LOG_LEVEL)
91+
7692
return parser.parse_args(args)
7793

7894

src/sagemaker/cli/mxnet.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
113
from sagemaker.cli.common import HostCommand, TrainCommand
214

315

src/sagemaker/cli/tensorflow.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
113
from sagemaker.cli.common import HostCommand, TrainCommand
214

315

tests/unit/test_cli.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
113
import pytest
214
import sagemaker.cli.main as cli
315
from mock import patch
@@ -62,8 +74,8 @@ def test_args_mxnet_train_defaults():
6274

6375

6476
def test_args_mxnet_train_non_defaults():
65-
args = cli.parse_arguments('mxnet train --role-name role {} {} {}'
66-
.format(COMMON_ARGS, TRAIN_ARGS, LOG_ARGS)
77+
args = cli.parse_arguments('{} mxnet train --role-name role {} {}'
78+
.format(LOG_ARGS, COMMON_ARGS, TRAIN_ARGS)
6779
.split())
6880
assert_common_non_defaults(args)
6981
assert_train_non_defaults(args)
@@ -80,8 +92,8 @@ def test_args_mxnet_host_defaults():
8092

8193

8294
def test_args_mxnet_host_non_defaults():
83-
args = cli.parse_arguments('mxnet host --role-name role {} {} {}'
84-
.format(COMMON_ARGS, HOST_ARGS, LOG_ARGS)
95+
args = cli.parse_arguments('{} mxnet host --role-name role {} {}'
96+
.format(LOG_ARGS, COMMON_ARGS, HOST_ARGS)
8597
.split())
8698
assert_common_non_defaults(args)
8799
assert_host_non_defaults(args)
@@ -100,8 +112,8 @@ def test_args_tensorflow_train_defaults():
100112

101113

102114
def test_args_tensorflow_train_non_defaults():
103-
args = cli.parse_arguments('tensorflow train --role-name role --training-steps 10 --evaluation-steps 5 {} {} {}'
104-
.format(COMMON_ARGS, TRAIN_ARGS, LOG_ARGS)
115+
args = cli.parse_arguments('{} tensorflow train --role-name role --training-steps 10 --evaluation-steps 5 {} {}'
116+
.format(LOG_ARGS, COMMON_ARGS, TRAIN_ARGS)
105117
.split())
106118
assert_common_non_defaults(args)
107119
assert_train_non_defaults(args)
@@ -120,8 +132,8 @@ def test_args_tensorflow_host_defaults():
120132

121133

122134
def test_args_tensorflow_host_non_defaults():
123-
args = cli.parse_arguments('tensorflow host --role-name role {} {} {}'
124-
.format(COMMON_ARGS, HOST_ARGS, LOG_ARGS)
135+
args = cli.parse_arguments('{} tensorflow host --role-name role {} {}'
136+
.format(LOG_ARGS, COMMON_ARGS, HOST_ARGS)
125137
.split())
126138
assert_common_non_defaults(args)
127139
assert_host_non_defaults(args)

0 commit comments

Comments
 (0)