def is_test_job_enabled(test_type): # only ec2 and sagemaker benchmark tests are supported currently sm_tests_enabled = parse_dlc_developer_configs("test", "sagemaker_tests") ec2_tests_enabled = parse_dlc_developer_configs("test", "ec2_tests") ecs_tests_enabled = parse_dlc_developer_configs("test", "ecs_tests") eks_tests_enabled = parse_dlc_developer_configs("test", "eks_tests") sanity_tests_enabled = parse_dlc_developer_configs("test", "sanity_tests") benchmark_mode = is_benchmark_mode_enabled() # For each test type, see if we should run the tests if test_type == constants.SAGEMAKER_TESTS and sm_tests_enabled: return True if test_type == constants.EC2_TESTS and ec2_tests_enabled: return True # We have no ECS/EKS/SANITY benchmark tests if not benchmark_mode: if test_type == constants.ECS_TESTS and ecs_tests_enabled: return True if test_type == constants.EKS_TESTS and eks_tests_enabled: return True if test_type == constants.SANITY_TESTS and sanity_tests_enabled: return True return False
def is_test_job_implemented_for_framework(images_str, test_type): """ Check to see if a test job is implemnted and supposed to be executed for this particular set of images """ is_trcomp_image = False is_huggingface_image = False if "huggingface" in images_str: if "trcomp" in images_str: is_trcomp_image = True else: is_huggingface_image = True is_autogluon_image = "autogluon" in images_str if (is_huggingface_image or is_autogluon_image) and test_type in [ constants.EC2_TESTS, constants.ECS_TESTS, constants.EKS_TESTS, ]: LOGGER.debug(f"Skipping {test_type} test") return False # SM Training Compiler has EC2 tests implemented so don't skip if is_trcomp_image and (test_type in [ constants.ECS_TESTS, constants.EKS_TESTS, ] or config.is_benchmark_mode_enabled()): LOGGER.debug(f"Skipping {test_type} tests for trcomp containers") return False return True
def main(): build_context = os.getenv("BUILD_CONTEXT") if build_context != "PR": LOGGER.info(f"Not triggering test jobs from boto3, as BUILD_CONTEXT is {build_context}") return # load the images for all test_types to pass on to code build jobs with open(constants.TEST_TYPE_IMAGES_PATH) as json_file: test_images = json.load(json_file) # Run necessary PR test jobs commit = os.getenv("CODEBUILD_RESOLVED_SOURCE_VERSION") for test_type, images in test_images.items(): # only run the code build test jobs when the images are present LOGGER.debug(f"test_type : {test_type}") LOGGER.debug(f"images: {images}") if images: pr_test_job = f"dlc-pr-{test_type}-test" images_str = " ".join(images) # Maintaining separate codebuild project for graviton sanity test if "graviton" in images_str and test_type == "sanity": pr_test_job += "-graviton" if is_test_job_enabled(test_type) and is_test_job_implemented_for_framework(images_str, test_type): run_test_job(commit, pr_test_job, images_str) # Trigger sagemaker local test jobs when there are changes in sagemaker_tests # sagemaker local test is not supported in benchmark dev mode if ( test_type == "sagemaker" and not config.is_benchmark_mode_enabled() and config.is_sm_local_test_enabled() ): test_job = f"dlc-pr-{test_type}-local-test" run_test_job(commit, test_job, images_str)
def is_test_job_enabled(test_type): """ Check to see if a test job is enabled See if we should run the tests based on test types and config options. """ if test_type == constants.SAGEMAKER_TESTS and config.is_sm_remote_test_enabled(): return True if test_type == constants.EC2_TESTS and config.is_ec2_test_enabled(): return True # We have no ECS/EKS/SANITY benchmark tests if not config.is_benchmark_mode_enabled(): if test_type == constants.ECS_TESTS and config.is_ecs_test_enabled(): return True if test_type == constants.EKS_TESTS and config.is_eks_test_enabled(): return True if test_type == constants.SANITY_TESTS and config.is_sanity_test_enabled(): return True return False
def main(): build_context = os.getenv("BUILD_CONTEXT") if build_context != "PR": LOGGER.info( f"Not triggering test jobs from boto3, as BUILD_CONTEXT is {build_context}" ) return # load the images for all test_types to pass on to code build jobs with open(constants.TEST_TYPE_IMAGES_PATH) as json_file: test_images = json.load(json_file) # Run necessary PR test jobs commit = os.getenv("CODEBUILD_RESOLVED_SOURCE_VERSION") for test_type, images in test_images.items(): # only run the code build test jobs when the images are present LOGGER.debug(f"test_type : {test_type}") LOGGER.debug(f"images: {images}") if images: pr_test_job = f"dlc-pr-{test_type}-test" images_str = " ".join(images) if is_test_job_enabled(test_type): if "huggingface" in images_str and test_type in [ constants.EC2_TESTS, constants.ECS_TESTS, constants.EKS_TESTS, ]: LOGGER.debug(f"Skipping huggingface {test_type} test") continue run_test_job(commit, pr_test_job, images_str) # Trigger sagemaker local test jobs when there are changes in sagemaker_tests # sagemaker local test is not supported in benchmark dev mode if test_type == "sagemaker" and not is_benchmark_mode_enabled( ): test_job = f"dlc-pr-{test_type}-local-test" run_test_job(commit, test_job, images_str)