Skip to content

Commit

Permalink
verify that config files for each system are valid
Browse files Browse the repository at this point in the history
  • Loading branch information
scheibelp committed Oct 10, 2024
1 parent 875c76d commit 5a74914
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/benchpark/cmd/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
#
# SPDX-License-Identifier: Apache-2.0

import os
import pathlib
import sys

import benchpark.repo
import benchpark.system as system

import ramble.config as cfg

sys_repo = benchpark.repo.paths[benchpark.repo.ObjectTypes.systems]
exp_repo = benchpark.repo.paths[benchpark.repo.ObjectTypes.experiments]
Expand All @@ -28,13 +32,40 @@ def audit_experiment(exp_cls):
return errors


def _find_yaml_files(d):
yaml_files = list()
for root, dirs, files in os.walk(d):
root = pathlib.Path(root)
yaml_files.extend((root / f) for f in files if f.endswith(".yaml"))
return yaml_files


def audit_system(sys_cls):
errors = list()
basedir = pathlib.Path(sys_repo.filename_for_object_name(sys_cls.__name__)).parent
externals = basedir / "externals"
if externals.exists():
for f in _find_yaml_files(externals):
cfg.read_config_file(f, system.packages_schema)

compilers = basedir / "compilers"
if compilers.exists():
for f in _find_yaml_files(compilers):
cfg.read_config_file(f, system.compilers_schema)
return errors


def command(args):
all_errors = list()

for exp_name in exp_repo.all_object_names():
exp_cls = exp_repo.get_obj_class(exp_name)
all_errors.extend(audit_experiment(exp_cls))

for sys_name in sys_repo.all_object_names():
sys_cls = sys_repo.get_obj_class(sys_name)
all_errors.extend(audit_system(sys_cls))

for error in all_errors:
print(error)

Expand Down

0 comments on commit 5a74914

Please sign in to comment.