Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative path to include config files #104

Open
FMalerba opened this issue Jan 1, 2021 · 2 comments
Open

Relative path to include config files #104

FMalerba opened this issue Jan 1, 2021 · 2 comments

Comments

@FMalerba
Copy link

FMalerba commented Jan 1, 2021

Currently if you include other gin files with a statement include path/to/file the path can be either absolute or relative to the folder the code is running in.

The config file however should be - in my opinion - agnostic to the folder from which you are calling the code. It makes more sense to me if all gin-config files are stored in a config folder and their relative paths are fixed (or whoever is maintaining the code is keeping track of it).

In other words, take the example in which there are two config files (config.gin and base.gin) in the same folder. Let's say that config.gin has the following line of code:

...
include 'base.gin'
...

Now let's say that main.py (located wherever you want) is calling the gin.parse_config_files_and_bindings(...) on config.gin having been given the appropriate path to it (absolute or relative). This scenario will raise an error if the terminal from which you are calling main.py is not located in the same folder in which the two config files are.

@sguada
Copy link
Collaborator

sguada commented May 10, 2021

You can use gin.add_config_file_search_path('path/to/config.gin') to add folders that you want gin to use when doing gin.parse_config_files_and_bindings(...)

@breakds
Copy link

breakds commented Jun 29, 2021

You can use gin.add_config_file_search_path('path/to/config.gin') to add folders that you want gin to use when doing gin.parse_config_files_and_bindings(...)

Thanks for sharing this. The problem can definitely be solved by automatically add the directory of config.gin to the search path with gin.add_config_file_search_path(). However, based on my limited experience I think people tend to cluster configurations files together, and IMHO having the directory of config.gin (or whatever the top-level configuration file is) in the search path is probably a better default behavior.

Also Ideally we probably want something like with_config_file_search_paths to avoid having to use add_config_file_search_path which has side effects that can potentially pollute the other modules who also imports gin.

Just my 2 cents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants