-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
ClimaParams.jl/src/file_parsing.jl
Lines 400 to 426 in ec828db
| """ | |
| create_toml_dict(FT; | |
| override_file, | |
| default_file, | |
| ) | |
| Creates a `ParamDict{FT}` struct, by reading and merging upto | |
| two TOML files or Julia Dicts with override information taking precedence over | |
| default information. | |
| """ | |
| function create_toml_dict( | |
| ::Type{FT}; | |
| override_file::Union{Nothing, String, Dict} = nothing, | |
| default_file::Union{String, Dict} = joinpath(@__DIR__, "parameters.toml"), | |
| ) where {FT <: AbstractFloat} | |
| default_dict = | |
| default_file isa String ? TOML.parsefile(default_file) : default_file | |
| default_toml_dict = ParamDict{FT}(default_dict, nothing) | |
| isnothing(override_file) && return default_toml_dict | |
| override_dict = | |
| override_file isa String ? TOML.parsefile(override_file) : override_file | |
| override_toml_dict = ParamDict{FT}(override_dict, override_dict) | |
| return merge_override_default_values(override_toml_dict, default_toml_dict) | |
| end |
This function has a really counter-intuitive behavior, where you can pass a dictionary to an override_file/default_file. If we want to support this feature, it should be in different method instead of having a function that does all sorts of stuff and that can only be understood by reading the source code.
Metadata
Metadata
Assignees
Labels
No labels