-
-
Notifications
You must be signed in to change notification settings - Fork 389
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
Issue changing configuration at runtime #2993
Comments
The pattern I've promoted is instead from astroquery.astrometry_net import AstrometryNet, conf
ast = AstrometryNet(...)
ast.URL = 'http://localhost:8080' so I designed modules to support that approach, expecting that configuration changes would be done via configuration files, not modified at runtime, while individual modules would have their URLs updated at runtime. This latter approach is useful if you want to use different URLs with different instances of the module, e.g.: from astroquery.astrometry_net import AstrometryNet, conf
ast1 = AstrometryNet(...)
ast1.URL = host1
ast2 = AstrometryNet(...)
ast2.URL = host2 This latter use case would be more awkward using the conf-only approach. However, I would be in favor of supporting both approaches. |
The following should work to change e.g. the astrometry.net server:
but does not, because configuration settings are read at class definition time:
I noticed this on astrometry.net because this is the one that I wanted it to work for, but I noticed this pattern in other classes too. We should instead be reading the configuration at runtime at the last minute when these values are needed.
However, before I open a PR to try and fix this, I wanted to check if there is a deliberate reason why the above was done?
The text was updated successfully, but these errors were encountered: