ClimaParams.jl icon indicating copy to clipboard operation
ClimaParams.jl copied to clipboard

`override_file` and `default_file` can be something that is not a file

Open Sbozzolo opened this issue 1 year ago • 4 comments

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.

Sbozzolo avatar May 20 '24 03:05 Sbozzolo

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

nefrathenrici avatar May 20 '24 20:05 nefrathenrici

I think that an argument that takes nothing, string, and dict will always be a little confusing.

Maybe you could do this:

  1. you have a method that only takes dictionaries (dictionaries are the "primitive type", file reading can be reduced to this case)
  2. 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.

Sbozzolo avatar May 20 '24 20:05 Sbozzolo

@nefrathenrici is this still current? If so, is it something we should do something about?

tapios avatar Oct 20 '25 22:10 tapios

@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.

nefrathenrici avatar Oct 23 '25 19:10 nefrathenrici