diff --git a/bins/inbreeding/README.md b/bins/inbreeding/README.md index 4519a70cea276e8ea453976b6c57897da53e5718..dc77e786db6f26a0228b1dafb953373448b8a443 100644 --- a/bins/inbreeding/README.md +++ b/bins/inbreeding/README.md @@ -36,6 +36,6 @@ inbreeding build inbreeding run --options $OPTS --prng-seed $PRNG_SEED ``` ```bash -let experiment = $"($PRNG_SEED)-($OPTS.environment)" +let experiment = $"($PRNG_SEED)-($OPTS.environment)-($OPTS.k)-($OPTS.n)-($OPTS.nb_bytes)" inbreeding load $experiment | inbreeding plot --options { k: $OPTS.k } ``` diff --git a/bins/inbreeding/load.nu b/bins/inbreeding/load.nu index b0437ca6fdfe4fc3d51d5bc2428944a4ff83bc13..9537b96b7ffce8688132fecd65ca7f05cf311172 100644 --- a/bins/inbreeding/load.nu +++ b/bins/inbreeding/load.nu @@ -1,29 +1,45 @@ use consts.nu +use ../../.nushell error "error throw" +const ARG_EXPERIMENT_FORMAT = "{seed}-{env}-{k}-{n}-{nb_bytes}" +const EXPERIMENT_FORMAT = "{timestamp}-{env}-{strategy}-{k}-{n}-{nb_bytes}" +const FULL_EXPERIMENT_FORMAT = $"{seed}(char path_sep)($EXPERIMENT_FORMAT)" + +def remove-cache-prefix []: path -> string { + str replace $"($consts.CACHE)(char path_sep)" '' +} + +# return experiment names following `$ARG_EXPERIMENT_FORMAT` def get-experiments []: nothing -> list<string> { $consts.CACHE - | path join '*' '*' '*' + | path join '*' '*' | into glob | ls $in | get name - | path split - | each { last 3 | reject 1 | str join "-" } + | each { remove-cache-prefix } + | parse $FULL_EXPERIMENT_FORMAT + | reject timestamp strategy + | each { values | str join '-' } | uniq } export def main [ - experiment: string@get-experiments, # something of the form '<seed>-<env>' + experiment: string@get-experiments, ]: nothing -> table<strategy: string, diversity: table<x: int, y: float, e: float>> { - let exp = $experiment | parse "{seed}-{env}" | into record + let exp = $experiment | parse $ARG_EXPERIMENT_FORMAT | into record if $exp == {} { error throw { err: "invalid experiment", - label: $"should have format '<seed>-<env>', found ($experiment)", + label: $"should have format '($ARG_EXPERIMENT_FORMAT)', found ($experiment)", span: (metadata $experiment).span, } } - let experiment_path = [$consts.CACHE, $exp.seed, '*', $exp.env, '*' ] + let experiment_path = [ + $consts.CACHE, + $exp.seed, + (['*', $exp.env, '*', $exp.k, $exp.n, $exp.nb_bytes] | str join '-') + ] | path join | into glob let experiment_files = try { @@ -37,8 +53,9 @@ export def main [ } $experiment_files - | insert strategy { get name | path split | last } - | select name strategy + | select name + | insert . { get name | remove-cache-prefix | parse $EXPERIMENT_FORMAT } + | flatten --all | insert diversity { ls $in.name | each { get name | open | lines } diff --git a/bins/inbreeding/run.nu b/bins/inbreeding/run.nu index f18f72c17d3338606a81fc7fc9c41a923ba12729..5b01dfce6a0d5535322e6db825a9beb746ab96bc 100644 --- a/bins/inbreeding/run.nu +++ b/bins/inbreeding/run.nu @@ -25,7 +25,11 @@ export def main [ let now = date now | format date "%s%f" for s in $options.strategies { - let output_dir = [ $consts.CACHE, $"($prng_seed)", $now, $options.environment, $"($s)" ] | path join + let output_dir = [ + $consts.CACHE, + $"($prng_seed)", + ([$now, $options.environment, $s, $options.k, $options.n, $options.nb_bytes] | str join '-') + ] | path join mkdir $output_dir print $"data will be dumped to `($output_dir)`"