configure ruff, separate hydraJobs from other derivations

Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
This commit is contained in:
2024-08-04 11:24:38 -04:00
parent bdc15b2c41
commit c4bfafeaef
4 changed files with 47 additions and 20 deletions

View File

@ -4,11 +4,7 @@ import argparse
def parse_inputs():
parser = argparse.ArgumentParser()
parser.add_argument(
"flake_path", metavar="flake-path", help="path to flake to evaluate"
)
parser.add_argument(
"--keep-hydra", action="store_true", help="allow evaluating Hydra jobs"
)
parser.add_argument("flake_path", metavar="flake-path", help="path to flake to evaluate")
parser.add_argument("--keep-hydra", action="store_true", help="allow evaluating Hydra jobs")
args = parser.parse_args()
return args

View File

@ -33,9 +33,7 @@ def traverse_json(json_dict: dict) -> list[str]:
def get_derivations_from_check(nix_path: str, path_to_flake: str) -> list[str]:
flake_check = bash_wrapper(
f"{nix_path} flake check --verbose --keep-going", path=path_to_flake
)
flake_check = bash_wrapper(f"{nix_path} flake check --verbose --keep-going", path=path_to_flake)
if flake_check[2] != 0:
logging.warn(
"nix flake check returned non-zero exit code, collecting all available outputs"
@ -57,9 +55,7 @@ def get_derivations(path_to_flake: str) -> list[str]:
nix_path = shutil.which("nix")
derivations = []
if nix_path is None:
raise RuntimeError(
"nix is not available in the PATH, please verify that it is installed"
)
raise RuntimeError("nix is not available in the PATH, please verify that it is installed")
flake_show = bash_wrapper(f"{nix_path} flake show --json", path=path_to_flake)
if flake_show[2] != 0:
logging.error("flake show returned non-zero exit code")

View File

@ -10,19 +10,21 @@ import rad_development_python as rd
def main():
rd.configure_logger("INFO")
args = parse_inputs()
print("hi")
flake_path = args.flake_path
derivations = get_derivations(flake_path)
if (
not args.keep_hydra
and len(list(filter(lambda s: s.startswith("hydraJobs"), derivations))) > 0
):
logging.info("--keep-hydra flag is not specified, removing Hydra jobs")
derivations = filter(lambda s: not s.startswith("hydraJobs"), derivations)
derivations, hydraJobs = rd.partition(
lambda s: s.startswith("hydraJobs"), get_derivations(flake_path)
)
logging.info(f"derivations: {list(derivations)}")
for d in derivations:
evaluate_output(flake_path, d)
if not args.keep_hydra:
logging.info("--keep-hydra flag is not specified, removing Hydra jobs")
else:
logging.info(f"hydraJobs: {list(hydraJobs)}")
for d in hydraJobs:
evaluate_output(flake_path, d)
if __name__ == "__main__":
main()