diff --git a/garlic/postprocess/fetch.nix b/garlic/postprocess/fetch.nix new file mode 100644 index 0000000..32460f8 --- /dev/null +++ b/garlic/postprocess/fetch.nix @@ -0,0 +1,47 @@ +{ + stdenv +, rsync +, openssh +, nix +, curl +, garlicTools +}: + +{ + sshHost +, prefix +, experiment +, garlicTemp +}: + +with garlicTools; + +let + experimentStage = getExperimentStage experiment; + experimentName = baseNameOf (toString experimentStage); +in + stdenv.mkDerivation { + name = "fetch"; + preferLocalBuild = true; + + buildInputs = [ rsync openssh curl ]; + phases = [ "installPhase" ]; + + installPhase = '' + cat > $out << EOF + #!/bin/sh -e + mkdir -p ${garlicTemp} + export PATH=${rsync}/bin:${openssh}/bin:${nix}/bin + rsync -av \ + --include='*/*/*.log' --include='*/*/*.json' --exclude='*/*/*' \ + '${sshHost}:${prefix}/${experimentName}' ${garlicTemp} + + res=\$(nix-build -E '(with import ./default.nix; garlic.getExpResult \ + {experiment = "${experiment}"; garlicTemp = "${garlicTemp}"; })') + + echo "The results for experiment ${experimentName} are at:" + echo " \$res" + EOF + chmod +x $out + ''; + } diff --git a/garlic/postprocess/filter/fetch b/garlic/postprocess/filter/fetch deleted file mode 100755 index 8890c29..0000000 --- a/garlic/postprocess/filter/fetch +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -rsync -a mn1:go/$1 . diff --git a/garlic/postprocess/filter/filter b/garlic/postprocess/filter/filter deleted file mode 100755 index 78527bc..0000000 --- a/garlic/postprocess/filter/filter +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -for unit in $1/*; do - #echo unit=$unit - bs=$(jq ".blocksize" "$unit/garlic_config.json") - #echo bs=$bs - - awk '/^time /{print $2}' > time.$bs $unit/stdout.log - - N=$(wc -l "time.$bs" | awk '{print $1}') - #echo N=$N - - if [ $N -lt 30 ]; then - echo "too few points ($N) in unit $unit" - #exit 1 - fi - -done diff --git a/garlic/postprocess/filter/plot.gnuplot b/garlic/postprocess/filter/plot.gnuplot deleted file mode 100644 index a9abefc..0000000 --- a/garlic/postprocess/filter/plot.gnuplot +++ /dev/null @@ -1,17 +0,0 @@ -set terminal png size 800,800 -set output 'out.png' - -set xrange [16:1024] -set nokey -set logscale x 2 -set logscale y 2 -set grid - -set xlabel "blocksize" -set ylabel "time (s)" - -plot 'time.32' using (32):1 with circles title "32", \ - 'time.64' using (64):1 with circles title "64", \ - 'time.128' using (128):1 with circles title "128", \ - 'time.256' using (256):1 with circles title "256", \ - 'time.512' using (512):1 with circles title "512" diff --git a/garlic/postprocess/result.nix b/garlic/postprocess/result.nix new file mode 100644 index 0000000..272884e --- /dev/null +++ b/garlic/postprocess/result.nix @@ -0,0 +1,43 @@ +{ + stdenv +, garlicTools +, fetchExperiment +}: + +{ + experiment +, garlicTemp +}: + +with garlicTools; + +let + experimentStage = getExperimentStage experiment; + experimentName = baseNameOf (toString experimentStage); + fetcher = fetchExperiment { + sshHost = "mn1"; + prefix = "/gpfs/projects/\\\$(id -gn)/\\\$(id -un)/garlic-out"; + garlicTemp = "/tmp/garlic-temp"; + inherit experiment; + }; +in + stdenv.mkDerivation { + name = "result"; + preferLocalBuild = true; + __noChroot = true; + + phases = [ "installPhase" ]; + + installPhase = '' + expPath=${garlicTemp}/${experimentName} + if [ ! -e $expPath ]; then + echo "The experiment ${experimentName} is missing in ${garlicTemp}." + echo "Please fetch it and try again." + echo "You can execute ${experiment} to run the experiment." + echo "And then ${fetcher} to get the results." + exit 1 + fi + mkdir -p $out + cp -a ${garlicTemp}/${experimentName} $out + ''; + } diff --git a/garlic/tools.nix b/garlic/tools.nix index 7316fff..342a877 100644 --- a/garlic/tools.nix +++ b/garlic/tools.nix @@ -39,6 +39,8 @@ let then "${stage}${stage.programPath}" else "${stage}"; + /* Given a trebuchet, returns the experiment */ + getExperimentStage = drv: drv.nextStage.nextStage.nextStage; }; in gen