Skip to content

ENH: Allow discovery of available config items - #10139

Merged
mhvk merged 3 commits into
astropy:masterfrom
pllim:config-item-discovery
May 4, 2020
Merged

mhvk merged 3 commits into
astropy:masterfrom
pllim:config-item-discovery

Conversation

@pllim

@pllim pllim commented Apr 13, 2020

Copy link
Copy Markdown
Member

Description

This pull request is to add __iter__ in ConfigNamespace to see what ConfigItem names are defined in it.

Fixes #8524

p.s. Not sure what the "example start" stuff is about, so I didn't add that in.

@pllim pllim added this to the v4.1 milestone Apr 13, 2020
@pllim
pllim requested a review from eteq April 13, 2020 20:08
@mhvk

mhvk commented Apr 14, 2020

Copy link
Copy Markdown
Contributor

Seems like a good idea! And from the example I can see why you felt this might be useful......

Somewhat separately, it would be really good if searching for "astropy configuration" didn't just return how to do configuration, but also all possible things one can configure. It should be possible to auto-generate a nice list... Which probably should be a new issue... Will generate one.

@pllim

pllim commented Apr 14, 2020

Copy link
Copy Markdown
Member Author

@mhvk , I did have to use this feature for synphot when I had to loop through all the items to change the root path in them but I did not want to hardcode the item names.

@mhvk

mhvk commented Apr 14, 2020

Copy link
Copy Markdown
Contributor

Just to be clear, I think this really is independent of my other request/wishlist - and I am all for getting it in! But better let @eteq have a look first...

@bsipocz

bsipocz commented Apr 30, 2020

Copy link
Copy Markdown
Member

please do rebase

@pllim
pllim force-pushed the config-item-discovery branch from ce90846 to 3c934e8 Compare April 30, 2020 21:11
Comment thread astropy/config/configuration.py Resolved
@pllim

pllim commented May 1, 2020

Copy link
Copy Markdown
Member Author

Rebased and I added dict-like iterators.

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is all OK, though it needs a rebase and one might as well fix a nitpick in the process. One of those little things that makes stuff just that bit better!

Comment thread astropy/config/configuration.py Outdated

def values(self):
"""Iterate over configuration item values."""
for key, val in self.__class__.__dict__.items():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd iterate over __dict__.values() here, but not essential.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

for item in self.__class__.__dict__.values():
if isinstance(item, ConfigItem):
item.reload()
for item in self.values():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Immediate benefit!

@pllim
pllim force-pushed the config-item-discovery branch from bd1876c to 2e965af Compare May 4, 2020 17:14
Comment thread CHANGES.rst Resolved
Fix change log duplicate added from rebasing.
@pllim
pllim force-pushed the config-item-discovery branch from 2e965af to ab85080 Compare May 4, 2020 17:18
@pllim pllim added the zzz 💤 merge-when-ci-passes Do not use: We have auto-merge option now. label May 4, 2020
@mhvk

mhvk commented May 4, 2020

Copy link
Copy Markdown
Contributor

Great, merging!

@mhvk
mhvk merged commit 8e19d39 into astropy:master May 4, 2020
@pllim
pllim deleted the config-item-discovery branch May 4, 2020 18:07
@pllim

pllim commented May 4, 2020

Copy link
Copy Markdown
Member Author

Thanks for the review and merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Allow discovery of available config items

4 participants