Skip to content

Commit

Permalink
Removed dependency on ArgParse.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkschleg committed Mar 29, 2022
1 parent d90880b commit 34b9511
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 29 deletions.
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ authors = ["Matt <[email protected]>"]
version = "0.11.5-dev"

[deps]
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0"
CodeTracking = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
DBInterface = "a10d1c49-ce27-4219-8d33-6db1a4562965"
Expand All @@ -29,7 +28,6 @@ TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"

[compat]
ArgParse = "0.6, 1"
BSON = "0.2, 0.3"
CodeTracking = "0.5, 1"
DBInterface = "2"
Expand Down
3 changes: 3 additions & 0 deletions examples/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[deps]
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
Reproduce = "560a9c3a-0b8c-11e9-0329-d39dfcb85ed2"
2 changes: 1 addition & 1 deletion examples/configs/arg_iter_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[config]
save_dir="test_loc"
exp_file="examples/experiment.jl"
exp_file="experiment.jl"
exp_module_name = "Main"
exp_func_name = "main_experiment"
arg_iter_type = "iter"
Expand Down
2 changes: 1 addition & 1 deletion examples/configs/arg_iter_config_sql.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ save_backend="mysql" # mysql only database backend supported
database="test_iter" # for params and resutsl
save_dir="test_iter_sql" # for exceptions, settings, and more!

exp_file="examples/experiment.jl"
exp_file="experiment.jl"
exp_module_name = "Main"
exp_func_name = "main_experiment"
arg_iter_type = "iter"
Expand Down
2 changes: 1 addition & 1 deletion examples/configs/arg_iter_config_sql_p2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ save_backend="mysql" # mysql only database backend supported
database="test_iter" # for params and resutsl
save_dir="test_iter_sql" # for exceptions, settings, and more!

exp_file="examples/experiment.jl"
exp_file="experiment.jl"
exp_module_name = "Main"
exp_func_name = "main_experiment"
arg_iter_type = "iter"
Expand Down
2 changes: 1 addition & 1 deletion examples/configs/arg_iter_config_sql_slurm.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ save_backend="mysql" # mysql only database backend supported
database="mkschleg_test_iter" # for params and resutsl
save_dir="test_iter_sql" # for exceptions, settings, and more!

exp_file="examples/experiment.jl"
exp_file="experiment.jl"
exp_module_name = "Main"
exp_func_name = "main_experiment"
arg_iter_type = "iter"
Expand Down
2 changes: 1 addition & 1 deletion examples/configs/arg_looper_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[config]
save_dir="test_loc_loop"
exp_file="examples/experiment.jl"
exp_file="experiment.jl"
exp_module_name = "Main"
exp_func_name = "main_experiment"
arg_iter_type = "looper"
Expand Down
1 change: 1 addition & 0 deletions examples/toml_parallel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ using Pkg
Pkg.activate(".")

using Reproduce
using ArgParse

function main()

Expand Down
4 changes: 0 additions & 4 deletions src/Reproduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ include("search.jl")
export HDF5Manager, BSONManager, JLD2Manager, TOMLManager, save, save!, load
include("data_manager.jl")


# SQL Management...
include("sql_utils.jl")
include("sql_manager.jl")
Expand All @@ -50,8 +49,6 @@ include("save.jl")

abstract type AbstractArgIter end



export ArgIterator, ArgLooper
include("args_iter.jl")
include("args_looper.jl")
Expand Down Expand Up @@ -101,7 +98,6 @@ include("parse.jl")
export job
include("job.jl")


include("exp_util.jl")

end # module
34 changes: 16 additions & 18 deletions src/param_info.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using Logging
using Reexport

import JLD2
@reexport using ArgParse
# @reexport using ArgParse

const HASH_KEY="_HASH"
const SAVE_NAME_KEY="_SAVE"
Expand Down Expand Up @@ -111,19 +109,19 @@ function create_custom_info!(parsed_args::Dict,
JLD2.@save save_settings_file parsed_args used_keys
end

function create_custom_info(arg_list::Vector{String},
settings::ArgParseSettings,
save_dir::AbstractString;
use_keys::Array{String,1} = Array{String,1}(),
make_save_str=default_save_str,
replace=true,
settings_file="settings.jld2", kwargs...)
parsed = parse_args(arg_list, settings; kwargs...)
create_custom_info!(parsed, save_dir;
use_keys=use_keys,
make_save_str=make_save_str,
replace=replace,
settings_file=settings_file)
return parsed
end
# function create_custom_info(arg_list::Vector{String},
# settings::ArgParseSettings,
# save_dir::AbstractString;
# use_keys::Array{String,1} = Array{String,1}(),
# make_save_str=default_save_str,
# replace=true,
# settings_file="settings.jld2", kwargs...)
# parsed = parse_args(arg_list, settings; kwargs...)
# create_custom_info!(parsed, save_dir;
# use_keys=use_keys,
# make_save_str=make_save_str,
# replace=replace,
# settings_file=settings_file)
# return parsed
# end

1 change: 1 addition & 0 deletions src/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function get_arg_iter(::Val{:iter}, dict)
arg_order=arg_order)
end


function get_arg_iter(::Val{:looper}, dict)

static_args_dict = get_static_args(dict)
Expand Down
37 changes: 37 additions & 0 deletions src/parse_ini.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

# SQL conf files are ini files...

function parse_ini(f)
blockname = "default"
seekstart(f); _data=Dict()
for line in eachline(f)
# skip comments and newlines
occursin(r"^\s*(\n|\#|;)", line) && continue

occursin(r"\w", line) || continue

line = chomp(line)

# parse blockname
m = match(r"^\s*\[\s*([^\]]+)\s*\]$", line)
if m !== nothing
blockname = lowercase(m.captures[1])
continue
end

# parse key/value
m = match(r"^\s*([^=]*[^\s])\s*=\s*(.*)\s*$", line)
if m !== nothing
key::String, values::String = m.captures
if !haskey(_data, blockname)
_data[blockname] = Dict(key => parse_line(values))
else
merge!(_data[blockname], Dict(key => parse_line(values)))
end
continue
end

error("invalid syntax on line: $(line)")
end
_data
end

0 comments on commit 34b9511

Please sign in to comment.