Skip to content

fix: preserve model_dir bool value #1954

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
Oct 16, 2020
Merged

fix: preserve model_dir bool value #1954

merged 3 commits into from
Oct 16, 2020

Conversation

chuyang-deng
Copy link
Contributor

@chuyang-deng chuyang-deng commented Oct 15, 2020

Issue #, if available:
TensorFlow estimator's param model_dir will be changed to None if it was set to False by user after .hyperparameter() is called in https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/estimator.py#L1116-L1117 (.hyperparameters() called twice). It will later get set to a default s3 value when it's called the second time because its value is no longer False https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/tensorflow/estimator.py#L319.

Description of changes:
Adding a disable_model_dir param to TensorFlow class to make sure the boolean value is used as intended.
Corresponding change in sagemaker-tensorflow-training-toolkit: aws/sagemaker-tensorflow-training-toolkit#403

Testing done:
tox -e py38 -- tests/unit
tox -e py38 -- tests/component/test_tf_estimator.py

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.

General

  • I have read the CONTRIBUTING doc
  • I used the commit message format described in CONTRIBUTING
  • I have passed the region in to all S3 and STS clients that I've initialized as part of this change.
  • I have updated any necessary documentation, including READMEs and API docs (if appropriate)

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have checked that my tests are not configured for a specific region or account (if appropriate)
  • I have used unique_name_from_base to create resource names in integ tests (if appropriate)

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

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: 854513c
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: 854513c
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-local-mode-tests
  • Commit ID: 854513c
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: 854513c
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@icywang86rui
Copy link
Contributor

Can we fix it in https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/estimator.py#L1116-L1117
by assigning the result of hyperparamter() and eliminate the send call?

@icywang86rui
Copy link
Contributor

or if you want to limit blast radius fix it here -

self.model_dir = self.model_dir or self._default_s3_path("model", mpi=mpi_enabled)
additional_hyperparameters["model_dir"] = self.model_dir

additional_hyperparameters["model_dir"] = self.model_dir or self._default_s3_path("model", mpi=mpi_enabled)

@chuyang-deng
Copy link
Contributor Author

or if you want to limit blast radius fix it here -

self.model_dir = self.model_dir or self._default_s3_path("model", mpi=mpi_enabled)
additional_hyperparameters["model_dir"] = self.model_dir

additional_hyperparameters["model_dir"] = self.model_dir or self._default_s3_path("model", mpi=mpi_enabled)

This will also result in setting additional_hyperparameters["model_dir"] to a default s3 uri if self.model_dir is None.

I will try with making changes here: https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/estimator.py#L1116-L1117 (I was hesitant at first because I was afraid it might break something else, but I will make sure it doesn't)

@icywang86rui
Copy link
Contributor

or if you want to limit blast radius fix it here -

self.model_dir = self.model_dir or self._default_s3_path("model", mpi=mpi_enabled)
additional_hyperparameters["model_dir"] = self.model_dir

additional_hyperparameters["model_dir"] = self.model_dir or self._default_s3_path("model", mpi=mpi_enabled)

This will also result in setting additional_hyperparameters["model_dir"] to a default s3 uri if self.model_dir is None.

I will try with making changes here: https://github.com/aws/sagemaker-python-sdk/blob/master/src/sagemaker/estimator.py#L1116-L1117 (I was hesitant at first because I was afraid it might break something else, but I will make sure it doesn't)

you can make it explicit by adding another if statement

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: 1453a12
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: 1453a12
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: 1453a12
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-local-mode-tests
  • Commit ID: 1453a12
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: 9c8d2d4
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: 9c8d2d4
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: 9c8d2d4
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-local-mode-tests
  • Commit ID: 9c8d2d4
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-local-mode-tests
  • Commit ID: 9c8d2d4
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

hyperparameters = {str(k): str(v) for (k, v) in estimator.hyperparameters().items()}
current_hyperparameters = estimator.hyperparameters()
if current_hyperparameters is not None:
hyperparameters = {str(k): str(v) for (k, v) in current_hyperparameters.items()}
Copy link
Contributor

Choose a reason for hiding this comment

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

you can remove the parentheses:

Suggested change
hyperparameters = {str(k): str(v) for (k, v) in current_hyperparameters.items()}
hyperparameters = {str(k): str(v) for k, v in current_hyperparameters.items()}

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-local-mode-tests
  • Commit ID: 9c8d2d4
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@chuyang-deng chuyang-deng merged commit a27d9d7 into aws:master Oct 16, 2020
guoqiao1992 pushed a commit to guoqiao1992/sagemaker-python-sdk that referenced this pull request Oct 26, 2020
* fix: preserve model_dir bool value

* avoid calling hyperparaneters twince

Co-authored-by: Chuyang Deng <[email protected]>
Co-authored-by: icywang86rui <[email protected]>
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.

4 participants