Skip to content

Refactor LocalSageMakerClient #375

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 10 commits into from
Sep 26, 2018
Merged

Conversation

iquintero
Copy link
Contributor

@iquintero iquintero commented Aug 31, 2018

local sagemakerclient was not very useful beyond creating a single
estimator/endpoint. doing workflows such as training and later creating
and endpoint was really awkward.

These changes make it both resemble the API a bit more and allow
persisting objects across LocalSessions. This is important because most
of the time the SDK classes create sessions behind the scenes.

Issue #, if available:

Description of changes:

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have updated the changelog with a description of my changes (if appropriate)
  • I have updated any necessary documentation (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-io
Copy link

codecov-io commented Aug 31, 2018

Codecov Report

Merging #375 into master will decrease coverage by 0.03%.
The diff coverage is 90.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #375      +/-   ##
==========================================
- Coverage   92.99%   92.96%   -0.04%     
==========================================
  Files          51       52       +1     
  Lines        3568     3652      +84     
==========================================
+ Hits         3318     3395      +77     
- Misses        250      257       +7
Impacted Files Coverage Δ
src/sagemaker/local/image.py 89.18% <100%> (+0.86%) ⬆️
src/sagemaker/local/local_session.py 75% <88.23%> (-5%) ⬇️
src/sagemaker/local/entities.py 91.17% <91.17%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9d3dceb...0b42d3d. Read the comment docs.

local sagemakerclient was not very useful beyond creating a single
estimator/endpoint. doing workflows such as training and later creating
and endpoint was really awkward.

These changes make it both resemble the API a bit more and allow
persisting objects across LocalSessions. This is important because most
of the time the SDK classes create sessions behind the scenes.
@iquintero iquintero force-pushed the local_session_refactor branch from e6fe630 to e6bcfc0 Compare August 31, 2018 23:31
@codecov-io
Copy link

Codecov Report

Merging #375 into master will decrease coverage by 0.11%.
The diff coverage is 90.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #375      +/-   ##
==========================================
- Coverage   92.94%   92.83%   -0.12%     
==========================================
  Files          51       52       +1     
  Lines        3572     3656      +84     
==========================================
+ Hits         3320     3394      +74     
- Misses        252      262      +10
Impacted Files Coverage Δ
src/sagemaker/local/image.py 87.38% <100%> (-0.04%) ⬇️
src/sagemaker/local/local_session.py 75% <88.23%> (-5%) ⬇️
src/sagemaker/local/entities.py 91.17% <91.17%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cb184cb...f287b8a. Read the comment docs.

Copy link
Contributor

@laurenyu laurenyu left a comment

Choose a reason for hiding this comment

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

no tests for the new entities file?

'ModelName': self.model_name,
'CreationTime': self.creation_time,
'ExecutionRoleArn': 'local:arn-does-not-matter',
'ModelArn': 'local:arn-does-not-matter',
Copy link
Contributor

Choose a reason for hiding this comment

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

might be better to have these as constants

_FAILED = 'Failed'

def __init__(self, endpoint_name, endpoint_config_name, local_session=None):
from sagemaker.local import LocalSagemakerClient
Copy link
Contributor

Choose a reason for hiding this comment

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

could you add a comment explaining why this has to be imported down here? also, I think you could move it to the else block if you wanted to

InputDataConfig (dict): Describes the training dataset and the location where it is stored.
OutputDataConfig (dict): Identifies the location where you want to save the results of model training.
ResourceConfig (dict): Identifies the resources to use for local model traininig.
HyperParameters (dict): Specify these algorithm-specific parameters to influence the quality of the final
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: s/Specify/Specifies to make it consistent with the other ones

container = _SageMakerContainer(ResourceConfig['InstanceType'], ResourceConfig['InstanceCount'],
AlgorithmSpecification['TrainingImage'], self.sagemaker_session)
train_job = _LocalTrainingJob(container)
train_job.start(InputDataConfig, HyperParameters)
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: s/train_job/training_job

assert train_container is not None
assert train_container.image == image
assert train_container.instance_count == instance_count
local_sagemaker_client.create_training_job('my-training-job', algo_spec, input_data_config,
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe constants for some of these strings as well?

iquintero and others added 3 commits September 26, 2018 10:27
- Fix Hyperparameters being mandatory in local mode
- Fix serving container timeout time to match SageMaker
@iquintero iquintero merged commit 3cd8628 into aws:master Sep 26, 2018
pdasamzn pushed a commit to pdasamzn/sagemaker-python-sdk that referenced this pull request Nov 1, 2018
Local sagemakerclient was not very useful beyond creating a single
estimator/endpoint. doing workflows such as training and later creating
and endpoint was really awkward.

These changes make it both resemble the API a bit more and allow
persisting objects across LocalSessions. This is important because most
of the time the SDK classes create sessions behind the scenes.

includes 2 bug fixes:

- Fix Hyperparameters being mandatory in local mode
- Fix serving container timeout time to match SageMaker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants