-
Couldn't load subscription status.
- Fork 57
feat: update s3 data source for us-isof partition #311
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,11 @@ | |
| import urllib.parse | ||
| from typing import IO | ||
| from abc import ABC, abstractmethod | ||
| from fmeval.constants import BUILT_IN_DATASET_PREFIX, BUILT_IN_DATASET_DEFAULT_REGION | ||
| from fmeval.constants import ( | ||
| BUILT_IN_DATASET_PREFIX, | ||
| BUILT_IN_DATASET_DEFAULT_REGION, | ||
| BUILT_IN_DATASET_ISO_REGIONS, | ||
| ) | ||
| from fmeval.exceptions import EvalAlgorithmClientError | ||
|
|
||
|
|
||
|
|
@@ -110,14 +114,25 @@ def __reduce__(self): | |
|
|
||
| def get_s3_client(uri: str) -> boto3.client: | ||
| """ | ||
| Util method to return boto3 s3 client. For built-in datasets, the boto3 client region is default to us-west-2 as | ||
| the bucket is not accessible in opt-in regions. | ||
| Util method to return boto3 s3 client. For built-in datasets, the boto3 client region is default to us-west-2 for | ||
| commercial regions as the bucket is not accessible in opt-in regions. | ||
| For us-isof partition, built-in datasets are located in us-isof-south-1 region. | ||
|
|
||
| :param uri: s3 dataset uri | ||
| :return: boto3 s3 client | ||
| """ | ||
| s3_client = ( | ||
| boto3.client("s3", region_name=BUILT_IN_DATASET_DEFAULT_REGION) | ||
| if uri.startswith(BUILT_IN_DATASET_PREFIX) | ||
| else boto3.client("s3") | ||
| ) | ||
| session = boto3.session.Session() | ||
| region = session.region_name | ||
| if region in BUILT_IN_DATASET_ISO_REGIONS.keys(): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking nit: no need to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: if later we want to support other ISO regions, are we going to keep updating BUILT_IN_DATASET_ISO_REGIONS? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For new iso regions in other iso partitions we'll need to add the built-in datasets to a region in that partition and update the |
||
| s3_client = ( | ||
| boto3.client("s3", region_name=BUILT_IN_DATASET_ISO_REGIONS[region], verify=False) | ||
| if uri.startswith(BUILT_IN_DATASET_PREFIX) | ||
| else boto3.client("s3", verify=False) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking nit: Should we specify Marking this as a nit since based on the docs, whatever configuration files/env vars are used to create |
||
| ) | ||
| else: | ||
| s3_client = ( | ||
| boto3.client("s3", region_name=BUILT_IN_DATASET_DEFAULT_REGION) | ||
| if uri.startswith(BUILT_IN_DATASET_PREFIX) | ||
| else boto3.client("s3") | ||
| ) | ||
| return s3_client | ||
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.
Non-blocking nit: update docstring to describe the iso region case in general