From 39a57188b59ec902a9cb2e5d8d2dd78d30f73ef1 Mon Sep 17 00:00:00 2001 From: ahuston-0 Date: Sat, 1 Mar 2025 23:29:01 -0500 Subject: [PATCH] switch to new cache, fix minor issues with logging --- flake.nix | 6 +++--- flupdt/flake_show.py | 16 +++++++++------- flupdt/main.py | 13 +++++++++---- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/flake.nix b/flake.nix index e163b3e..9f155ea 100644 --- a/flake.nix +++ b/flake.nix @@ -4,17 +4,17 @@ nixConfig = { substituters = [ "https://cache.nixos.org/?priority=1&want-mass-query=true" - "https://attic.alicehuston.xyz/cache-nix-dot?priority=4&want-mass-query=true" + "https://attic.nayeonie.com/nix-cache" "https://nix-community.cachix.org/?priority=10&want-mass-query=true" ]; trusted-substituters = [ "https://cache.nixos.org" - "https://attic.alicehuston.xyz/cache-nix-dot" + "https://attic.nayeonie.com/nix-cache" "https://nix-community.cachix.org" ]; trusted-public-keys = [ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" - "cache-nix-dot:Od9KN34LXc6Lu7y1ozzV1kIXZa8coClozgth/SYE7dU=" + "nix-cache:trR+y5nwpQHR4hystoogubFmp97cewkjWeqqbygRQRs=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ]; }; diff --git a/flupdt/flake_show.py b/flupdt/flake_show.py index e77dd97..1c53ce6 100644 --- a/flupdt/flake_show.py +++ b/flupdt/flake_show.py @@ -1,10 +1,12 @@ #!/usr/bin/env python3 import json -from rad_development_python import bash_wrapper -import shutil import logging import re +import shutil +import typing + +from rad_development_python import bash_wrapper output_regexes = [ re.compile(r"checking derivation (.*)..."), @@ -12,7 +14,7 @@ output_regexes = [ ] -def traverse_json_base(json_dict: dict, path: list[str]) -> list[str]: +def traverse_json_base(json_dict: dict[str,typing.Any], path: list[str]) -> list[str]: final_paths = [] for key, value in json_dict.items(): if isinstance(value, dict): @@ -21,10 +23,10 @@ def traverse_json_base(json_dict: dict, path: list[str]) -> list[str]: "nixos-configuration", "derivation", ]: - output = ".".join(path + [key]) + output = ".".join([*path, key]) final_paths += [output] else: - final_paths += traverse_json_base(value, path + [key]) + final_paths += traverse_json_base(value, [*path ,key]) return final_paths @@ -35,7 +37,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) if flake_check[2] != 0: - logging.warn( + logging.warning( "nix flake check returned non-zero exit code, collecting all available outputs" ) error_out = flake_check[1].split("\n") @@ -59,7 +61,7 @@ def get_derivations(path_to_flake: str) -> list[str]: 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") - logging.warn("falling back to full evaluation via nix flake check") + logging.warning("falling back to full evaluation via nix flake check") derivations = get_derivations_from_check(nix_path, path_to_flake) else: flake_show_json = json.loads(flake_show[0]) diff --git a/flupdt/main.py b/flupdt/main.py index 95d8bb2..c5b287e 100644 --- a/flupdt/main.py +++ b/flupdt/main.py @@ -7,11 +7,16 @@ import logging import rad_development_python as rd -def main(): +def main() -> None: + """Sets up logging, parses args, and runs evaluation routine. + + :returns: None + + """ rd.configure_logger("INFO") args = parse_inputs() flake_path = args.flake_path - derivations, hydraJobs = rd.partition( + derivations, hydra_jobs = rd.partition( lambda s: s.startswith("hydraJobs"), get_derivations(flake_path) ) logging.info(f"derivations: {list(derivations)}") @@ -21,8 +26,8 @@ def main(): 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: + logging.info(f"hydraJobs: {list(hydra_jobs)}") + for d in hydra_jobs: evaluate_output(flake_path, d)