From 2680dcb66ff1f465ee40ad8910889304b55134fb Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Fri, 16 Oct 2020 15:51:05 +0200 Subject: [PATCH] Don't nest the unit results The experiment directory now contains symlinks to the units, keeping the old structure. The unit results are directly placed in the garlic out directory. --- garlic/stages/experiment.nix | 13 ++++++++++--- garlic/stages/unit.nix | 12 ++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/garlic/stages/experiment.nix b/garlic/stages/experiment.nix index 0195780..95535e8 100644 --- a/garlic/stages/experiment.nix +++ b/garlic/stages/experiment.nix @@ -13,6 +13,9 @@ with garlicTools; let unitsString = builtins.concatStringsSep "\n" (map (x: "${stageProgram x}") units); + + unitsLinks = builtins.concatStringsSep "\n" + (map (x: "ln -s ../${baseNameOf x} ${baseNameOf x}") units); in stdenv.mkDerivation { name = "experiment"; @@ -30,16 +33,20 @@ stdenv.mkDerivation { exit 1 fi + cd "\$GARLIC_OUT" + export GARLIC_EXPERIMENT=$(basename $out) - echo "Running experiment \$GARLIC_EXPERIMENT" if [ -e "\$GARLIC_EXPERIMENT" ]; then - >&2 echo "Already exists \$GARLIC_EXPERIMENT, aborting" - exit 1 + >&2 echo "skipping, experiment path already exists: \$GARLIC_EXPERIMENT" + exit 0 fi mkdir -p "\$GARLIC_EXPERIMENT" cd "\$GARLIC_EXPERIMENT" + ${unitsLinks} + + echo "Running experiment \$GARLIC_EXPERIMENT" # This is an experiment formed by the following units: ${unitsString} diff --git a/garlic/stages/unit.nix b/garlic/stages/unit.nix index 87650f8..3f32f37 100644 --- a/garlic/stages/unit.nix +++ b/garlic/stages/unit.nix @@ -50,9 +50,21 @@ stdenv.mkDerivation { ${desc} + if [ -z "\$GARLIC_OUT" ]; then + >&2 echo "GARLIC_OUT not defined, aborting" + exit 1 + fi + + cd "\$GARLIC_OUT" + # Set the experiment unit in the environment export GARLIC_UNIT=$(basename $out) + if [ -e "\$GARLIC_UNIT" ]; then + >&2 echo "skipping, unit path already exists: \$GARLIC_UNIT" + exit 0 + fi + # And change the working directory mkdir \$GARLIC_UNIT cd \$GARLIC_UNIT