Skip to content
Snippets Groups Projects

complete experiment dump paths with k, n, ...

Merged STEVAN Antoine requested to merge complete-experiment-path into main
1 file
+ 7
6
Compare changes
  • Side-by-side
  • Inline
+ 7
6
use consts.nu
use consts.nu
use ../../.nushell error "error throw"
use ../../.nushell error "error throw"
const EXPERIMENT_FORMAT = "{seed}-{env}-{k}-{n}-{nb_bytes}"
const ARG_EXPERIMENT_FORMAT = "{seed}-{env}-{k}-{n}-{nb_bytes}"
const FULL_EXPERIMENT_FORMAT = "{seed}/{timestamp}-{env}-{strategy}-{k}-{n}-{nb_bytes}"
const EXPERIMENT_FORMAT = "{timestamp}-{env}-{strategy}-{k}-{n}-{nb_bytes}"
const OTHER_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 {
def remove-cache-prefix []: path -> string {
str replace $"($consts.CACHE)(char path_sep)" ''
str replace $"($consts.CACHE)(char path_sep)" ''
}
}
 
# return experiment names following `$ARG_EXPERIMENT_FORMAT`
def get-experiments []: nothing -> list<string> {
def get-experiments []: nothing -> list<string> {
$consts.CACHE
$consts.CACHE
| path join '*' '*'
| path join '*' '*'
@@ -25,11 +26,11 @@ def get-experiments []: nothing -> list<string> {
@@ -25,11 +26,11 @@ def get-experiments []: nothing -> list<string> {
export def main [
export def main [
experiment: string@get-experiments,
experiment: string@get-experiments,
]: nothing -> table<strategy: string, diversity: table<x: int, y: float, e: float>> {
]: nothing -> table<strategy: string, diversity: table<x: int, y: float, e: float>> {
let exp = $experiment | parse $EXPERIMENT_FORMAT | into record
let exp = $experiment | parse $ARG_EXPERIMENT_FORMAT | into record
if $exp == {} {
if $exp == {} {
error throw {
error throw {
err: "invalid experiment",
err: "invalid experiment",
label: $"should have format '($EXPERIMENT_FORMAT)', found ($experiment)",
label: $"should have format '($ARG_EXPERIMENT_FORMAT)', found ($experiment)",
span: (metadata $experiment).span,
span: (metadata $experiment).span,
}
}
}
}
@@ -53,7 +54,7 @@ export def main [
@@ -53,7 +54,7 @@ export def main [
$experiment_files
$experiment_files
| select name
| select name
| insert foo { get name | remove-cache-prefix | parse $OTHER_EXPERIMENT_FORMAT }
| insert foo { get name | remove-cache-prefix | parse $EXPERIMENT_FORMAT }
| flatten --all
| flatten --all
| insert diversity {
| insert diversity {
ls $in.name
ls $in.name
Loading