Skip to content

Commit c92a5c7

Browse files
authored
nix: build with parallelism feature (#167)
2 parents 115f80d + 513141d commit c92a5c7

File tree

5 files changed

+81
-43
lines changed

5 files changed

+81
-43
lines changed

.config/nextest.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
11
[profile.default]
22
slow-timeout = { period = "30s", terminate-after = 3 }
3+
4+
# the default profile runs ALL tests,
5+
# the CI runs everything except parallel & decentralized,
6+
# and there's a decentralized & parallel section to cover the gap
7+
# parallelism tests require more than one gpu.
8+
# psyche-decentralized-testing tests are slow and laborious.
9+
10+
[profile.ci]
11+
slow-timeout = { period = "30s", terminate-after = 3 }
12+
default-filter = 'not (package(psyche-modeling) and test(parallelism::)) and not package(psyche-decentralized-testing)'
13+
fail-fast = false
14+
15+
[profile.decentralized]
16+
slow-timeout = { period = "60s", terminate-after = 3 }
17+
default-filter = 'package(psyche-decentralized-testing)'
18+
19+
[profile.parallelism]
20+
slow-timeout = { period = "30s", terminate-after = 3 }
21+
default-filter = 'package(psyche-modeling) and test(parallelism::)'

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,6 @@ rstest = "0.25.0"
111111

112112
[profile.dev]
113113
opt-level = 1
114+
115+
[profile.test]
116+
opt-level = 1

garnix.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ builds:
2222
# only build the rust packages explicitly!
2323
# all other packages like the book are built via deployments, etc
2424
# and duplicating work in garnix causes big big compute overspend.
25-
- exclude: []
25+
- exclude:
26+
- 'checks.x86_64-linux.workspace-test-all'
27+
- 'checks.x86_64-linux.workspace-test-decentralized'
28+
- 'checks.x86_64-linux.workspace-test-parallelism'
2629
include:
2730
- 'packages.x86_64-linux.psyche-solana-client'
2831
- 'packages.x86_64-linux.psyche-centralized-client'
@@ -32,7 +35,7 @@ builds:
3235
- 'packages.x86_64-linux.expand-distro'
3336
- devShells.x86_64-linux.default
3437
- devShells.aarch64-darwin.default
35-
- nixosConfigurations.*
38+
- 'nixosConfigurations.*'
3639
- 'checks.x86_64-linux.*'
3740

3841
# on main, might as well build everything, though

nix/checks.nix

Lines changed: 52 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,50 +16,63 @@
1616
;
1717
in
1818
{
19-
checks = {
20-
workspace-clippy = craneLib.cargoClippy (
21-
rustWorkspaceArgs
22-
// {
23-
inherit cargoArtifacts;
24-
cargoClippyExtraArgs = "--workspace -- --deny warnings";
25-
}
26-
);
19+
checks =
20+
let
21+
testWithProfile =
22+
profile:
23+
craneLib.cargoNextest (
24+
rustWorkspaceArgsWithPython
25+
// {
26+
inherit cargoArtifacts;
2727

28-
workspace-test = craneLib.cargoNextest (
29-
rustWorkspaceArgsWithPython
30-
// {
31-
inherit cargoArtifacts;
32-
RUST_LOG = "info,psyche=trace";
33-
partitions = 1;
34-
partitionType = "count";
35-
cargoNextestExtraArgs = "--workspace --exclude psyche-decentralized-testing";
36-
}
37-
);
28+
RUST_LOG = "info,psyche=trace";
29+
partitions = 1;
30+
partitionType = "count";
31+
cargoNextestExtraArgs = "--workspace --profile ${profile}";
32+
}
33+
);
34+
in
35+
{
36+
workspace-clippy = craneLib.cargoClippy (
37+
rustWorkspaceArgs
38+
// {
39+
inherit cargoArtifacts;
40+
cargoClippyExtraArgs = "--workspace -- --deny warnings";
41+
}
42+
);
3843

39-
validate-all-configs =
40-
pkgs.runCommandNoCC "validate-configs"
41-
{ nativeBuildInputs = [ self'.packages.psyche-centralized-server ]; }
42-
''
43-
dir="${../config}"
44-
if [ ! -d "$dir" ]; then
45-
echo "config dir $dir does not exist."
46-
exit 1
47-
fi
44+
workspace-test-all = testWithProfile "default";
4845

49-
for f in $dir/*; do
50-
if [ -f $f/data.toml ]; then
51-
psyche-centralized-server validate-config --state $f/state.toml --data-config $f/data.toml || exit 1
52-
echo "config $f/data.toml and $f/state.toml ok!"
53-
else
54-
psyche-centralized-server validate-config --state $f/state.toml|| exit 1
55-
echo "config $f/state.toml ok!"
46+
workspace-test-ci = testWithProfile "ci";
47+
48+
workspace-test-decentralized = testWithProfile "decentralized";
49+
50+
workspace-test-parallelism = testWithProfile "parallelism";
51+
52+
validate-all-configs =
53+
pkgs.runCommandNoCC "validate-configs"
54+
{ nativeBuildInputs = [ self'.packages.psyche-centralized-server ]; }
55+
''
56+
dir="${../config}"
57+
if [ ! -d "$dir" ]; then
58+
echo "config dir $dir does not exist."
59+
exit 1
5660
fi
57-
done;
5861
59-
echo "all configs ok!"
62+
for f in $dir/*; do
63+
if [ -f $f/data.toml ]; then
64+
psyche-centralized-server validate-config --state $f/state.toml --data-config $f/data.toml || exit 1
65+
echo "config $f/data.toml and $f/state.toml ok!"
66+
else
67+
psyche-centralized-server validate-config --state $f/state.toml|| exit 1
68+
echo "config $f/state.toml ok!"
69+
fi
70+
done;
71+
72+
echo "all configs ok!"
6073
61-
touch $out
62-
'';
63-
};
74+
touch $out
75+
'';
76+
};
6477
};
6578
}

nix/lib.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ let
5757
rustWorkspaceArgs = rustWorkspaceDeps // {
5858
inherit env src;
5959
strictDeps = true;
60-
cargoExtraArgs = "--features python-extension";
60+
cargoExtraArgs = "--features python-extension,parallelism";
6161
};
6262

6363
rustWorkspaceArgsWithPython = rustWorkspaceArgs // {
@@ -100,7 +100,7 @@ let
100100
craneLib.buildPackage (
101101
rustWorkspaceArgs
102102
// {
103-
inherit cargoArtifacts;
103+
cargoExtraArgs = ""; # *remove* features - we don't want the cuda stuff in here.
104104
pname = name;
105105
doCheck = false;
106106

0 commit comments

Comments
 (0)