Allow custom root directory for config#8237
Conversation
|
So this seems to be working in DKISTDC/dkist#3 |
|
Edit: This is now irrelevant.
|
|
Can a template version of that code not exist in astropy.config instead of in affiliated packages? |
7ff652c to
5676dc6
Compare
Codecov Report
@@ Coverage Diff @@
## master #8237 +/- ##
==========================================
- Coverage 87.13% 86.96% -0.17%
==========================================
Files 408 400 -8
Lines 62061 59330 -2731
Branches 1096 1100 +4
==========================================
- Hits 54077 51597 -2480
+ Misses 7362 7092 -270
- Partials 622 641 +19
Continue to review full report at Codecov.
|
|
Oh good, the tests seem to write the config to a different path on Python 3.5 🤦♀️ |
mhvk
left a comment
There was a problem hiding this comment.
Only had a glance, really, but like where this is going. Comments incomplete.
astrofrog
left a comment
There was a problem hiding this comment.
Looks good to me! Other than the minor comments/questions below, could you add a small section to the narrative docs mentioning this capability? (http://docs.astropy.org/en/stable/config/index.html)
| pkgname : `str`, optional | ||
| The package name to use to locate the download cache. i.e. for | ||
| ``pkgname='astropy'`` the default cache location is | ||
| ``~/.astropy/cache``. |
There was a problem hiding this comment.
Related to my previous comment, here you have ~ as the prefix for the config dir.
There was a problem hiding this comment.
I am not entirely sure what the behaviour is here, so I think this is probably the best way to doc it.
There was a problem hiding this comment.
Maybe instead of assuming it is ~/.astropy, crosslink to the config doc, since over there, it explains that user can further customize with XDG stuff?
There was a problem hiding this comment.
To be honest I am going to open another PR after this which will change all the directories stuff anyway, so I don't really think it's worth going down the pit with.
|
Ok I have now added docs to this, (I also removed the old 0.4 migration docs) and addressed all the comments. I think this is ready for review again. |
|
For item 3 you mentioned above, are there unwanted side effects? Like, we added a new item or changed default of existing item but template no longer gets copied over, but user has an older version from last install, so user now accidentally using an outdated config? |
pllim
left a comment
There was a problem hiding this comment.
Usage of both "config" and "configuration" interchangeably is confusing to read. Either do something like "configuration (hereafter, config)" and then only use "config" after, or stick to "configuration" unless you are referring to config as in a variable name.
For affiliated package maintainers like myself, I would like a section to help those who want to transition from ~/.astropy (as they had no choice before) to using their own root name now; i.e., what function to call differently in their own config, how they should tell their users about the switch (what old files to get rid of), and so on. Helper functions would be even better but probably out of scope here.
astropy/config/configuration.py
Outdated
| return digest in known_configs | ||
|
|
||
|
|
||
| def write_default_config(pkg, rootname=None): |
There was a problem hiding this comment.
I find it very confusing that this function has the same name as the one in __init__.py.
There was a problem hiding this comment.
The purpose of this is to be overrideable for affiliated packages and the one in __init__.py just has the defaults set for the specific package.
| pkgname : `str`, optional | ||
| The package name to use to locate the download cache. i.e. for | ||
| ``pkgname='astropy'`` the default cache location is | ||
| ``~/.astropy/cache``. |
There was a problem hiding this comment.
Maybe instead of assuming it is ~/.astropy, crosslink to the config doc, since over there, it explains that user can further customize with XDG stuff?
b7bf526 to
b49a18c
Compare
This behaviour is the same as before, currently if the user has changed their config a new template is written with the version number appended. This is the same behaviour as used here, just it happens explicitly when called rather than on import. |
|
@pllim I think I have addressed all your review comments now. |
08e0697 to
6319363
Compare
|
The doc fail seems unrelated. |
db42f39 to
5dd0285
Compare
[ci skip]
[ci skip]
Co-Authored-By: Brigitta Sipocz <b.sipocz@gmail.com>
3b1b136 to
d98b06d
Compare
|
Ok, I finally fixed the stupid changelog. |
astrofrog
left a comment
There was a problem hiding this comment.
Just confirming that this looks good to me
|
Shall we merge then? |
|
Let's get on with this then. Thank you @Cadair! |
This PR makes three main changes to the way configuration files are handled, one is intended for affiliated package authors and two affect end users.
Allow the customisation of the directory name for configuration files, via the
rootnameargument. This allows affiliated package authors to use a directory like~/.dkist/config/dkist.cfgrather than~/.astropy/config/dkist.cfgProvide a user facing helper (the previous API wasn't user facing but hasn't been changed) to be called if the user wants to write out the default config for subsequent manual editing.
Remove the code that automatically writes the template config to disk on import of astropy (fixes Consider providing template config file in docs instead of writing to disk #8552)
It also makes one minor change,
get_config_dirnow defaults tocreate=Falseso as to not create the config dir when a config file is not to be written to it.This is a replacement for #6985
TODO: