Skip to content
Snippets Groups Projects
Commit 85f60a29 authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

complete experiment dump paths with k, n, ... (dragoon/komodo!124)

in order to add more information in the experiment names, e.g. $k$, $n$ and $\#\text{bytes}$, this MR changes the cache files format from
```
{seed}/{timestamp}/{env}/{strategy}/...
```
to
```
{seed}/{timestamp}-{env}-{strategy}-{k}-{n}-{nb_bytes}/...
```
parent 45540a7c
No related branches found
No related tags found
No related merge requests found
......@@ -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 }
```
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 }
......
......@@ -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)`"
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment