-
-
Notifications
You must be signed in to change notification settings - Fork 409
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
Fix issue #535: Treat rel. paths inside config relative to the config file #543
Conversation
ad1c25b
to
1b2cdcb
Compare
This is an interesting proposal. Not clear if we want to have it that way as I think most software does it relative to the CWD for these user defined config files. But what does @tardis-sn/tardis-core think? |
I think this change will help to keep things more organized. If I'm defining paths inside a file I expect them to be treated relative to that file, if I don't want that behavior I'd use absolute paths. The current implementation requires me to constantly link the atom_data database to my current working directory. |
If nothing else, at least this was a good example problem for me to work on. Finally passes the tests :). |
Could include an extra setting for each input file with options to set the base path to either the config directory or CWD. Alternatively, special keywords like $CWD or $CONFIGDIR could be replaced with their values during input. Both of these can preserve the default behaviour of giving paths relative to the CWD. |
@lukeshingles I think it's fine. If we need this later - we can add it. I think we just need to review it from the code and then merge. |
I think it's fine as it is. In the next month the config system might see significant changes so I wouldn't add these features now. As for the implementation. I think it's fine. For a rewrite of the config system I'd convert everything to absolute paths but that's not necessary. |
15f8d18
to
db51da6
Compare
@tardis-sn/tardis-core are we merging this now? |
@wkerzendorf I'm happy to merge. If @lukeshingles wants to add a small test for that functionality it would be even better but since this is not a major change I wouldn't make it a requirement for merging. |
I'm happy to do it, although it would take me a couple of working days to have it done. What kind of test did you have in mind? Moving the working directory up a level and rewriting the config dir to match? Also, any idea why Scrutinizer failed this commit? |
@lukeshingles I was thinking of the following:
UpdateWhen I'm looking at the current implementation I think it would be useful to have a |
6c97075
to
1b25eaa
Compare
Treat rel. paths inside config relative to the config file import os in run_tardis() Detect and preserve absolute paths in configuration spacing replace default config_dirname with "" to have no effect on os.path.join update file paths in test configurations set config_dir on test configurations fix artis_abundances.dat path
Since I plan to write/update tests for the changes I make in the configuration system and I have no extensive experience in writing tests, this would be a good chance for me to write one for the changes @lukeshingles did. May I? |
@ftsamis Sure, feel free to add them and make a PR to @lukeshingles 's branch. |
Please check my PR (lukeshingles#1) on @lukeshingles' branch which adds tests for this PR. This is also my first attempt to write pytest tests, so bear with me if something is not as it should be. |
Write tests for the issue tardis-sn#535 fix.
@lukeshingles @ftsamis @tardis-sn/tardis-core is that done? |
Looks good to me. |
@lukeshingles @ftsamis well done! |
@tardis-sn/tardis-core Sorry I'm a bit late to the party. Pytest provides this fixture automatically to do exactly what we want. |
You are right @yeganer, monkeypatch.chdir is exactly what I should have used in this one. Opened a new PR with this change: #555 , please review it. Regarding the empty commit, I'm not sure anything can be done now on my side, except not pushing empty commits again on PR branch. I was exploring Travis, but I should have done that on a separate test branch (which I did, after this empty commit) from the beginning. |
@ftsamis There is no problem with pushing anything to a PR branch, but please make sure to clean up the commit history of your PR before finishing it (have a look at |
This is a quickfix for issue #535. File paths in the config file are now treated as relative to the location of the config file.