-
Notifications
You must be signed in to change notification settings - Fork 138
feat: support codeartifact for installing requirements.txt packages #187
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
Conversation
|
This is related to the similar PR for sagemaker-inference-toolkit at aws/sagemaker-inference-toolkit#130 |
|
I've been using the codeartifact-related code for a few months already. I was not able to add any related integration tests as such tests would require access to a fixed codeartifact repo, and for the container to have access to AWS credentials. I'm asking for guidance if any such integ tests would be needed here. Additionally, is anything required in README to mention this CodeArtifact support? |
|
As an attempt to integ test this (code not in a committable state), I made the following changes ( which
With that, I got stdout looking like |
|
Based on #187 (comment), I've updated the PR to include a commented out integ test, that includes updates to |
src/sagemaker_training/modules.py
Outdated
| token = auth_token_response["authorizationToken"] | ||
| endpoint_response = client.get_repository_endpoint(domain=domain, domainOwner=owner, repository=repository, format="pypi") | ||
| unauthenticated_index = endpoint_response["repositoryEndpoint"] | ||
| return re.sub("https://", "https://aws:{}@".format(token), re.sub("{}/?$".format(repository), "{}/simple/".format(repository), unauthenticated_index)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please ensure https://aws works for all regions. Some snow-forted region may have different prefix.
LGTM otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1. Have you tested this in China region? Are we sure it will not be like https://aws.cn?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per https://aws.amazon.com/codeartifact/faq/, CodeArtifact is not available everywhere
In which AWS Regions is CodeArtifact available?
CodeArtifact is available in the following 13 [AWS Regions](https://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/):
US East (N.Virginia)
US East (Ohio)
US West (Oregon)
EU (Ireland)
EU (London)
EU (Frankfurt)
EU (Stockholm)
EU (Milan)
EU (Paris)
Asia Pacific (Sydney)
Asia Pacific (Tokyo)
Asia Pacific (Mumbai)
Asia Pacific (Singapore).
Additionally, the aws: part is not really abt the partition, it's the username e.g. https://username:[email protected]/somewhere
client.get_repository_endpoint returns the https://example.com/somewhere, then the following code is abt adding the username/password, and appending some path to the url
9a75eee to
621ac15
Compare
|
The inference-side change has been merged at Appreciate if you can have a look here. |
| assert "Reporting training SUCCESS" in stdout | ||
|
|
||
|
|
||
| # def test_install_requirements_from_codeartifact(capsys): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will you enable this test later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, for this to really be enabled, it requires that the build infrastructure for this package to actually have a codeartifact repo which I believe it doesn't.
I've written the integ test, that can be enabled if the build infra has such access.
So, at the moment, the answer is no, I don't think I can enable this on my own.
| https://docs.aws.amazon.com/service-authorization/latest/reference/list_awscodeartifact.html#awscodeartifact-resources-for-iam-policies | ||
| :return: authenticated codeartifact index url | ||
| """ | ||
| repository_arn = os.getenv(CA_REPOSITORY_ARN_ENV) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a repository_arn sample in comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second documentation link already has the format of the arn.
arn:${Partition}:codeartifact:${Region}:${Account}:repository/${DomainName}/${RepositoryName}
Also, keep in mind, this is a private method, but am happy to add this above format for clarity if u think that the link is not enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, pls add it. Thanks
emeraldbay
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ec547c1 to
6bb7f8f
Compare
- update modules.install_requirements to check for the presence of codeartifact (CA_* prefixed) environment variable - if env variable is present, build the authenticated endpoint index url, and add that to the pip install command - update sagemaker test dependency to support the setting of environment variables and update tox to resolve conflicts with newer sagemaker - add commented out integ test for installing requirements from codeartifact
emeraldbay
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Issue #, if available: #167
Description of changes:
Testing done:
Merge Checklist
Put an
xin 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
Tests
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.