-
Notifications
You must be signed in to change notification settings - Fork 46
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
Change import to have configurable prefixes via set_options
#460
Conversation
I didn't realize users would need to override these variables. I'd like to suggest a different approach that exposes these variables and (other future configuration) as options that users can easily manipulate. Using donfig would simplify this process and make it easy to modify these configurations. Let me know what you think. |
Oh! The way they were declared as constants made me think that was the goal. In our case, we found I agree that this is not super clean. But there are only 3 variables... If you plan to add more user-controllable stuff, then yes an external package could be useful. For now, I feel it is not needed? I'm a dev at |
If you have time, let's go with the |
@andersy005 Last commit pushed a simplified version of xarray's mechanic for options! I added the class to the API page and mentioned it in the docstring of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, @aulemaha! Thank you...
set_options
Change Summary
Restructures the import of the default attribute names and prefixes in
source.py
so that they are actually configurable by patching the variables inutils.py
.Related issue number
No issue sorry.
The problem was the
source.py
imported the variables directly, this copying the python reference to the string. As strings are non-mutable, someone that would want to customize the attribute names has to re-set the variable in theutils
module (I think this is called "monkey-patching" ?). But that doesn't update the version insource.py
. Here, the solution is to import the wholeutils
module object insource
, so that the strings are queried as members of the module everytime they are needed, not only a import time.Checklist