Cannot change Vizier configuration value neither at runtime nor with config file due to outdated parameter name in astroquery.cfg
- Dominant language
- Python
- Stars
- 791
- Forks
- 451
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 4
Description
I cannot change configuration values for `Vizier`, both at runtime via `conf` object, or at configuration file `~/.astropy/config/astroquery.cfg` .
1. For changing values with config file, setting the server in `astroquery.cfg` does not have any effect.
```ini
[vizier]
vizier_server = vizier.cfa.harvard.edu
```
**UPDATE:** The issue is because the parameter name is now `server` instead of `vizier_server` . See https://github.com/astropy/astroquery/issues/3018#issuecomment-2146166158 below.
---
2. For changing the values at runtime, setting it with `conf.server` does not have any effect either. More examples later.
The issue of changing at runtime is similar to #2291 (for SIMBAD) and #2993 (for astrometry.net). The specifics are slightly different, but they all boil down to that the default value is read once at class loading time.
---
**Example for runtime config issue**
For illustration, I added a debug output at the end of [`VizierClass.__init__()`](https://github.com/astropy/astroquery/blob/6798431a35644eb30fc938d61cd5c8398cba0ac8/astroquery/vizier/core.py#L47):
```python
# at the end of __init__()
print("[DBG] vizier_server param:", vizier_server, "- in conf obj:", conf.server)
```
Test code
```python
import astroquery.vizier as vizier
print("Before change:", vizier.conf.server)
vizier.conf.server = "vizier.cfa.harvard.edu"
print("after change:", vizier.conf.server)
print("Create Vizier object...")
vizier.Vizier()
```
Output: it shows the updated value in `conf` object is not used.
```
Before change: vizier.cds.unistra.fr
after change: vizier.cfa.harvard.edu
Create Vizier object...
[DBG] vizier_server param: vizier.cds.unistra.fr - in conf obj: vizier.cfa.harvard.edu
```
---
**Workaround for runtime issue:** Reload all relevant modules
```python
from importlib import reload
import astroquery.vizier as vizier
vizier.conf.server = "vizier.cfa.harvard.edu"
# need to reload both
reload(vizier.core)
reload(vizier)
print("Create Vizier object...")
vizier.Vizier()
```
Output
```
Create Vizier object...
[DBG] vizier_server param: vizier.cfa.harvard.edu - in conf obj: vizier.cfa.harvard.edu
```
It could get tricky in practice to do proper reloading. If `Vizier` is imported to some other module, say, `module_a`, `module_a` would also need to be reloaded.
---
**Versions**
astroquery: v0.4.7
astropy: v6.0.1
Platform: Windows 11
Contributor guide
Research direction
Start in astroquery/vizier/core.py at VizierClass.__init__ and inspect how the server value is captured relative to vizier.conf.server. Check the [vizier] section and server parameter in astroquery.cfg, then run the issue's runtime example; done means both configuration-file and runtime changes are used when creating Vizier.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100