let base_path ?results_dir ~work_dir ~name () =
let name =
String.map name ~f:(function
| '0' .. '9' | 'a' .. 'z' | 'A' .. 'Z' | '-' | '_' as c -> c
| other -> '_') in
match results_dir with
| None -> work_dir // "results" // name
| Some r -> r // name