Skip to content

infra: modify PR template and refactor test #1381

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

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ _Put an `x` in the boxes that apply. You can also fill these out after creating

- [ ] I have read the [CONTRIBUTING](https://github.com/aws/sagemaker-python-sdk/blob/master/CONTRIBUTING.md) doc
- [ ] I used the commit message format described in [CONTRIBUTING](https://github.com/aws/sagemaker-python-sdk/blob/master/CONTRIBUTING.md#committing-your-change)
- [ ] I have passed the region in to any/all clients that I've initialized as part of this change.
- [ ] I have passed the region in to any/all AWS clients that I've initialized as part of this change.
- [ ] I have updated any necessary documentation, including [READMEs](https://github.com/aws/sagemaker-python-sdk/blob/master/README.rst) and [API docs](https://github.com/aws/sagemaker-python-sdk/tree/master/doc) (if appropriate)

#### Tests
Expand Down
12 changes: 7 additions & 5 deletions tests/integ/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@
def test_sagemaker_session_does_not_create_bucket_on_init(
sagemaker_client_config, sagemaker_runtime_config, boto_config
):
boto_session = (
boto3.Session(**boto_config) if boto_config else boto3.Session(region_name=DEFAULT_REGION)
)
if boto_config:
boto_session = boto3.Session(**boto_config)
s3 = boto3.resource("s3", region_name=boto_config["region_name"])
else:
boto_session = boto3.Session(region_name=DEFAULT_REGION)
s3 = boto3.resource("s3", region_name=DEFAULT_REGION)
Comment on lines +31 to +32
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I'd rather go with how the other tests do it and not have a fallback at all. That way we explicitly fail if the region is not set instead of potentially masking other errors (e.g. #1308)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see what you're saying, and I think it's a better idea, but that would likely be best done as a refactor to every situation we currently have, because that's not how we currently do it.
I'd also say we should throw an exception in that case to make sure UTs/ITs catch it:

boto3.Session(**boto_config) if boto_config else boto3.Session(region_name=DEFAULT_REGION)

Copy link
Contributor

Choose a reason for hiding this comment

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

a refactor to every situation we currently have
I'd also say we should throw an exception in that case to make sure UTs/ITs catch it

so...these sound like good suggestions...


sagemaker_client_config.setdefault("config", Config(retries=dict(max_attempts=10)))
sagemaker_client = (
boto_session.client("sagemaker", **sagemaker_client_config)
Expand All @@ -45,6 +49,4 @@ def test_sagemaker_session_does_not_create_bucket_on_init(
sagemaker_runtime_client=runtime_client,
default_bucket=CUSTOM_BUCKET_NAME,
)

s3 = boto3.resource("s3", region_name=DEFAULT_REGION)
assert s3.Bucket(CUSTOM_BUCKET_NAME).creation_date is None