Skip to content

config: Find YAML files recursively #2860

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kernelci/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def iterate_yaml_files(config_path: str):
if config_path.endswith('.yaml'):
yaml_files = [config_path]
else:
yaml_files = glob.glob(os.path.join(config_path, "*.yaml"))
yaml_files = glob.glob(os.path.join(config_path, "**", "*.yaml"), recursive=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
yaml_files = glob.glob(os.path.join(config_path, "**", "*.yaml"), recursive=True)
yaml_files = glob.iglob(os.path.join(config_path, "**", "*.yaml"), recursive=True)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we do not expect a large number of files there, as such memory usage is not a concern, we walk the list of the files we find almost immediately, so we might as well use the variant that returns an iterator.

for yaml_path in yaml_files:
with open(yaml_path, encoding='utf8') as yaml_file:
data = yaml.safe_load(yaml_file)
Expand Down
Loading