in scripts/azureml-assets/azureml/assets/util/util.py [0:0]
def find_asset_config_files(input_dirs: Union[List[Path], Path],
asset_config_filename: str,
changed_files: List[Path] = None,
exclude_dirs: List[Path] = None) -> List[Path]:
"""Search directories for asset config files.
Args:
input_dirs (Union[List[Path], Path]): Directories to search in.
asset_config_filename (str): Asset config filename to search for.
changed_files (List[Path], optional): Changed files, used to filter assets in input_dirs.
exclude_dirs (Union[List[Path], Path], optional): Directories that should be excluded from the search.
Returns:
List[Path]: Asset config files found.
"""
input_dirs, exclude_dirs = _convert_excludes(input_dirs, exclude_dirs)
changed_files_resolved = set([file.resolve() for file in changed_files] if changed_files else [])
found_assets = []
for input_dir in input_dirs:
for file in input_dir.rglob(asset_config_filename):
# If specified, skip assets when no change in asset, source_code and test_code
try:
asset_config = assets.AssetConfig(file)
test_dir_path = asset_config.pytest_tests_dir_with_path
test_dir_path = test_dir_path.resolve() if test_dir_path else Path()
release_paths_resolved = [path.resolve() for path in asset_config.release_paths]
asset_changed_files = changed_files_resolved & set(release_paths_resolved)
except ValidationException:
test_dir_path = Path()
asset_changed_files = set()
if changed_files and not asset_changed_files and not any(
file.parent in f.parents or
test_dir_path in f.resolve().parents
for f in changed_files
):
continue
# If specified, skip excluded directories
if exclude_dirs and any([d for d in exclude_dirs if d in file.parents]):
continue
found_assets.append(file)
return found_assets