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

Ensure app.config.config_file is an absolute path #8836

Merged
merged 1 commit into from
Oct 23, 2019

Conversation

jdavcs
Copy link
Member

@jdavcs jdavcs commented Oct 21, 2019

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, then config.config_file is an ABSOLUTE path. Because __find_config_files() in util/properties uses os.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), then config.config_file is set to a RELATIVE path. Because it uses the value of __file__ in global_conf dictionary passed in kwargs 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() of config_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), ensuring config_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).

@jdavcs jdavcs requested a review from natefoo October 21, 2019 20:44
@jdavcs jdavcs added area/configuration Galaxy's configuration system kind/bug labels Oct 21, 2019
@galaxybot galaxybot added this to the 20.01 milestone Oct 21, 2019
@jdavcs
Copy link
Member Author

jdavcs commented Oct 21, 2019

Both fails caused by error in test implementation. Fixing it... [Update: fixed.]

Also, add integration tests for base config dirs.

NOTE: this is a rebased commit that contains a fix to a previously
failed commit:
- the expected value of config_dir is calculated separately;
- the default value of data_dir is not testable in this context and is
  marked accordingly.
@jmchilton jmchilton merged commit e7a913d into galaxyproject:dev Oct 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/configuration Galaxy's configuration system kind/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants