Skip to content

Add integ tests for tuning jobs #220

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 4 commits into from
Jun 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CHANGELOG
========

* bug-fix: Unit Tests: Improve unit test runtime
* bug-fix: Estimators: Fix attach for LDA

1.4.1
=====
Expand Down
4 changes: 3 additions & 1 deletion src/sagemaker/amazon/lda.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ def __init__(self, role, train_instance_type, num_topics,
tol (float): Optional. Target error tolerance for the ALS phase of the algorithm.
**kwargs: base class keyword argument values.
"""

# this algorithm only supports single instance training
if kwargs.pop('train_instance_count', 1) != 1:
print('LDA only supports single instance training. Defaulting to 1 {}.'.format(train_instance_type))

super(LDA, self).__init__(role, 1, train_instance_type, **kwargs)
self.num_topics = num_topics
self.alpha0 = alpha0
Expand Down
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import boto3
import pytest
from botocore.config import Config

from sagemaker import Session
from sagemaker.local import LocalSession
Expand All @@ -32,7 +33,7 @@ def pytest_addoption(parser):
@pytest.fixture(scope='session')
def sagemaker_client_config(request):
config = request.config.getoption('--sagemaker-client-config')
return json.loads(config) if config else None
return json.loads(config) if config else dict()


@pytest.fixture(scope='session')
Expand All @@ -50,6 +51,7 @@ def boto_config(request):
@pytest.fixture(scope='session')
def sagemaker_session(sagemaker_client_config, sagemaker_runtime_config, boto_config):
boto_session = boto3.Session(**boto_config) if boto_config else boto3.Session(region_name=DEFAULT_REGION)
sagemaker_client_config.setdefault('config', Config(retries=dict(max_attempts=10)))
sagemaker_client = boto_session.client('sagemaker', **sagemaker_client_config) if sagemaker_client_config else None
runtime_client = (boto_session.client('sagemaker-runtime', **sagemaker_runtime_config) if sagemaker_runtime_config
else None)
Expand Down
3 changes: 2 additions & 1 deletion tests/data/chainer_mnist/mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def _preprocess_mnist(raw, withlabel, ndim, scale, image_dtype, label_dtype, rgb
parser.add_argument('--epochs', type=int, default=20)
parser.add_argument('--frequency', type=int, default=20)
parser.add_argument('--batch-size', type=int, default=100)
parser.add_argument('--alpha', type=float, default=0.001)
parser.add_argument('--model-dir', type=str, default=env.model_dir)

parser.add_argument('--train', type=str, default=env.channel_input_dirs['train'])
Expand Down Expand Up @@ -103,7 +104,7 @@ def _preprocess_mnist(raw, withlabel, ndim, scale, image_dtype, label_dtype, rgb
chainer.cuda.get_device_from_id(0).use()

# Setup an optimizer
optimizer = chainer.optimizers.Adam()
optimizer = chainer.optimizers.Adam(alpha=args.alpha)
optimizer.setup(model)

# Load the MNIST dataset
Expand Down
4 changes: 3 additions & 1 deletion tests/data/iris/iris-dnn-classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@


def estimator_fn(run_config, hyperparameters):
input_tensor_name = hyperparameters['input_tensor_name']
input_tensor_name = hyperparameters.get('input_tensor_name', 'inputs')
learning_rate = hyperparameters.get('learning_rate', 0.05)
feature_columns = [tf.feature_column.numeric_column(input_tensor_name, shape=[4])]
return tf.estimator.DNNClassifier(feature_columns=feature_columns,
hidden_units=[10, 20, 10],
optimizer=tf.train.AdagradOptimizer(learning_rate=learning_rate),
n_classes=3,
config=run_config)

Expand Down
Loading