Ensure app.config.config_file is an absolute path #8836
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Also, added integration tests for base config dirs. (I'll add all other config options that are paths in a follow-up)
RATIONALE:
If
galaxy.yml
exists, thenconfig.config_file
is an ABSOLUTE path. Because__find_config_files()
inutil/properties
usesos.getcwd()
to build a list of directories - and that results in an absolute path.(see https://github.com/galaxyproject/galaxy/blob/dev/lib/galaxy/util/properties.py#L56)
If
galaxy.yml
does NOT exist (testing is one use case), thenconfig.config_file
is set to a RELATIVE path. Because it uses the value of__file__
inglobal_conf
dictionary passed inkwargs
and set in the galaxy-main script. (see https://github.com/galaxyproject/galaxy/blob/dev/lib/galaxy/config/__init__.py#L113)As a result, the value of
config.config_dir
will be relative OR absolute (os.path.dirname()
ofconfig_file
) (https://github.com/galaxyproject/galaxy/blob/dev/lib/galaxy/config/__init__.py#L124)And that leads to config files (initially) being resolved to a relative OR an absolute path.
It is all fixed in the end in
_parse_config_file_options()
where everything is resolved w.r.t.config.root
(so with an absolute path, the path is left as is, but with a relative path, it is resolved w.r.t root). However, because conceptually it doesn't feel right (I think, in the end,config_file
should be relative OR absolute, regardless of what file was loaded and how it was discovered); and because it causes problems during testing (when galaxy is run without a preset config file, so all config properties containing paths to config files become relative), ensuringconfig_file
is always an absolute path, seems the logical choice. I've consulted with @natefoo on this.(marking this a bug; although it's not quite a bug: it's resolved in the end, but it shouldn't have to be).