Skip to content

fix: adjacent slash in s3 key #3427

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 1 commit into from
Oct 25, 2022
Merged

fix: adjacent slash in s3 key #3427

merged 1 commit into from
Oct 25, 2022

Conversation

nmadan
Copy link
Member

@nmadan nmadan commented Oct 19, 2022

Issue #, if available: #3413

Description of changes: Change S3 output_path to remove adjacent slashes

Testing done: unit testing

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 certify that the changes I am introducing will be backward compatible, and I have discussed concerns about this, if any, with the Python SDK team
  • 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 added unit and/or integration tests as appropriate to ensure backward compatibility of the changes
  • 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.

@nmadan nmadan requested a review from qidewenwhen October 19, 2022 23:26
self.sagemaker_session.context.runtime_repack_output_prefix = "s3://{}/{}".format(
bucket, key_prefix
self.sagemaker_session.context.runtime_repack_output_prefix = s3.s3_path_join(
"s3://", bucket, key_prefix
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems the s3.s3_path_join will remove the "/" in the end of the path and return "s3://my-bucket/my-key-prefix".

But given the customer input in #3413

Removing the slash from the code location “works” (as in does not create an error message), but then I have no separation between the pipeline prefix and the artifact name, e.g. pipeline-codepytorchinference ...

Should we also check the estimator side on how it generates the entire code output path with the code_location?

Or if this is already checked in the unit test that a separation is correctly added between the prefix and the artifact name, please let me know. Then we're good

Copy link
Contributor

Choose a reason for hiding this comment

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

Plus, if we decide to update the model side rather than the estimator side, as this only updates the tensorflow model, same changes are needed in the model class as well:

Copy link
Member Author

@nmadan nmadan Oct 19, 2022

Choose a reason for hiding this comment

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

Or if this is already checked in the unit test that a separation is correctly added between the prefix and the artifact name, please let me know. Then we're good

yep, I verified in the unit test that for input code_location f's3://my-bucket/pipeline-code/' and model-name pytorchinference the s3 path will be s3://bucket/pipeline-code/pytorchinference/.... Note that key_prefix in the code above is actually pipeline-code//pytorchinference. Basically this code change will convert the // to /

same changes are needed in the model class as well

Yes, forgot to commit that class adding it now

Copy link
Contributor

@qidewenwhen qidewenwhen Oct 20, 2022

Choose a reason for hiding this comment

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

After a second thought, how about we directly update the joins in _stage_user_code_in_s3 in estimator.py (see here)? The reasons are:

  • even if we update the model side to remove the "/" at the end of code_location, if user supplies ...code_location/ directly to the code_location to an estimator, the code_location//some-key would still persist in estimator code output. Though it may not cause any errors but it may not work as customer's expectation.
  • If update the estimator side, we can just update in one place and no need to update the model sides.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am assuming that by "artifact" the user means "model-name"

Copy link
Contributor

Choose a reason for hiding this comment

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

how about we directly update the joins in _stage_user_code_in_s3 in estimator.py

Synced up offline, this may break backward compatibility. Given that we don't see any customer complains on the estimator's code location output path, we can just simply update the model side

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@codecov-commenter
Copy link

codecov-commenter commented Oct 19, 2022

Codecov Report

Merging #3427 (fd0a326) into master (1fa2377) will decrease coverage by 0.22%.
The diff coverage is 82.90%.

@@            Coverage Diff             @@
##           master    #3427      +/-   ##
==========================================
- Coverage   89.17%   88.95%   -0.23%     
==========================================
  Files         204      205       +1     
  Lines       18979    19070      +91     
==========================================
+ Hits        16924    16963      +39     
- Misses       2055     2107      +52     
Impacted Files Coverage Δ
src/sagemaker/sklearn/model.py 92.98% <ø> (-1.76%) ⬇️
...sagemaker/workflow/monitor_batch_transform_step.py 0.00% <0.00%> (ø)
src/sagemaker/workflow/utilities.py 94.31% <ø> (ø)
src/sagemaker/xgboost/model.py 96.36% <ø> (-1.82%) ⬇️
src/sagemaker/session.py 71.41% <28.57%> (-0.25%) ⬇️
src/sagemaker/training_compiler/config.py 80.43% <60.00%> (-2.90%) ⬇️
src/sagemaker/sklearn/estimator.py 93.93% <63.63%> (-6.07%) ⬇️
src/sagemaker/estimator.py 89.43% <71.42%> (-0.08%) ⬇️
src/sagemaker/amazon/amazon_estimator.py 87.82% <81.25%> (-0.62%) ⬇️
src/sagemaker/amazon/lda.py 98.03% <92.30%> (+0.16%) ⬆️
... and 23 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: fd0a326
  • 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-slow-tests
  • Commit ID: fd0a326
  • 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-unit-tests
  • Commit ID: fd0a326
  • 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: fd0a326
  • 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: fd0a326
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

Copy link
Collaborator

@claytonparnell claytonparnell left a comment

Choose a reason for hiding this comment

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

/bot run slow-tests, notebook-tests

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: fd0a326
  • 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-slow-tests
  • Commit ID: fd0a326
  • 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-slow-tests
  • Commit ID: fd0a326
  • Result: FAILED
  • Build Logs (available for 30 days)

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

Copy link
Collaborator

@claytonparnell claytonparnell left a comment

Choose a reason for hiding this comment

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

/bot run slow-tests

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-slow-tests
  • Commit ID: fd0a326
  • 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-slow-tests
  • Commit ID: fd0a326
  • 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-slow-tests
  • Commit ID: fd0a326
  • 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-slow-tests
  • Commit ID: fd0a326
  • 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-slow-tests
  • Commit ID: fd0a326
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mufaddal-rohawala mufaddal-rohawala merged commit 9e8230c into aws:master Oct 25, 2022
knikure pushed a commit to knikure/sagemaker-python-sdk that referenced this pull request Oct 25, 2022
mizanfiu pushed a commit to mizanfiu/sagemaker-python-sdk that referenced this pull request Dec 13, 2022
JoseJuan98 pushed a commit to JoseJuan98/sagemaker-python-sdk that referenced this pull request Mar 4, 2023
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.

7 participants