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

parse experiment names with regex (!128)

because the "_environment_" can contain an experiment separator, e.g. `random-fixed`, more powerful `parse` patterns needs to be used.
parent 0b51ce48
No related branches found
No related tags found
1 merge request!128parse experiment names with regex
Pipeline #5305 passed
export const BIN = "./target/release/inbreeding" export const BIN = "./target/release/inbreeding"
export const CACHE = ($nu.home-path | path join .cache komodo inbreeding) export const CACHE = ($nu.home-path | path join .cache komodo inbreeding)
export const ARG_EXPERIMENT_FORMAT = "{seed}-{env}-{k}-{n}-{nb_bytes}" const FMT = {
export const EXPERIMENT_FORMAT = "{timestamp}-{env}-{strategy}-{k}-{n}-{nb_bytes}" env: "(?<env>.*)",
export const FULL_EXPERIMENT_FORMAT = $"{seed}(char path_sep)($EXPERIMENT_FORMAT)" seed: "(?<seed>[a-zA-Z0-9]*)",
params: '(?<k>\d+)-(?<n>\d+)-(?<nb_bytes>\d+)',
timestamp: '(?<timestamp>\d+)',
strat: "(?<strategy>.*)" ,
}
export const ARG_EXPERIMENT_FORMAT = $FMT.seed + '-' + $FMT.env + '-' + $FMT.params
export const EXPERIMENT_FORMAT = $FMT.timestamp + '-' + $FMT.env + '-' + $FMT.strat + '-' + $FMT.params
export const FULL_EXPERIMENT_FORMAT = $FMT.seed + (char path_sep) + $EXPERIMENT_FORMAT
...@@ -25,7 +25,8 @@ export def main [seed: int@get-seeds]: [ ...@@ -25,7 +25,8 @@ export def main [seed: int@get-seeds]: [
| select name m | select name m
| update name { | update name {
remove-cache-prefix remove-cache-prefix
| parse $consts.FULL_EXPERIMENT_FORMAT | parse --regex $consts.FULL_EXPERIMENT_FORMAT
| reject seed
} }
| flatten --all name | flatten --all name
} }
......
...@@ -10,7 +10,7 @@ def get-experiments []: nothing -> list<string> { ...@@ -10,7 +10,7 @@ def get-experiments []: nothing -> list<string> {
| ls $in | ls $in
| get name | get name
| each { remove-cache-prefix } | each { remove-cache-prefix }
| parse $consts.FULL_EXPERIMENT_FORMAT | parse --regex $consts.FULL_EXPERIMENT_FORMAT
| reject timestamp strategy | reject timestamp strategy
| each { values | str join '-' } | each { values | str join '-' }
| uniq | uniq
...@@ -19,7 +19,7 @@ def get-experiments []: nothing -> list<string> { ...@@ -19,7 +19,7 @@ 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 $consts.ARG_EXPERIMENT_FORMAT | into record let exp = $experiment | parse --regex $consts.ARG_EXPERIMENT_FORMAT | into record
if $exp == {} { if $exp == {} {
error throw { error throw {
err: "invalid experiment", err: "invalid experiment",
...@@ -47,7 +47,7 @@ export def main [ ...@@ -47,7 +47,7 @@ export def main [
$experiment_files $experiment_files
| select name | select name
| insert . { get name | remove-cache-prefix | parse $consts.EXPERIMENT_FORMAT } | insert . { get name | remove-cache-prefix | parse --regex $consts.EXPERIMENT_FORMAT }
| flatten --all | flatten --all
| insert diversity { | insert diversity {
ls $in.name ls $in.name
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment