in src/utils.py [0:0]
def fetch_dlc_images_for_test_jobs(images, use_latest_additional_tag=False):
"""
use the JobParamters.run_test_types values to pass on image ecr urls to each test type.
:param images: list
:return: dictionary
"""
DLC_IMAGES = {"sagemaker": [], "ecs": [], "eks": [], "ec2": [], "sanity": []}
build_enabled = is_build_enabled()
for docker_image in images:
if not docker_image.is_test_promotion_enabled:
continue
use_preexisting_images = ((not build_enabled) and docker_image.build_status == constants.NOT_BUILT)
if docker_image.build_status == constants.SUCCESS or use_preexisting_images:
ecr_url_to_test = docker_image.ecr_url
if use_latest_additional_tag and len(docker_image.additional_tags) > 0:
ecr_url_to_test = f"{docker_image.repository}:{docker_image.additional_tags[-1]}"
# Run sanity tests on the all images built
DLC_IMAGES["sanity"].append(ecr_url_to_test)
image_job_type = docker_image.info.get("image_type")
image_device_type = docker_image.info.get("device_type")
image_python_version = docker_image.info.get("python_version")
image_tag = f"{image_job_type}_{image_device_type}_{image_python_version}"
# when image_run_test_types has key all values can be (all , ecs, eks, ec2, sagemaker)
if constants.ALL in JobParameters.image_run_test_types.keys():
run_tests = JobParameters.image_run_test_types.get(constants.ALL)
run_tests = (
constants.ALL_TESTS if constants.ALL in run_tests else run_tests
)
for test in run_tests:
DLC_IMAGES[test].append(ecr_url_to_test)
# when key is training or inference values can be (ecs, eks, ec2, sagemaker)
if image_job_type in JobParameters.image_run_test_types.keys():
run_tests = JobParameters.image_run_test_types.get(image_job_type)
for test in run_tests:
DLC_IMAGES[test].append(ecr_url_to_test)
# when key is image_tag (training-cpu-py3) values can be (ecs, eks, ec2, sagemaker)
if image_tag in JobParameters.image_run_test_types.keys():
run_tests = JobParameters.image_run_test_types.get(image_tag)
run_tests = (
constants.ALL_TESTS if constants.ALL in run_tests else run_tests
)
for test in run_tests:
DLC_IMAGES[test].append(ecr_url_to_test)
for test_type in DLC_IMAGES.keys():
test_images = DLC_IMAGES[test_type]
if test_images:
DLC_IMAGES[test_type] = list(set(test_images))
return DLC_IMAGES