Skip to content

Commit

Permalink
ci/eval: add rebuildsByPlatform to the comparison result
Browse files Browse the repository at this point in the history
  • Loading branch information
GaetanLepage authored and Mic92 committed Dec 12, 2024
1 parent cb815df commit 4e7ee5b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 20 deletions.
8 changes: 6 additions & 2 deletions ci/eval/compare/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ let
inherit (import ./utils.nix { inherit lib; })
diff
groupByKernel
processSystemPath
groupByPlatform
extractPackageNames
getLabels
uniqueStrings
Expand All @@ -25,16 +27,18 @@ let
changed-paths =
let
rebuilds = uniqueStrings (diffAttrs.added ++ diffAttrs.changed);
rebuildsAttrs = builtins.map processSystemPath rebuilds;

rebuildsByKernel = groupByKernel rebuilds;
rebuildsByPlatform = groupByPlatform rebuildsAttrs;
rebuildsByKernel = groupByKernel rebuildsAttrs;
rebuildCountByKernel = lib.mapAttrs (
kernel: kernelRebuilds: lib.length kernelRebuilds
) rebuildsByKernel;
in
writeText "changed-paths.json" (
builtins.toJSON {
attrdiff = lib.mapAttrs (_: v: extractPackageNames v) diffAttrs;
inherit rebuildsByKernel rebuildCountByKernel;
inherit rebuildsByPlatform rebuildsByKernel rebuildCountByKernel;
labels = getLabels rebuildCountByKernel;
}
);
Expand Down
62 changes: 44 additions & 18 deletions ci/eval/compare/utils.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ rec {
# Borrowed from https://github.com/NixOS/nixpkgs/pull/355616
uniqueStrings = list: builtins.attrNames (builtins.groupBy lib.id list);

_processSystemPath =
# Turns
# "hello.aarch64-linux"
# into
# {
# name = "hello";
# system = "aarch64-linux";
# }
processSystemPath =
packageSystemPath:
let
# python312Packages.torch.aarch64-linux -> ["python312Packages" "torch" "aarch64-linux"]
Expand Down Expand Up @@ -41,7 +48,7 @@ rec {
packageSystemPaths:
builtins.attrNames (
builtins.removeAttrs (builtins.groupBy (
packageSystemPath: (_processSystemPath packageSystemPath).name
packageSystemPath: (processSystemPath packageSystemPath).name
) packageSystemPaths) [ "" ]
);

Expand Down Expand Up @@ -71,35 +78,54 @@ rec {

# Turns
# [
# "hello.aarch64-linux"
# "hello.x86_64-linux"
# "hello.aarch64-darwin"
# "hello.x86_64-darwin"
# "bye.x86_64-darwin"
# "bye.aarch64-darwin"
# { name = "hello"; system = "aarch64-linux"; }
# { name = "hello"; system = "x86_64-linux"; }
# { name = "hello"; system = "aarch64-darwin"; }
# { name = "hello"; system = "x86_64-darwin"; }
# { name = "bye"; system = "aarch64-darwin"; }
# { name = "bye"; system = "x86_64-darwin"; }
# ]
#
# into
#
# {
# linux = [
# "hello"
# ];
# darwin = [
# "hello"
# "bye"
# ];
# aarch64-linux = [ "hello" ];
# x86_64-linux = [ "hello" ];
# aarch64-darwin = [ "hello" "bye" ];
# x86_64-darwin = [ "hello" "bye" ];
# }
groupByKernel =
groupByPlatform =
systemPaths:
let
systemPaths' = builtins.map _processSystemPath systemPaths;
systemPathsByPlatform = builtins.groupBy (systemPath: systemPath.system) systemPaths;
extractPackageNames = map (systemPath: systemPath.name);
in
lib.mapAttrs (_: extractPackageNames) systemPathsByPlatform;

# Turns
# [
# { name = "hello"; system = "aarch64-linux"; }
# { name = "hello"; system = "x86_64-linux"; }
# { name = "hello"; system = "aarch64-darwin"; }
# { name = "hello"; system = "x86_64-darwin"; }
# { name = "bye"; system = "aarch64-darwin"; }
# { name = "bye"; system = "x86_64-darwin"; }
# ]
#
# into
#
# {
# linux = [ "hello" ];
# darwin = [ "hello" "bye" ];
# }
groupByKernel =
systemPaths:
let
filterKernel =
kernel:
builtins.attrNames (
builtins.groupBy (systemPath: systemPath.name) (
builtins.filter (systemPath: lib.hasSuffix kernel systemPath.system) systemPaths'
builtins.filter (systemPath: lib.hasSuffix kernel systemPath.system) systemPaths
)
);
in
Expand Down

0 comments on commit 4e7ee5b

Please sign in to comment.