From b92dfbba572ca433276fc9319fb1319111cc5ae3 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Mon, 23 Aug 2021 12:20:16 -0500 Subject: [PATCH 1/3] Use python3.withPackages to pull in pytest Using the other method leaks into PYTHONPATH. --- flake.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 998772d..bf87bd6 100644 --- a/flake.nix +++ b/flake.nix @@ -16,7 +16,9 @@ defaultPackage = self.packages.${system}.hydra-eval-jobs; devShell = defaultPackage.overrideAttrs (old: { nativeBuildInputs = old.nativeBuildInputs ++ [ - pkgs.python3.pkgs.pytest + (pkgs.python3.withPackages(ps: [ + ps.pytest + ])) ]; }); }); From 19823c899d42a6c26b89770e01768edcacf3329e Mon Sep 17 00:00:00 2001 From: adisbladis Date: Mon, 23 Aug 2021 18:29:04 -0500 Subject: [PATCH 2/3] Add full meta to output While the current output may be sufficient for Hydra it's not enough for a more generically useful evaluator. --- src/hydra-eval-jobs.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/hydra-eval-jobs.cc b/src/hydra-eval-jobs.cc index bcfecb7..c2fdc23 100644 --- a/src/hydra-eval-jobs.cc +++ b/src/hydra-eval-jobs.cc @@ -17,6 +17,8 @@ #include #include +#include + #include #include #include @@ -217,6 +219,16 @@ static void worker( job["maxSilent"] = drv->queryMetaInt("maxSilent", 7200); job["isChannel"] = drv->queryMetaBool("isHydraChannel", false); + nlohmann::json meta; + for (auto & name : drv->queryMetaNames()) { + PathSet context; + std::stringstream ss; + printValueAsJSON(state, true, *drv->queryMeta(name), ss, context); + nlohmann::json field = nlohmann::json::parse(ss.str()); + meta[name] = field; + } + job["meta"] = meta; + /* If this is an aggregate, then get its constituents. */ auto a = v->attrs->get(state.symbols.create("_hydraAggregate")); if (a && state.forceBool(*a->value, *a->pos)) { From 1774f874ee82e184eefc73c470108fe3a37eafc2 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Mon, 23 Aug 2021 18:31:24 -0500 Subject: [PATCH 3/3] Remove superflous meta fields from output Since meta is now included in it's entirety we no longer need to output them separately. --- src/hydra-eval-jobs.cc | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/src/hydra-eval-jobs.cc b/src/hydra-eval-jobs.cc index c2fdc23..8d509ff 100644 --- a/src/hydra-eval-jobs.cc +++ b/src/hydra-eval-jobs.cc @@ -100,31 +100,6 @@ struct MyArgs : MixEvalArgs, MixCommonArgs static MyArgs myArgs; -static std::string queryMetaStrings(EvalState & state, DrvInfo & drv, const string & name, const string & subAttribute) -{ - Strings res; - std::function rec; - - rec = [&](Value & v) { - state.forceValue(v); - if (v.type() == nString) - res.push_back(v.string.s); - else if (v.isList()) - for (unsigned int n = 0; n < v.listSize(); ++n) - rec(*v.listElems()[n]); - else if (v.type() == nAttrs) { - auto a = v.attrs->find(state.symbols.create(subAttribute)); - if (a != v.attrs->end()) - res.push_back(state.forceString(*a->value)); - } - }; - - Value * v = drv.queryMeta(name); - if (v) rec(*v); - - return concatStringsSep(", ", res); -} - static nlohmann::json serializeStorePathSet(StorePathSet &paths, LocalFSStore &store) { auto array = nlohmann::json::array(); for (auto & p : paths) { @@ -210,14 +185,6 @@ static void worker( job["nixName"] = drv->queryName(); job["system"] =drv->querySystem(); job["drvPath"] = drvPath; - job["description"] = drv->queryMetaString("description"); - job["license"] = queryMetaStrings(state, *drv, "license", "shortName"); - job["homepage"] = drv->queryMetaString("homepage"); - job["maintainers"] = queryMetaStrings(state, *drv, "maintainers", "email"); - job["schedulingPriority"] = drv->queryMetaInt("schedulingPriority", 100); - job["timeout"] = drv->queryMetaInt("timeout", 36000); - job["maxSilent"] = drv->queryMetaInt("maxSilent", 7200); - job["isChannel"] = drv->queryMetaBool("isHydraChannel", false); nlohmann::json meta; for (auto & name : drv->queryMetaNames()) {