Skip to content

Support optional input channels in local mode. #466

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 3 commits into from
Nov 9, 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
==========

* doc-fix: fix rendering error in README.rst
* enhancement: Local Mode: support optional input channels
* build: added pylint

1.14.1
Expand Down
1 change: 0 additions & 1 deletion src/sagemaker/local/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ def write_config_files(self, host, hyperparameters, input_data_config):
'hosts': self.hosts
}

print(input_data_config)
json_input_data_config = {}
for c in input_data_config:
channel_name = c['ChannelName']
Expand Down
6 changes: 3 additions & 3 deletions src/sagemaker/local/local_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def __init__(self, sagemaker_session=None):
"""
self.sagemaker_session = sagemaker_session or LocalSession()

def create_training_job(self, TrainingJobName, AlgorithmSpecification, InputDataConfig, OutputDataConfig,
ResourceConfig, **kwargs):
def create_training_job(self, TrainingJobName, AlgorithmSpecification, OutputDataConfig,
ResourceConfig, InputDataConfig=None, **kwargs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the first line of this method becomes

InputDataConfig = InputDataConfig or {}

Then you don't need to actually touch any other part of the code as all the for loops will just not happen.

"""
Create a training job in Local Mode
Args:
Expand All @@ -66,7 +66,7 @@ def create_training_job(self, TrainingJobName, AlgorithmSpecification, InputData
HyperParameters (dict) [optional]: Specifies these algorithm-specific parameters to influence the quality of
the final model.
"""

InputDataConfig = InputDataConfig or {}
container = _SageMakerContainer(ResourceConfig['InstanceType'], ResourceConfig['InstanceCount'],
AlgorithmSpecification['TrainingImage'], self.sagemaker_session)
training_job = _LocalTrainingJob(container)
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/test_local_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def test_create_training_job(train, LocalSession):
resource_config = {'InstanceType': 'local', 'InstanceCount': instance_count}
hyperparameters = {'a': 1, 'b': 'bee'}

local_sagemaker_client.create_training_job('my-training-job', algo_spec, input_data_config,
output_data_config, resource_config, HyperParameters=hyperparameters)
local_sagemaker_client.create_training_job('my-training-job', algo_spec, output_data_config, resource_config,
InputDataConfig=input_data_config, HyperParameters=hyperparameters)

expected = {
'ResourceConfig': {'InstanceCount': instance_count},
Expand Down Expand Up @@ -111,8 +111,8 @@ def test_create_training_job_invalid_data_source(train, LocalSession):
hyperparameters = {'a': 1, 'b': 'bee'}

with pytest.raises(ValueError):
local_sagemaker_client.create_training_job('my-training-job', algo_spec, input_data_config,
output_data_config, resource_config, HyperParameters=hyperparameters)
local_sagemaker_client.create_training_job('my-training-job', algo_spec, output_data_config, resource_config,
InputDataConfig=input_data_config, HyperParameters=hyperparameters)


@patch('sagemaker.local.image._SageMakerContainer.train', return_value="/some/path/to/model")
Expand Down Expand Up @@ -141,8 +141,8 @@ def test_create_training_job_not_fully_replicated(train, LocalSession):
hyperparameters = {'a': 1, 'b': 'bee'}

with pytest.raises(RuntimeError):
local_sagemaker_client.create_training_job('my-training-job', algo_spec, input_data_config,
output_data_config, resource_config, HyperParameters=hyperparameters)
local_sagemaker_client.create_training_job('my-training-job', algo_spec, output_data_config, resource_config,
InputDataConfig=input_data_config, HyperParameters=hyperparameters)


@patch('sagemaker.local.local_session.LocalSession')
Expand Down