Fix SageMakerNotebookOperator domain_id/project_id/domain_region params#62962
Fix SageMakerNotebookOperator domain_id/project_id/domain_region params#62962o-nikolas merged 8 commits intoapache:mainfrom
Conversation
providers/amazon/tests/system/amazon/aws/example_sagemaker_unified_studio_explicit_params.py
Outdated
Show resolved
Hide resolved
providers/amazon/tests/system/amazon/aws/example_sagemaker_unified_studio.py
Show resolved
Hide resolved
providers/amazon/src/airflow/providers/amazon/aws/operators/sagemaker_unified_studio.py
Outdated
Show resolved
Hide resolved
providers/amazon/src/airflow/providers/amazon/aws/operators/sagemaker_unified_studio.py
Outdated
Show resolved
Hide resolved
providers/amazon/tests/system/amazon/aws/example_sagemaker_unified_studio.py
Show resolved
Hide resolved
providers/amazon/tests/system/amazon/aws/example_sagemaker_unified_studio_explicit_params.py
Outdated
Show resolved
Hide resolved
providers/amazon/tests/system/amazon/aws/example_sagemaker_unified_studio_explicit_params.py
Outdated
Show resolved
Hide resolved
providers/amazon/tests/system/amazon/aws/example_sagemaker_unified_studio_explicit_params.py
Outdated
Show resolved
Hide resolved
providers/amazon/tests/system/amazon/aws/example_sagemaker_unified_studio_explicit_params.py
Outdated
Show resolved
Hide resolved
providers/amazon/tests/system/amazon/aws/example_sagemaker_unified_studio_explicit_params.py
Outdated
Show resolved
Hide resolved
|
Tests are still failing due to the fact that sagemaker-studio v1.0.25 is not available yet. Waiting for it to become live to rerun the tests |
uranusjr
left a comment
There was a problem hiding this comment.
No idea on how SageMaker works but Python-wise this looks as reasonable as it goes.
|
Is the version upgrade needed? It’s not explained above if this uses new features. |
|
@Shnekit This PR has been converted to draft because it does not yet meet our Pull Request quality criteria. Issues found:
What to do next:
Converting a PR to draft is not a rejection — it is an invitation to bring the PR up to the project's standards so that maintainer review time is spent productively. If you have questions, feel free to ask on the Airflow Slack. |
|
Tightening the sagemaker-studio version to make sure it supports receiving domain id and project id parameters configured through SageMakerNotebookOperator |
providers/amazon/tests/system/amazon/aws/example_sagemaker_unified_studio.py
Outdated
Show resolved
Hide resolved
providers/amazon/tests/system/amazon/aws/example_sagemaker_unified_studio.py
Outdated
Show resolved
Hide resolved
providers/amazon/src/airflow/providers/amazon/aws/hooks/sagemaker_unified_studio.py
Show resolved
Hide resolved
providers/amazon/tests/system/amazon/aws/example_sagemaker_unified_studio.py
Show resolved
Hide resolved
providers/amazon/src/airflow/providers/amazon/aws/operators/sagemaker_unified_studio.py
Outdated
Show resolved
Hide resolved
56f2e6b to
32a4e86
Compare
- Fix duplicate _get_sagemaker_studio_config method in hook that was missing domain_identifier, project_identifier, datazone_domain_region - Add template_fields to SageMakerNotebookOperator so XCom references are resolved before execute() is called and the hook is instantiated - Update example_sagemaker_unified_studio system test to remove deprecated ENVIRONMENT_ID, SCOPE_NAME, STAGE, ENDPOINT env vars - Add example_sagemaker_unified_studio_explicit_params system test that passes domain_id, project_id, domain_region as operator params instead of relying on environment variables
- Fix duplicate _get_sagemaker_studio_config method in hook that was missing domain_identifier, project_identifier, datazone_domain_region - Add template_fields to SageMakerNotebookOperator so XCom references resolve before execute() is called and the hook is instantiated - Add explicit domain_id/project_id operator params test to system test, verifying SDK can resolve S3 path and region without env vars - Bump sagemaker-studio minimum version to 1.0.25
…xplicit params path
32a4e86 to
94a3198
Compare
…ms (apache#62962) - Method _get_sagemaker_studio_config in hook did not specify domain, project, and DZ region identifiers. The hook was missing domain_identifier, project_identifier, and datazone_domain_region. - Add template_fields to SageMakerNotebookOperator. Without template_fields, passing XCom references (e.g. task_instance.xcom_pull(...)) for domain_id, project_id, or domain_region caused a ParamValidationError because the hook was instantiated before Airflow resolved the XCom values to actual strings. Adding these to template_fields ensures they are rendered before execute() is called. - Updated example_sagemaker_unified_studio to reflect changes.
…ms (apache#62962) - Method _get_sagemaker_studio_config in hook did not specify domain, project, and DZ region identifiers. The hook was missing domain_identifier, project_identifier, and datazone_domain_region. - Add template_fields to SageMakerNotebookOperator. Without template_fields, passing XCom references (e.g. task_instance.xcom_pull(...)) for domain_id, project_id, or domain_region caused a ParamValidationError because the hook was instantiated before Airflow resolved the XCom values to actual strings. Adding these to template_fields ensures they are rendered before execute() is called. - Updated example_sagemaker_unified_studio to reflect changes.
…ms (apache#62962) - Method _get_sagemaker_studio_config in hook did not specify domain, project, and DZ region identifiers. The hook was missing domain_identifier, project_identifier, and datazone_domain_region. - Add template_fields to SageMakerNotebookOperator. Without template_fields, passing XCom references (e.g. task_instance.xcom_pull(...)) for domain_id, project_id, or domain_region caused a ParamValidationError because the hook was instantiated before Airflow resolved the XCom values to actual strings. Adding these to template_fields ensures they are rendered before execute() is called. - Updated example_sagemaker_unified_studio to reflect changes.
…ms (apache#62962) - Method _get_sagemaker_studio_config in hook did not specify domain, project, and DZ region identifiers. The hook was missing domain_identifier, project_identifier, and datazone_domain_region. - Add template_fields to SageMakerNotebookOperator. Without template_fields, passing XCom references (e.g. task_instance.xcom_pull(...)) for domain_id, project_id, or domain_region caused a ParamValidationError because the hook was instantiated before Airflow resolved the XCom values to actual strings. Adding these to template_fields ensures they are rendered before execute() is called. - Updated example_sagemaker_unified_studio to reflect changes.
…ms (apache#62962) - Method _get_sagemaker_studio_config in hook did not specify domain, project, and DZ region identifiers. The hook was missing domain_identifier, project_identifier, and datazone_domain_region. - Add template_fields to SageMakerNotebookOperator. Without template_fields, passing XCom references (e.g. task_instance.xcom_pull(...)) for domain_id, project_id, or domain_region caused a ParamValidationError because the hook was instantiated before Airflow resolved the XCom values to actual strings. Adding these to template_fields ensures they are rendered before execute() is called. - Updated example_sagemaker_unified_studio to reflect changes.
Summary
This PR fixes two issues with the
SageMakerNotebookOperatorand its underlying hook whendomain_id,project_id, anddomain_regionare passed as parameters.Fixes
1. Method
_get_sagemaker_studio_configin hook did not specify domain, project, and DZ region identifiersThe hook was missing
domain_identifier,project_identifier, anddatazone_domain_region.2. Add
template_fieldstoSageMakerNotebookOperatorWithout
template_fields, passing XCom references (e.g.task_instance.xcom_pull(...)) fordomain_id,project_id, ordomain_regioncaused aParamValidationErrorbecause the hook was instantiated before Airflow resolved the XCom values to actual strings. Adding these totemplate_fieldsensures they are rendered beforeexecute()is called.System Tests
example_sagemaker_unified_studioto remove deprecated env vars (ENVIRONMENT_ID,SCOPE_NAME,STAGE,ENDPOINT)example_sagemaker_unified_studio_explicit_params— identical flow but passesdomain_id,project_id,domain_regiondirectly as operator parameters instead of environment variables