agupta01 commented on code in PR #45726: URL: https://github.com/apache/airflow/pull/45726#discussion_r1964407718
########## providers/tests/system/amazon/aws/example_sagemaker_unified_studio.py: ########## @@ -0,0 +1,149 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +from __future__ import annotations + +import os +from datetime import datetime + +import pytest + +from airflow.decorators import task +from airflow.models.baseoperator import chain +from airflow.models.dag import DAG +from airflow.providers.amazon.aws.operators.sagemaker_unified_studio import ( + SageMakerNotebookOperator, +) +from providers.tests.system.amazon.aws.utils import ENV_ID_KEY, SystemTestContextBuilder +from tests_common.test_utils.version_compat import AIRFLOW_V_2_10_PLUS + +""" +Prerequisites: The account which runs this test must manually have the following: +1. An IAM IDC organization set up in the testing region with the following user initialized: + Username: airflowTestUser + Password: airflowSystemTestP@ssword1! +2. A SageMaker Unified Studio Domain (with default VPC and roles) +3. A project within the SageMaker Unified Studio Domain + +Essentially, this test will emulate a DAG run in the shared MWAA environment inside a SageMaker Unified Studio Project. +The setup tasks will set up the project and configure the test runnner to emulate an MWAA instance. +Then, the SageMakerNotebookOperator will run a test notebook. This should spin up a SageMaker training job, run the notebook, and exit successfully. +The teardown tasks will finally delete the project and domain that was set up for this test run. +""" + +pytestmark = pytest.mark.skipif( + not AIRFLOW_V_2_10_PLUS, reason="Test requires Airflow 2.10+" +) + +DAG_ID = "example_sagemaker_unified_studio" + +# Externally fetched variables: +DOMAIN_ID_KEY = "DOMAIN_ID" +PROJECT_ID_KEY = "PROJECT_ID" +ENVIRONMENT_ID_KEY = "ENVIRONMENT_ID" +S3_PATH_KEY = "S3_PATH" + +sys_test_context_task = ( + SystemTestContextBuilder() + .add_variable(DOMAIN_ID_KEY) + .add_variable(PROJECT_ID_KEY) + .add_variable(ENVIRONMENT_ID_KEY) + .add_variable(S3_PATH_KEY) + .build() +) + + +@task +def emulate_mwaa_environment( + domain_id: str, project_id: str, environment_id: str, s3_path: str +): Review Comment: Updated to use this, please take a look. Thanks! -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
