Skip to content
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

Use AWS_DEFAULT_REGION for bedrock if provided #157

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

AnirudhDagar
Copy link
Collaborator

Description

How Has This Been Tested?

  • Unit tests (pytest tests/)
  • Integration tests (if applicable)
  • tested locally with aga run knot_theory --config_overrides "time_limit=120, feature_transformers.enabled_models=[CAAFE]"

Configuration Changes

  • No config changes
  • Config changes (please describe):

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Performance improvement
  • Code cleanup/refactor

@@ -115,8 +115,7 @@ def get_openai_models() -> List[str]:
@staticmethod
def get_bedrock_models() -> List[str]:
try:
# TODO: Remove hardcoding AWS region
bedrock = boto3.client("bedrock", region_name="us-west-2")
bedrock = boto3.client("bedrock", region_name=os.environ.get("AWS_DEFAULT_REGION", "us-west-2"))
Copy link
Contributor

Choose a reason for hiding this comment

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

If you leave out region_name in the client creation, boto3 handles this fallback behavior automatically. This might be cleaner where we don't need to take care of passing the region everytime a boto3 client initiated in codes

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree we could simply remove the region_name kwarg, the only thing being added here is that we have a fallback in case the user doesn't set AWS_DEFAULT_REGION. But I'm happy to remove this as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

The default behavior uses AWS_DEFAULT_REGION or the AWS config file, and as a last resort, it resorts to IMDS for EC2. If none of these sources provide a region resolution, a NoRegionError is raised to ensure that the user has to explicitly set the region in the running environment. I believe this approach is better than selecting a region on behalf of the user.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cleaned it up

@@ -29,8 +29,7 @@ def __init__(
num_iterations: int = 2,
optimization_metric: str = "roc",
eval_model: str = "lightgbm",
# TODO: Remove hardcoding AWS region
region_name: str = "us-west-2",
region_name: str = os.environ.get("AWS_DEFAULT_REGION", "us-west-2"),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@tonyhoo it is still required to pass the region_name here as for CAAFE, so I think it is okay to keep this.

Later after the release I'm going to refactor CAAFE, and then this argument can also be removed.

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 it would be better to keep the region setting consistent across the repo

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not possible to remove it from CAAFE until we make changes in CAAFE upstream. Would you suggest that I also make changes upstream? See details here:

https://github.com/AnirudhDagar/CAAFE/blob/be58d15e03329e0a7344938d347e07b76166523f/caafe/caafe.py#L37

https://github.com/AnirudhDagar/CAAFE/blob/be58d15e03329e0a7344938d347e07b76166523f/caafe/sklearn_wrapper.py#L42

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.

2 participants