diff --git a/garlic/ds/ctf/mode.py b/garlic/ds/ctf-mode.py similarity index 100% rename from garlic/ds/ctf/mode.py rename to garlic/ds/ctf-mode.py diff --git a/garlic/ds/ctf/mode.nix b/garlic/ds/ctf/mode.nix deleted file mode 100644 index d3348eb..0000000 --- a/garlic/ds/ctf/mode.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ - stdenv -, python3 -, gzip -}: - -resultTree: - -stdenv.mkDerivation { - name = "ctf-mode.json.gz"; - preferLocalBuild = true; - src = ./mode.py; - phases = [ "unpackPhase" "installPhase" ]; - - unpackPhase = '' - cp $src mode.py - ''; - - buildInputs = [ python3 gzip ]; - installPhase = '' - python mode.py ${resultTree} | gzip > $out - ''; -} diff --git a/garlic/ds/index.nix b/garlic/ds/index.nix index b0dc7ec..95cb388 100644 --- a/garlic/ds/index.nix +++ b/garlic/ds/index.nix @@ -6,17 +6,13 @@ , callPackage }: -{ - std = { - timetable = callPackage ./std/timetable.nix {}; - }; +rec { - osu = { - latency = callPackage ./osu/latency.nix {}; - bw = callPackage ./osu/bw.nix {}; - }; + py = callPackage ./py.nix {}; - perf.stat = callPackage ./perf/stat.nix {}; - - ctf.mode = callPackage ./ctf/mode.nix {}; + std.timetable = py { script = ./std-timetable.py; compress = false; }; + osu.latency = py { script = ./osu-latency.py; }; + osu.bw = py { script = ./osu-bw.py; }; + perf.stat = py { script = ./perf-stat.py; }; + ctf.mode = py { script = ./ctf-mode.py; }; } diff --git a/garlic/ds/osu/bw.py b/garlic/ds/osu-bw.py similarity index 100% rename from garlic/ds/osu/bw.py rename to garlic/ds/osu-bw.py diff --git a/garlic/ds/osu/latency.py b/garlic/ds/osu-latency.py similarity index 100% rename from garlic/ds/osu/latency.py rename to garlic/ds/osu-latency.py diff --git a/garlic/ds/osu/bw.nix b/garlic/ds/osu/bw.nix deleted file mode 100644 index 9426998..0000000 --- a/garlic/ds/osu/bw.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ - stdenv -, python3 -, gzip -}: - -resultTree: - -stdenv.mkDerivation { - name = "osu-bw.json.gz"; - preferLocalBuild = true; - src = ./bw.py; - phases = [ "unpackPhase" "installPhase" ]; - - unpackPhase = '' - cp $src bw.py - ''; - - buildInputs = [ python3 gzip ]; - installPhase = '' - python bw.py ${resultTree} | gzip > $out - ''; -} diff --git a/garlic/ds/osu/latency.nix b/garlic/ds/osu/latency.nix deleted file mode 100644 index 3fe0426..0000000 --- a/garlic/ds/osu/latency.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ - stdenv -, python3 -, gzip -}: - -resultTree: - -stdenv.mkDerivation { - name = "osu-latency.json.gz"; - preferLocalBuild = true; - src = ./latency.py; - phases = [ "unpackPhase" "installPhase" ]; - - unpackPhase = '' - cp $src latency.py - ''; - - buildInputs = [ python3 gzip ]; - installPhase = '' - python latency.py ${resultTree} | gzip > $out - ''; -} diff --git a/garlic/ds/perf/stat.py b/garlic/ds/perf-stat.py similarity index 100% rename from garlic/ds/perf/stat.py rename to garlic/ds/perf-stat.py diff --git a/garlic/ds/perf/stat.nix b/garlic/ds/perf/stat.nix deleted file mode 100644 index 14b55c4..0000000 --- a/garlic/ds/perf/stat.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ - stdenv -, python3 -, gzip -}: - -resultTree: - -stdenv.mkDerivation { - name = "perf-stat.json.gz"; - preferLocalBuild = true; - src = ./stat.py; - phases = [ "unpackPhase" "installPhase" ]; - - unpackPhase = '' - cp $src stat.py - ''; - - buildInputs = [ python3 gzip ]; - installPhase = '' - python stat.py ${resultTree} | gzip > $out - ''; -} diff --git a/garlic/ds/py.nix b/garlic/ds/py.nix new file mode 100644 index 0000000..012a159 --- /dev/null +++ b/garlic/ds/py.nix @@ -0,0 +1,34 @@ +{ + stdenv +, python3 +, gzip +}: + +{ + script, + compress ? true +}: + +tree: + +stdenv.mkDerivation { + name = "dataset"; + preferLocalBuild = true; + phases = [ "installPhase" ]; + buildInputs = [ python3 gzip ]; + installPhase = '' + mkdir -p $out + ln -s ${tree} $out/tree + ln -s ${script} $out/script + + COMPRESS_DATASET=${toString compress} + + if [ $COMPRESS_DATASET ]; then + python $out/script $out/tree | gzip > $out/dataset.json.gz + ln -s dataset.json.gz $out/dataset + else + python $out/script $out/tree > $out/dataset.json + ln -s dataset.json $out/dataset + fi + ''; +} diff --git a/garlic/ds/std/timetable.py b/garlic/ds/std-timetable.py similarity index 100% rename from garlic/ds/std/timetable.py rename to garlic/ds/std-timetable.py diff --git a/garlic/ds/std/timetable.nix b/garlic/ds/std/timetable.nix deleted file mode 100644 index 496dc58..0000000 --- a/garlic/ds/std/timetable.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ - stdenv -, python3 -}: - -resultTree: - -stdenv.mkDerivation { - name = "timetable.json"; - preferLocalBuild = true; - src = ./timetable.py; - phases = [ "unpackPhase" "installPhase" ]; - - unpackPhase = '' - cp $src timetable.py - ''; - - buildInputs = [ python3 ]; - installPhase = '' - touch $out - python timetable.py ${resultTree} > $out - ''; -} diff --git a/garlic/pp/merge.nix b/garlic/pp/merge.nix index bd83c46..7f8919d 100644 --- a/garlic/pp/merge.nix +++ b/garlic/pp/merge.nix @@ -2,15 +2,22 @@ stdenv }: -experiments: +datasets: with stdenv.lib; stdenv.mkDerivation { - name = "merge.json"; + name = "merged-dataset"; preferLocalBuild = true; phases = [ "installPhase" ]; + inherit datasets; installPhase = '' - cat ${concatStringsSep " " experiments} >> $out + mkdir -p $out + n=1 + for d in $datasets; do + ln -s $d $out/$n + let n=n+1 + cat $d/dataset >> $out/dataset + done ''; } diff --git a/garlic/pp/rplot.nix b/garlic/pp/rplot.nix index cf194b6..28704d1 100644 --- a/garlic/pp/rplot.nix +++ b/garlic/pp/rplot.nix @@ -144,10 +144,10 @@ in stdenv.mkDerivation { mkdir -p $out cd $out - dataset="${dataset}" + dataset=$(readlink -f ${dataset}/dataset) ln -s $dataset input - Rscript --vanilla ${script} ${dataset} "$out" + Rscript --vanilla ${script} "$dataset" "$out" # HACK: replace the \minus for a \hyphen to keep the file paths intact, so # they can be copied to the terminal directly. The StandardEncoding is not