feature/flupdt #1

Merged
ahuston-0 merged 14 commits from feature/flupdt into main 2025-03-02 01:01:15 -05:00
4 changed files with 47 additions and 20 deletions
Showing only changes of commit c4bfafeaef - Show all commits

View File

@ -4,11 +4,7 @@ import argparse
def parse_inputs(): def parse_inputs():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument( parser.add_argument("flake_path", metavar="flake-path", help="path to flake to evaluate")
"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(
"--keep-hydra", action="store_true", help="allow evaluating Hydra jobs"
)
args = parser.parse_args() args = parser.parse_args()
return 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]: def get_derivations_from_check(nix_path: str, path_to_flake: str) -> list[str]:
flake_check = bash_wrapper( flake_check = bash_wrapper(f"{nix_path} flake check --verbose --keep-going", path=path_to_flake)
f"{nix_path} flake check --verbose --keep-going", path=path_to_flake
)
if flake_check[2] != 0: if flake_check[2] != 0:
logging.warn( logging.warn(
"nix flake check returned non-zero exit code, collecting all available outputs" "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") nix_path = shutil.which("nix")
derivations = [] derivations = []
if nix_path is None: if nix_path is None:
raise RuntimeError( raise RuntimeError("nix is not available in the PATH, please verify that it is installed")
"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) flake_show = bash_wrapper(f"{nix_path} flake show --json", path=path_to_flake)
if flake_show[2] != 0: if flake_show[2] != 0:
logging.error("flake show returned non-zero exit code") logging.error("flake show returned non-zero exit code")

View File

@ -10,19 +10,21 @@ import rad_development_python as rd
def main(): def main():
rd.configure_logger("INFO") rd.configure_logger("INFO")
args = parse_inputs() args = parse_inputs()
print("hi")
flake_path = args.flake_path flake_path = args.flake_path
derivations = get_derivations(flake_path) derivations, hydraJobs = rd.partition(
if ( lambda s: s.startswith("hydraJobs"), get_derivations(flake_path)
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)
logging.info(f"derivations: {list(derivations)}") logging.info(f"derivations: {list(derivations)}")
for d in derivations: for d in derivations:
evaluate_output(flake_path, d) 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__": if __name__ == "__main__":
main() main()

View File

@ -23,6 +23,39 @@ flake-update-diff = "flupdt.main:main"
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
ruff = "0.5.5" ruff = "0.5.5"
[build-system] [build-system]
requires = ["poetry-core"] requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api" build-backend = "poetry.core.masonry.api"
[tool.ruff]
line-length = 100
indent-width = 4
target-version = "py39"
[tool.ruff.lint]
select = ["ALL"]
ignore = [
"ANN101", # (perm) this rule is deprecated
"ANN102", # (perm) this rule is deprecated
"G004", # (perm) this is a performance nit
]
[tool.ruff.lint.per-file-ignores]
"tests/**" = [
"S101", # (perm) pytest needs asserts
]
fixable = ["ALL"]
[tool.ruff.lint.pydocstyle]
convention = "google"
[tool.ruff.lint.pycodestyle]
max-line-length = 120
[tool.ruff.lint.pylint]
max-args = 9