ClimaParams.jl
ClimaParams.jl copied to clipboard
`override_file` and `default_file` can be something that is not a file
https://github.com/CliMA/ClimaParams.jl/blob/ec828db9798786a0962d0fe49c2786eaed07e4fd/src/file_parsing.jl#L400-L426
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.
Would it be clearer if the kwargs were changed? It is useful to be able to mix files and Dicts, so I would like to keep this functionality
I think that an argument that takes nothing, string, and dict will always be a little confusing.
Maybe you could do this:
- you have a method that only takes dictionaries (dictionaries are the "primitive type", file reading can be reduced to this case)
- you a methods that just call 1. with the input read from file
create_toml_dict(; override_file::String, default_file::String) = create_toml_dict(; override_dict = Toml.parse(override_file), default_dict = Toml.parse(default_file)
create_toml_dict(; override_dict::Dict, default_file::String) = create_toml_dict(; default_dict = Toml.parse(default_file), override_dict)
create_toml_dict(; override_file::String, default_dict::Dict) = create_toml_dict(; default_dict, override_dict = Toml.parse(override_file)
Or something like this.
More generally, to me this looks like a problem with the constructor of ParamDict. At this end, this just is just a constructor, so maybe we should just provide the correct constructors.
@nefrathenrici is this still current? If so, is it something we should do something about?
@nefrathenrici is this still current? If so, is it something we should do something about?
This issue is current, I can close it next sprint.