Skip to content

Suppress config loading with ASTROPY_SUPPRESS_CONFIG#10090

Closed
pllim wants to merge 2 commits intoastropy:mainfrom
pllim:disable-cfg
Closed

Suppress config loading with ASTROPY_SUPPRESS_CONFIG#10090
pllim wants to merge 2 commits intoastropy:mainfrom
pllim:disable-cfg

Conversation

@pllim
Copy link
Member

@pllim pllim commented Mar 30, 2020

Description

This pull request is to allow suppressing the loading of astropy.cfg when ASTROPY_SUPPRESS_CONFIG environment variable is set. This is a revival of #5907 by @funbaker and a little more to account for import-time loading and code changes since that PR was written.

Side effect: This suppresses not just loading of astropy.cfg but also .cfg of all the other packages that uses astropy.config configuration system.

TODO

  • Is side effect acceptable?
  • Do we need what's new entry?

Fix #5899

Close #7290

Close #6511

@saimn
Copy link
Contributor

saimn commented Apr 3, 2020

I wonder in the first place why we enforce loading a configuration file if it is not there. I mean, there is an easy solution to this: if the config file does not exists, do nothing and just use the default config. That's a common pattern for many software, where config files are optional.

The problem, I think, is that this default config file is used mostly as a mean to document the config items and their default value ? Because this list of config items is built dynamically by each sub-package declaring items, there is no centralized version of it, and it does not appear in the documentation as well. But instead of always creating this default config file, we could have a function creating it on demand, and better documentation of the config items.

@pllim
Copy link
Member Author

pllim commented Apr 3, 2020

why we enforce loading a configuration file if it is not there

The original intent is lost on me, but I guess this is for first time installation, so that the cfg file will be where it is supposed to be and user will only have to edit it for customization? Otherwise, there is this extra manual step of "where am I supposed to copy this file to"?

if the config file does not exists, do nothing

We could, but this is a breaking change (maybe for 5.x?) and we cannot backport. It won't solve the problem of people stuck with astropy 4.x and wants to suppress loading it.

@saimn
Copy link
Contributor

saimn commented Apr 3, 2020

Not reading the config file if it doesn't exist would not be a breaking change, since this would be equivalent to reading a config file that was not modified.
What could be a more important change would be to not write this default config file, and instead have a function to create it on demand, at the same place where it is put currently.

@bsipocz

This comment has been minimized.

@pllim

This comment has been minimized.

@mhvk mhvk removed this from the v4.1 milestone May 3, 2020
@mhvk

This comment has been minimized.

@pllim

This comment has been minimized.

@embray
Copy link
Member

embray commented Sep 27, 2020

I would say "yes" to the side-effect of not loading other config files being acceptable. In some sense these package-specific config files are extending the astropy configuration. The point is to suppress all loading of non-default configurations.

Unless someone else feels strongly about it, I would say "no" to "needs 'what's new' entry". This is mostly useful for development/testing. Its main use to "average" users might be to help them debug issues with their personal configuration, but in this case we can tell them about ASTROPY_SUPPRESS_CONFIG when the need arises. It's also in the documentation so I think that's good enough.

@embray
Copy link
Member

embray commented Sep 27, 2020

I resolved the latest merge conflicts. I can mark as approved pending successful CI.

@mhvk
Copy link
Contributor

mhvk commented Sep 27, 2020

Agreed with the logic.

@bsipocz

This comment has been minimized.

@embray embray self-requested a review October 7, 2020 21:26
@embray

This comment has been minimized.

@embray embray added this to the v4.2 milestone Oct 7, 2020
@pllim

This comment has been minimized.

@pllim

This comment has been minimized.

@pllim
Copy link
Member Author

pllim commented Oct 9, 2020

It's been so long that I don't remember where we stand with this anymore. If there is more code change necessary for this PR, please let me know. Thanks!

p.s. Feel free to ping me to rebase after we have fixed all the unrelated CI stuff. Rebased on 2020-10-15

pllim and others added 2 commits October 15, 2020 14:51
@pllim
Copy link
Member Author

pllim commented Oct 22, 2020

So, am I correct in my understanding that this PR has been superseded by #10877 , @saimn and @astrofrog ?

@saimn
Copy link
Contributor

saimn commented Oct 23, 2020

In my opinion yes, but @astrofrog may think otherwise (see discussion in #10738).

@pllim
Copy link
Member Author

pllim commented Oct 23, 2020

Well, in that case, I don't think this is making it into 4.2. Should we move milestone for both the PRs? (Ah, I see that other PR has a different milestone, so I moved this one's to match.)

@pllim pllim modified the milestones: v4.2, v5.0 Oct 23, 2020
@astrofrog
Copy link
Member

No strong opinions from my side, so close if you like :)

@pllim pllim closed this in #10877 Apr 7, 2021
@pllim pllim deleted the disable-cfg branch April 7, 2021 21:32
@saimn saimn removed this from the v5.0 milestone Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

6 participants