WIP: Testing with automatic fetching

This commit is contained in:
2020-10-26 19:43:02 +01:00
parent 59346fa97e
commit 3bd4e61f3f
7 changed files with 149 additions and 20 deletions

33
garlic/pp/check.nix Normal file
View File

@@ -0,0 +1,33 @@
{
stdenv
}:
resultTree:
stdenv.mkDerivation {
name = "check";
preferLocalBuild = true;
phases = [ "installPhase" ];
installPhase = ''
echo "checking result tree: ${resultTree}"
cd ${resultTree}
for exp in *-experiment; do
cd ${resultTree}/$exp
echo "$exp: checking units"
for unit in *-unit; do
cd ${resultTree}/$exp/$unit
if [ ! -e status ]; then
echo "missing $unit/status file, aborting"
exit 1
fi
st=$(cat status)
if [ "$st" != "completed" ]; then
echo "unit $unit is not complete yet, aborting"
exit 1
fi
done
echo "$exp: execution complete"
done
ln -s $out ${resultTree}
'';
}

View File

@@ -31,14 +31,17 @@ in
name = "fetch";
preferLocalBuild = true;
buildInputs = [ rsync openssh curl ];
buildInputs = [ rsync openssh curl nix ];
phases = [ "installPhase" ];
# This doesn't work when multiple users have different directories where the
# results are stored.
#src = /. + "${prefix}${experimentName}";
installPhase = ''
cat > $out << EOF
#!/bin/sh -e
mkdir -p ${garlicTemp}
export PATH=${rsync}/bin:${openssh}/bin:${nix}/bin
export PATH=$PATH
rsync -av \
--copy-links \
${rsyncFilter} \
@@ -50,8 +53,11 @@ in
garlicTemp = "${garlicTemp}"; \
})')
rm -rf ${garlicTemp}/${experimentName}
echo "The results for experiment ${experimentName} are at:"
echo " \$res"
EOF
chmod +x $out
'';

81
garlic/pp/result2.nix Normal file
View File

@@ -0,0 +1,81 @@
{
stdenv
, garlicTools
}:
{
trebuchetStage
, experimentStage
, garlicTemp
}:
with garlicTools;
let
experimentName = baseNameOf (toString experimentStage);
garlicOut = "/mnt/garlic-out";
in
stdenv.mkDerivation {
name = "result";
preferLocalBuild = true;
__noChroot = true;
phases = [ "installPhase" ];
installPhase = ''
expList=$(find ${garlicOut} -maxdepth 2 -name ${experimentName})
if [ -z "$expList" ]; then
echo "ERROR: missing results for ${experimentName}"
echo "Execute it by running:"
echo
echo -e " \e[30;48;5;2m${trebuchetStage}\e[0m"
echo
echo "cannot continue building $out, aborting"
exit 1
fi
N=$(echo $expList | wc -l)
echo "Found $N results: $expList"
if [ $N -gt 1 ]; then
echo
echo "ERROR: multiple results for ${experimentName}:"
echo "$expList"
echo
echo "cannot continue building $out, aborting"
exit 1
fi
exp=$expList
repeat=1
while [ 1 ]; do
repeat=0
cd $exp
echo "$exp: checking units"
for unit in *-unit; do
cd $exp/$unit
if [ ! -e status ]; then
echo "$unit: no status"
repeat=1
else
st=$(cat status)
echo "$unit: $st"
if [ "$st" != "completed" ]; then
repeat=1
fi
fi
done
if [ $repeat -eq 0 ]; then
break
fi
echo "waiting 10 seconds to try again"
sleep 10
done
echo "$exp: execution complete"
mkdir -p $out
cp -aL $exp $out
'';
}