-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix: Bug fixes for s3 path validation, mlflow app creation #5402
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
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c4e9ace
fix: Fix the recipe selection for multiple recipe scenario
8562a22
fix: Fix the recipe selection for multiple recipe scenario
066221f
Merge branch 'aws:master' into master-mc-bug-fixes
rsareddy0329 8867131
fix: Hyperparameter issue fixes, validate s3 output path,additional u…
112e12b
Merge branch 'aws:master' into master-mc-bug-fixes
rsareddy0329 9679c5d
Fix: Add validation to bedrock reward models
c71e957
Fix: Add validation to bedrock reward models
c3e6a51
Merge branch 'aws:master' into master-mc-bug-fixes
rsareddy0329 c43a863
Fix: Add allow list for bedrock eval models
2fb0ac1
Fix: Add allow list for bedrock eval models
6ac0aec
Merge branch 'master' into master-mc-bug-fixes
rsareddy0329 b3707fe
Merge branch 'aws:master' into master-mc-bug-fixes
rsareddy0329 5c56800
Fix: Bug fixes for s3 path validation, mlflow app creation
59eb8fe
Merge branch 'master' into master-mc-bug-fixes
rsareddy0329 7763bce
Merge branch 'aws:master' into master-mc-bug-fixes
rsareddy0329 ca85a78
Fix: Update Legal verbiage, and allowed reward model ids based on region
3388c3a
Fix: Update model_package_group_name to model_package_group in all tr…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -198,10 +198,19 @@ def _create_mlflow_app(sagemaker_session) -> Optional[MlflowApp]: | |
| if new_app.status in ["Created", "Updated"]: | ||
| return new_app | ||
| elif new_app.status in ["Failed", "Stopped"]: | ||
| raise RuntimeError(f"MLflow app creation failed with status: {new_app.status}") | ||
| # Get detailed error from MLflow app | ||
| error_msg = f"MLflow app creation failed with status: {new_app.status}" | ||
| if hasattr(new_app, 'failure_reason') and new_app.failure_reason: | ||
| error_msg += f". Reason: {new_app.failure_reason}" | ||
| raise RuntimeError(error_msg) | ||
| time.sleep(poll_interval) | ||
|
|
||
| raise RuntimeError(f"MLflow app creation timed out after {max_wait_time} seconds") | ||
| # Timeout case - get current status and any error details | ||
| new_app.refresh() | ||
| error_msg = f"MLflow app creation failed. Current status: {new_app.status}" | ||
| if hasattr(new_app, 'failure_reason') and new_app.failure_reason: | ||
| error_msg += f". Reason: {new_app.failure_reason}" | ||
| raise RuntimeError(error_msg) | ||
|
|
||
| except Exception as e: | ||
| logger.error("Failed to create MLflow app: %s", e) | ||
|
|
@@ -693,7 +702,7 @@ def _validate_eula_for_gated_model(model, accept_eula, is_gated_model): | |
|
|
||
|
|
||
| def _validate_s3_path_exists(s3_path: str, sagemaker_session): | ||
| """Validate if S3 path exists and is accessible.""" | ||
| """Validate S3 path and create bucket/prefix if they don't exist.""" | ||
| if not s3_path.startswith("s3://"): | ||
| raise ValueError(f"Invalid S3 path format: {s3_path}") | ||
|
|
||
|
|
@@ -705,19 +714,34 @@ def _validate_s3_path_exists(s3_path: str, sagemaker_session): | |
| s3_client = sagemaker_session.boto_session.client('s3') | ||
|
|
||
| try: | ||
| # Check if bucket exists and is accessible | ||
| s3_client.head_bucket(Bucket=bucket_name) | ||
| # Check if bucket exists, create if it doesn't | ||
| try: | ||
| s3_client.head_bucket(Bucket=bucket_name) | ||
| except Exception as e: | ||
| if "NoSuchBucket" in str(e) or "Not Found" in str(e): | ||
| # Create bucket | ||
| region = sagemaker_session.boto_region_name | ||
| if region == 'us-east-1': | ||
|
Collaborator
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. why this region specific check here ?
Member
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. This is expected for s3 |
||
| s3_client.create_bucket(Bucket=bucket_name) | ||
| else: | ||
| s3_client.create_bucket( | ||
| Bucket=bucket_name, | ||
| CreateBucketConfiguration={'LocationConstraint': region} | ||
| ) | ||
| else: | ||
| raise | ||
|
|
||
| # If prefix is provided, check if it exists | ||
| # If prefix is provided, check if it exists, create if it doesn't | ||
| if prefix: | ||
| response = s3_client.list_objects_v2(Bucket=bucket_name, Prefix=prefix, MaxKeys=1) | ||
| if 'Contents' not in response: | ||
| raise ValueError(f"S3 prefix '{prefix}' does not exist in bucket '{bucket_name}'") | ||
| # Create the prefix by putting an empty object | ||
| if not prefix.endswith('/'): | ||
| prefix += '/' | ||
| s3_client.put_object(Bucket=bucket_name, Key=prefix, Body=b'') | ||
|
|
||
| except Exception as e: | ||
| if "NoSuchBucket" in str(e): | ||
| raise ValueError(f"S3 bucket '{bucket_name}' does not exist or is not accessible") | ||
| raise ValueError(f"Failed to validate S3 path '{s3_path}': {str(e)}") | ||
| raise ValueError(f"Failed to validate/create S3 path '{s3_path}': {str(e)}") | ||
|
|
||
|
|
||
| def _validate_hyperparameter_values(hyperparameters: dict): | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
Do we need to raise error in case of timeout exception or should just display error message ? If MLFlow app is required parameter for CTJ API then it's fine to throw error.