-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move back to argparse but keep semantics
- Loading branch information
1 parent
5e9662b
commit 695e661
Showing
9 changed files
with
247 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
function cli_settings() | ||
s = ArgParseSettings(description="TMLE CLI.") | ||
|
||
@add_arg_table s begin | ||
"tmle" | ||
action = :command | ||
help = "Run TMLE." | ||
|
||
"svp" | ||
action = :command | ||
help = "Run Sieve Variance Plateau." | ||
|
||
"merge" | ||
action = :command | ||
help = "Merges TMLE outputs together." | ||
end | ||
|
||
@add_arg_table s["tmle"] begin | ||
"dataset" | ||
arg_type = String | ||
required = true | ||
help = "Path to the dataset (either .csv or .arrow)" | ||
|
||
"--estimands" | ||
arg_type = String | ||
help = "A string (`generateATEs`) or a serialized TMLE.Configuration (accepted formats: .json | .yaml | .jls)" | ||
default = "generateATEs" | ||
|
||
"--estimators" | ||
arg_type = String | ||
help = "A julia file containing the estimators to use." | ||
default = "glmnet" | ||
|
||
"--verbosity" | ||
arg_type = Int | ||
default = 0 | ||
help = "Verbosity level" | ||
|
||
"--hdf5-output" | ||
arg_type = String | ||
help = "HDF5 file output." | ||
|
||
"--json-output" | ||
arg_type = String | ||
help = "JSON file output." | ||
|
||
"--jls-output" | ||
arg_type = String | ||
help = "JLS file output." | ||
|
||
"--chunksize" | ||
arg_type = Int | ||
help = "Results are written in batches of size chunksize." | ||
default = 100 | ||
|
||
"--rng" | ||
arg_type = Int | ||
help = "Random seed (Only used for estimands ordering at the moment)." | ||
default = 123 | ||
|
||
"--cache-strategy" | ||
arg_type = String | ||
help = "Caching Strategy for the nuisance functions, any of (`release-unusable`, `no-cache`, `max-size`)." | ||
default = "release-unusable" | ||
|
||
"--sort-estimands" | ||
help = "Sort estimands to minimize cache usage (A brute force approach will be used, resulting in exponentially long sorting time)." | ||
action = :store_true | ||
end | ||
|
||
@add_arg_table s["svp"] begin | ||
"input-prefix" | ||
arg_type = String | ||
help = "Input prefix to HDF5 files generated by the tmle CLI." | ||
|
||
"--out" | ||
arg_type = String | ||
help = "Output filename." | ||
default = "svp.hdf5" | ||
|
||
"--grm-prefix" | ||
arg_type = String | ||
help = "Prefix to the aggregated GRM." | ||
default = "GRM" | ||
|
||
"--verbosity" | ||
arg_type = Int | ||
default = 0 | ||
help = "Verbosity level" | ||
|
||
"--n-estimators" | ||
arg_type = Int | ||
default = 10 | ||
help = "Number of variance estimators to build for each estimate." | ||
|
||
"--max-tau" | ||
arg_type = Float64 | ||
default = 0.8 | ||
help = "Maximum distance between any two individuals." | ||
|
||
"--estimator-key" | ||
arg_type = String | ||
help = "Estimator to use to proceed with sieve variance correction." | ||
default = "TMLE" | ||
end | ||
|
||
@add_arg_table s["merge"] begin | ||
"prefix" | ||
arg_type = String | ||
help = "Prefix to .hdf5 files to be used to create the summary file." | ||
|
||
"--hdf5-output" | ||
arg_type = String | ||
help = "HDF5 file output." | ||
|
||
"--json-output" | ||
arg_type = String | ||
help = "JSON file output." | ||
|
||
"--jls-output" | ||
arg_type = String | ||
help = "JLS file output." | ||
end | ||
|
||
return s | ||
end | ||
|
||
|
||
makeOutput(T::Type, ::Nothing) = T() | ||
|
||
function makeOutput(T::Type, str) | ||
args = split(str, ",") | ||
kwargs = Dict(fn => tryparse(ft, val) for (val, fn, ft) ∈ zip(args, fieldnames(T), fieldtypes(T))) | ||
return T(;kwargs...) | ||
end | ||
|
||
make_outputs(hdf5_string, json_string, jls_tring) = Outputs( | ||
hdf5=makeOutput(HDF5Output, hdf5_string), | ||
json=makeOutput(JSONOutput, json_string), | ||
jls=makeOutput(JLSOutput, jls_tring) | ||
) | ||
|
||
function main(args=ARGS) | ||
settings = parse_args(args, cli_settings()) | ||
cmd = settings["%COMMAND%"] | ||
cmd_settings = settings[cmd] | ||
if cmd ∈ ("tmle", "merge") | ||
outputs = make_outputs(cmd_settings["hdf5-output"], cmd_settings["json-output"], cmd_settings["jls-output"]) | ||
if cmd == "tmle" | ||
tmle(cmd_settings["dataset"]; | ||
estimands=cmd_settings["estimands"], | ||
estimators=cmd_settings["estimators"], | ||
verbosity=cmd_settings["verbosity"], | ||
outputs=outputs, | ||
chunksize=cmd_settings["chunksize"], | ||
rng=cmd_settings["rng"], | ||
cache_strategy=cmd_settings["cache-strategy"], | ||
sort_estimands=cmd_settings["sort-estimands"] | ||
) | ||
else | ||
make_summary(cmd_settings["prefix"]; | ||
outputs=outputs | ||
) | ||
end | ||
else | ||
sieve_variance_plateau(cmd_settings["input-prefix"]; | ||
out=cmd_settings["out"], | ||
grm_prefix=cmd_settings["grm-prefix"], | ||
verbosity=cmd_settings["verbosity"], | ||
n_estimators=cmd_settings["n-estimators"], | ||
max_tau=cmd_settings["max-tau"], | ||
estimator_key=cmd_settings["estimator-key"] | ||
) | ||
end | ||
end | ||
|
||
function julia_main()::Cint | ||
main() | ||
return 0 | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.