in src/utils.py [0:0]
def parse_modified_sagemaker_test_files(files, framework, pattern=""):
"""
Parse all the files in PR to find sagemaker tests related changes for any framework
to trigger an image build matching the image_type(training/testing) for all the device_types(cpu,gpu)
and python_versions(py2,py3)
:param files: str
:param framework: str
:param pattern: str
:return: None
"""
rule = re.findall(rf"{pattern}", files)
for test_file in rule:
test_dirs = test_file.split("/")
test_folder = test_dirs[0]
if test_folder == "sagemaker_tests":
framework_changed = test_dirs[1]
# The below code looks for file changes in /test/sagemaker_tests/(mxnet|pytorch|tensorflow) directory
if framework_changed == framework:
job_name = test_dirs[2]
# The training folder structure for tensorflow is tensorflow1_training(1.x), tensorflow2_training(2.x)
# so we are stripping the tensorflow1 from the name
if framework_changed == "tensorflow" and "training" in job_name:
job_name = "training"
if job_name in constants.IMAGE_TYPES:
JobParameters.add_image_types(job_name)
JobParameters.build_for_all_device_types_py_versions()
update_image_run_test_types(job_name, constants.SAGEMAKER_TESTS)
# If file changed is under /test/sagemaker_tests/(mxnet|pytorch|tensorflow)
# but not in training/inference dirs
else:
JobParameters.build_for_all_images()
update_image_run_test_types(
constants.ALL, constants.SAGEMAKER_TESTS
)
break
# If file changed is under /test/sagemaker_tests but not in (mxnet|pytorch|tensorflow) dirs
elif framework_changed not in constants.FRAMEWORKS:
JobParameters.build_for_all_images()
update_image_run_test_types(constants.ALL, constants.SAGEMAKER_TESTS)
break