Include an index in the trebuchet
This commit is contained in:
parent
45afe7d391
commit
654e243735
@ -101,7 +101,7 @@ let
|
|||||||
isolate = {stage, conf, ...}: with conf; w.isolate {
|
isolate = {stage, conf, ...}: with conf; w.isolate {
|
||||||
program = stageProgram stage;
|
program = stageProgram stage;
|
||||||
clusterName = "mn4";
|
clusterName = "mn4";
|
||||||
inherit nixPrefix;
|
inherit stage nixPrefix;
|
||||||
};
|
};
|
||||||
|
|
||||||
extrae = {stage, conf, ...}: w.extrae {
|
extrae = {stage, conf, ...}: w.extrae {
|
||||||
@ -200,7 +200,8 @@ let
|
|||||||
trebuchet = stage: w.trebuchet {
|
trebuchet = stage: w.trebuchet {
|
||||||
program = stageProgram stage;
|
program = stageProgram stage;
|
||||||
nixPrefix = common.nixPrefix;
|
nixPrefix = common.nixPrefix;
|
||||||
experiment = experiment;
|
#experiment = experiment;
|
||||||
|
inherit stage;
|
||||||
};
|
};
|
||||||
|
|
||||||
isolatedRun = stage: isolate {
|
isolatedRun = stage: isolate {
|
||||||
|
@ -14,6 +14,12 @@ let
|
|||||||
|
|
||||||
unitsString = builtins.concatStringsSep "\n"
|
unitsString = builtins.concatStringsSep "\n"
|
||||||
(map (x: "${stageProgram x}") units);
|
(map (x: "${stageProgram x}") units);
|
||||||
|
|
||||||
|
desc = builtins.concatStringsSep "\n"
|
||||||
|
(map (x: ''
|
||||||
|
# ${x}
|
||||||
|
${x.desc}'') units);
|
||||||
|
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "experiment";
|
name = "experiment";
|
||||||
@ -21,11 +27,14 @@ stdenv.mkDerivation {
|
|||||||
preferLocalBuild = true;
|
preferLocalBuild = true;
|
||||||
dontPatchShebangs = true;
|
dontPatchShebangs = true;
|
||||||
inherit units;
|
inherit units;
|
||||||
|
inherit desc;
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
cat > $out << EOF
|
cat > $out << EOF
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
${desc}
|
||||||
|
|
||||||
# This is an experiment formed by the following units:
|
# This is an experiment formed by the following units:
|
||||||
${unitsString}
|
${unitsString}
|
||||||
EOF
|
EOF
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
program
|
program
|
||||||
|
, stage
|
||||||
, nixPrefix
|
, nixPrefix
|
||||||
, clusterName
|
, clusterName
|
||||||
}:
|
}:
|
||||||
@ -23,6 +24,7 @@ stdenv.mkDerivation {
|
|||||||
dontPatchShebangs = true;
|
dontPatchShebangs = true;
|
||||||
programPath = "/bin/stage1";
|
programPath = "/bin/stage1";
|
||||||
inherit program nixPrefix clusterName nixtools busybox;
|
inherit program nixPrefix clusterName nixtools busybox;
|
||||||
|
desc = "# $out\n" + (if builtins.hasAttr "desc" stage then stage.desc else "");
|
||||||
out = "$out";
|
out = "$out";
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
|
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
{
|
|
||||||
stdenv
|
|
||||||
, nixPrefix ? ""
|
|
||||||
}:
|
|
||||||
|
|
||||||
units:
|
|
||||||
|
|
||||||
with stdenv.lib;
|
|
||||||
|
|
||||||
let
|
|
||||||
|
|
||||||
stageProgram = stage:
|
|
||||||
if stage ? programPath
|
|
||||||
then "${stage}${stage.programPath}" else "${stage}";
|
|
||||||
|
|
||||||
unitsString = builtins.concatStringsSep "\n"
|
|
||||||
(map (x: "${stageProgram x}") units);
|
|
||||||
in
|
|
||||||
stdenv.mkDerivation {
|
|
||||||
name = "experiment";
|
|
||||||
phases = [ "installPhase" ];
|
|
||||||
preferLocalBuild = true;
|
|
||||||
dontPatchShebangs = true;
|
|
||||||
inherit units;
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
cat > $out << EOF
|
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# This is an experiment formed by the following units:
|
|
||||||
${unitsString}
|
|
||||||
EOF
|
|
||||||
chmod +x $out
|
|
||||||
'';
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
{
|
|
||||||
stdenv
|
|
||||||
, nixPrefix ? ""
|
|
||||||
}:
|
|
||||||
|
|
||||||
apps: # Each app must be unique
|
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
|
||||||
name = "launcher";
|
|
||||||
preferLocalBuild = true;
|
|
||||||
|
|
||||||
buildInputs = [] ++ apps;
|
|
||||||
apps = apps;
|
|
||||||
phases = [ "unpackPhase" "patchPhase" "installPhase" ];
|
|
||||||
dontPatchShebangs = true;
|
|
||||||
programPath = "/bin/run";
|
|
||||||
|
|
||||||
src = ./.;
|
|
||||||
|
|
||||||
inherit nixPrefix;
|
|
||||||
|
|
||||||
patchPhase = ''
|
|
||||||
substituteAllInPlace run
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
mkdir -p $out/apps
|
|
||||||
for j in $apps; do
|
|
||||||
target=$out/apps/$(basename $j)
|
|
||||||
if [ -e $target ]; then
|
|
||||||
echo "Duplicated app: $j"
|
|
||||||
echo
|
|
||||||
echo "Provided apps: "
|
|
||||||
printf "%s\n" $apps
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
ln -s $j $target
|
|
||||||
done
|
|
||||||
|
|
||||||
mkdir -p $out/bin
|
|
||||||
install -m755 run $out/bin/run
|
|
||||||
chmod +x $out/bin/*
|
|
||||||
|
|
||||||
# Mark the launcher for upload
|
|
||||||
touch $out/.upload-to-mn
|
|
||||||
# And mark it as an experiment
|
|
||||||
touch $out/.experiment
|
|
||||||
'';
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
#!/bin/sh -ex
|
|
||||||
|
|
||||||
>&2 echo "Running launcher"
|
|
||||||
|
|
||||||
if [ ! -e "/nix" ]; then
|
|
||||||
>&2 echo "missing /nix"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$GARLIC_OUT" ]; then
|
|
||||||
>&2 echo "GARLIC_OUT is not set"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mkdir -p "$GARLIC_OUT"
|
|
||||||
cd "$GARLIC_OUT"
|
|
||||||
|
|
||||||
for j in @out@/apps/*; do
|
|
||||||
$j/bin/run
|
|
||||||
done
|
|
38
garlic/stages/trebuchet.nix
Normal file
38
garlic/stages/trebuchet.nix
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
stdenv
|
||||||
|
, nixtools
|
||||||
|
}:
|
||||||
|
|
||||||
|
{
|
||||||
|
program
|
||||||
|
, nixPrefix
|
||||||
|
, sshHost ? "mn"
|
||||||
|
, targetCluster ? "mn4"
|
||||||
|
, stage
|
||||||
|
}:
|
||||||
|
|
||||||
|
stdenv.mkDerivation {
|
||||||
|
name = "trebuchet";
|
||||||
|
phases = [ "installPhase" ];
|
||||||
|
preferLocalBuild = true;
|
||||||
|
dontPatchShebangs = true;
|
||||||
|
installPhase = ''
|
||||||
|
cat > $out <<EOF
|
||||||
|
#!/bin/sh -e
|
||||||
|
# Using the token @upload-to-mn@ we instruct the post-build hook to upload
|
||||||
|
# this script and it's closure to the MN4 cluster, so it can run there.
|
||||||
|
# Take a look at ${program}
|
||||||
|
# to see what is being executed.
|
||||||
|
|
||||||
|
# $out
|
||||||
|
${stage.desc}
|
||||||
|
|
||||||
|
nixtools=${nixPrefix}${nixtools}/bin
|
||||||
|
runexp=\$nixtools/${targetCluster}/runexp
|
||||||
|
|
||||||
|
>&2 echo "Launching \"\$runexp ${program}\" in MN4"
|
||||||
|
ssh ${sshHost} \$runexp ${program}
|
||||||
|
EOF
|
||||||
|
chmod +x $out
|
||||||
|
'';
|
||||||
|
}
|
@ -1,69 +0,0 @@
|
|||||||
{
|
|
||||||
stdenv
|
|
||||||
, nixtools
|
|
||||||
}:
|
|
||||||
|
|
||||||
{
|
|
||||||
program
|
|
||||||
, nixPrefix
|
|
||||||
, sshHost ? "mn"
|
|
||||||
, targetCluster ? "mn4"
|
|
||||||
, experiment ? ""
|
|
||||||
}:
|
|
||||||
|
|
||||||
with stdenv.lib;
|
|
||||||
|
|
||||||
let
|
|
||||||
|
|
||||||
dStages = foldr (stageFn: {conf, prevStage, stages}: {
|
|
||||||
conf = conf;
|
|
||||||
prevStage = stageFn {stage=prevStage; conf=conf;};
|
|
||||||
stages = [ (stageFn {stage=prevStage; conf=conf;}) ] ++ stages;
|
|
||||||
})
|
|
||||||
{conf=conf; stages=[]; prevStage=null;} stages;
|
|
||||||
|
|
||||||
stageProgram = stage:
|
|
||||||
if stage ? programPath
|
|
||||||
then "${stage}${stage.programPath}" else "${stage}";
|
|
||||||
|
|
||||||
linkStages = imap1 (i: s: {
|
|
||||||
num = "${toString i}";
|
|
||||||
name = "${toString i}-${baseNameOf s.name}";
|
|
||||||
stage = s;
|
|
||||||
programPath = stageProgram s;
|
|
||||||
}) dStages.stages;
|
|
||||||
|
|
||||||
units = builtins.concatStringsSep "\n"
|
|
||||||
(map (x: "# ${x}") experiment.units);
|
|
||||||
|
|
||||||
firstStage = (x: x.programPath) (elemAt linkStages 0);
|
|
||||||
in
|
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
|
||||||
name = "trebuchet";
|
|
||||||
phases = [ "installPhase" ];
|
|
||||||
preferLocalBuild = true;
|
|
||||||
dontPatchShebangs = true;
|
|
||||||
installPhase = ''
|
|
||||||
cat > $out <<EOF
|
|
||||||
#!/bin/sh -e
|
|
||||||
# Using the token @upload-to-mn@ we instruct the post-build hook to upload
|
|
||||||
# this script and it's closure to the MN4 cluster, so it can run there.
|
|
||||||
# Take a look at ${program}
|
|
||||||
# to see what is being executed.
|
|
||||||
|
|
||||||
# Executes the following experiment in MN4:
|
|
||||||
# ${experiment}
|
|
||||||
|
|
||||||
# Which contains the following experiment units:
|
|
||||||
${units}
|
|
||||||
|
|
||||||
nixtools=${nixPrefix}${nixtools}/bin
|
|
||||||
runexp=\$nixtools/${targetCluster}/runexp
|
|
||||||
|
|
||||||
>&2 echo "Launching \"\$runexp ${program}\" in MN4"
|
|
||||||
ssh ${sshHost} \$runexp ${program}
|
|
||||||
EOF
|
|
||||||
chmod +x $out
|
|
||||||
'';
|
|
||||||
}
|
|
@ -30,8 +30,9 @@ let
|
|||||||
programPath = stageProgram s;
|
programPath = stageProgram s;
|
||||||
}) dStages.stages;
|
}) dStages.stages;
|
||||||
|
|
||||||
stageList = builtins.concatStringsSep "\n"
|
desc = builtins.concatStringsSep "\n"
|
||||||
(map (x: "# ${x.stage}") linkStages);
|
(map (x: "# ${x.stage}") linkStages);
|
||||||
|
|
||||||
|
|
||||||
firstStage = (x: x.programPath) (elemAt linkStages 0);
|
firstStage = (x: x.programPath) (elemAt linkStages 0);
|
||||||
in
|
in
|
||||||
@ -39,12 +40,12 @@ stdenv.mkDerivation {
|
|||||||
name = "unit";
|
name = "unit";
|
||||||
preferLocalBuild = true;
|
preferLocalBuild = true;
|
||||||
phases = [ "installPhase" ];
|
phases = [ "installPhase" ];
|
||||||
|
inherit desc;
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
cat > $out << EOF
|
cat > $out << EOF
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
# This script defines an experimental unit with the following stages:
|
${desc}
|
||||||
${stageList}
|
|
||||||
|
|
||||||
# Set the experiment unit in the environment
|
# Set the experiment unit in the environment
|
||||||
export GARLIC_UNIT=$(basename $out)
|
export GARLIC_UNIT=$(basename $out)
|
||||||
|
@ -207,10 +207,10 @@ let
|
|||||||
envRecord = callPackage ./garlic/stages/envRecord.nix { };
|
envRecord = callPackage ./garlic/stages/envRecord.nix { };
|
||||||
valgrind = callPackage ./garlic/stages/valgrind.nix { };
|
valgrind = callPackage ./garlic/stages/valgrind.nix { };
|
||||||
isolate = callPackage ./garlic/stages/isolate { };
|
isolate = callPackage ./garlic/stages/isolate { };
|
||||||
trebuchet = callPackage ./garlic/stages/trebuchet { };
|
trebuchet = callPackage ./garlic/stages/trebuchet.nix { };
|
||||||
strace = callPackage ./garlic/stages/strace.nix { };
|
strace = callPackage ./garlic/stages/strace.nix { };
|
||||||
unit = callPackage ./garlic/stages/unit.nix { };
|
unit = callPackage ./garlic/stages/unit.nix { };
|
||||||
experiment= callPackage ./garlic/stages/experiment/default.nix { };
|
experiment= callPackage ./garlic/stages/experiment.nix { };
|
||||||
};
|
};
|
||||||
|
|
||||||
# Tests (move to bsc ?)
|
# Tests (move to bsc ?)
|
||||||
|
Loading…
Reference in New Issue
Block a user