2020-10-29 17:44:48 +01:00
|
|
|
{
|
|
|
|
stdenv
|
|
|
|
}:
|
|
|
|
|
|
|
|
{
|
2021-02-24 19:45:47 +01:00
|
|
|
trebuchet,
|
|
|
|
experiment
|
2020-10-29 17:44:48 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
with builtins;
|
|
|
|
|
|
|
|
let
|
2021-02-24 19:45:47 +01:00
|
|
|
experimentName = baseNameOf (experiment);
|
|
|
|
trebuchetName = baseNameOf (trebuchet);
|
2020-10-29 17:44:48 +01:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "resultTree";
|
|
|
|
preferLocalBuild = true;
|
|
|
|
|
|
|
|
phases = [ "installPhase" ];
|
|
|
|
|
|
|
|
installPhase = ''
|
2021-02-24 19:45:47 +01:00
|
|
|
echo "resultTree: searching for garlicd daemon..."
|
|
|
|
if [ -e /garlic/run ]; then
|
|
|
|
echo "resultTree: asking the daemon to run and fetch the experiment"
|
|
|
|
|
|
|
|
echo ${trebuchet} >> /garlic/run
|
|
|
|
echo "resultTree: waiting for experiment results..."
|
|
|
|
res=$(cat /garlic/completed)
|
|
|
|
|
|
|
|
if [ "$res" != "${trebuchet}" ]; then
|
|
|
|
echo "resultTree: unknown trebuchet received"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "resultTree: garlicd not detected: /garlic/run not found"
|
|
|
|
echo "resultTree: assuming results are already in /garlic"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "resultTree: attempting to copy the results from /garlic ..."
|
|
|
|
|
|
|
|
exp=/garlic/cache/${experimentName}
|
2020-10-29 17:44:48 +01:00
|
|
|
|
|
|
|
if [ ! -e "$exp" ]; then
|
2021-02-24 19:45:47 +01:00
|
|
|
echo "resultTree: $exp: not found"
|
2021-02-25 11:18:56 +01:00
|
|
|
echo "resultTree: run the experiment and fetch the results running"
|
|
|
|
echo "resultTree: the following command from the nix-shell"
|
2020-10-29 17:44:48 +01:00
|
|
|
echo
|
2021-02-24 19:45:47 +01:00
|
|
|
echo -e "\e[30;48;5;2mgarlic -RFv ${trebuchet}\e[0m"
|
2020-10-29 17:44:48 +01:00
|
|
|
echo
|
2021-02-24 19:45:47 +01:00
|
|
|
echo "resultTree: see garlic(1) for more details."
|
|
|
|
echo "resultTree: cannot continue building $out, aborting"
|
2020-10-29 17:44:48 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-02-24 19:45:47 +01:00
|
|
|
echo "resultTree: copying results from /garlic into the nix store..."
|
|
|
|
|
2020-10-29 17:44:48 +01:00
|
|
|
mkdir -p $out
|
|
|
|
cp -aL $exp $out/
|
2021-02-24 19:45:47 +01:00
|
|
|
ln -s ${trebuchet} $out/trebuchet
|
|
|
|
ln -s ${experiment} $out/experiment
|
|
|
|
|
|
|
|
|
|
|
|
if [ -e /garlic/run ]; then
|
|
|
|
echo "resultTree: removing temp files..."
|
|
|
|
echo ${trebuchet} >> /garlic/wipe
|
|
|
|
echo "resultTree: waiting confimation from daemon..."
|
|
|
|
cat /garlic/completed > /dev/null
|
|
|
|
else
|
|
|
|
echo "resultTree: garlicd not detected: /garlic/run not found"
|
|
|
|
echo "resultTree: ignoring temp files"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "resultTree: successfully copied into the nix store"
|
|
|
|
|
|
|
|
echo " experiment: ${experiment}"
|
|
|
|
echo " trebuchet: ${trebuchet}"
|
|
|
|
echo " resultTree: $out"
|
2020-10-29 17:44:48 +01:00
|
|
|
'';
|
|
|
|
}
|