-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Julia CONFIG dictionary (closes #2430) #2716
Conversation
Overall I'm not comfortable with this general idea. I don't fully understand what needs to be configured, and why. It's best to avoid configuration and options, and instead pick good defaults, that can be overridden at the point where they are used. Otherwise you get state-dependent programs that don't work for people who don't have your configuration file. Options lead to ugly and brittle systems. They also make it easier to avoid design decisions by saying "make it an option". Considering the example of the graphics backend, we don't need a configurable backend so much as we need one that works well. And configuration is weaker than composability: This particular implementation is clever, though it feels rather complex. It clearly wants keyword arguments :) Anyway I'd rather avoid adding more options. The answer color thing is frivolous and I don't want a whole subsystem for configuring it, as hilarious as that would be. |
I prefer an ini file too. CONFIG suggests that changes would be reflected immediately, but it is only a holder. The ini file will obviously have an in memory representation, which should be const. |
@JeffBezanson for one thing, loading a second window manager (e.g. Gtk) can cause Tk to segfault, so composability is less helpful than a shared default for the window manager (window's themselves are a different thing -- I'm not sure that an While I agree that good design is important, at some point, you can't simply say "everyone just needs to use emacs", or I'll be forced to create a julia-vim fork. Why bring in the complexity and limitations of a True, @ViralBShah This provides the option of representing changes immediately, if meaningful, since it provides getter and setter callbacks. However, I suspect that usually it is not meaningful. |
We're using environment variables because they're the standard mechanism people already know how to work with (e.g. adding to your bashrc). Whether they are "scattered" is more of a documentation and presentation issue, which exists with any configuration system (how to know what options and values are available). I'm ok with I'm not sure how to handle something like |
I really do not like environment variables for stuff like answer color. They are ok for stuff like paths, I feel. Something like CONFIG would be nice to customize the REPL. |
I think I am worried about There is a staging problem: we have to define when configuration changes take effect. The callback feature makes it possible for changes to take effect immediately, but this places an undue burden on many use cases. For example, if I can select whether multiprocessing uses TCP or UDP, does changing it mean that all current connections are torn down and redone using the new protocol? Maybe we could divide options into build time, init time, and run time. |
Good point. We already use |
Julia code has a "build time" which occurs whenever the code is first loaded, for example by using a package or calling |
Another use case of this is the choice of the BLAS library, choice of LIBM, etc. |
But those are build-time options, so I don't see how it helps to have a julia interface to them. |
There are runtime checks too - checking the type of blas, whether 64 bit blas was built. We may even want to query versions of libraries and such. |
I'm fine with using However, it would be nice to have a good convention for a separate namespace for module-specific configurations. For example, I'd like to be able to do:
in my It would also be nice if Julia-specific configuration settings could be something other than strings, but that would require a separate |
6c7c7e3
to
1a4c02f
Compare
Close this? |
See also JuliaLang/Juleps#38; we really need persistent per-package configuration options. |
not all configuration is for packages though |
Maybe close this one? |
I figure the only way to get Jeff to comment on #2430 was to submit the code for it as a pull request. So this creates a CONFIG dictionary for arbitrary configuration parameters.
And assign configuration entries simply:
The user can also see the current bindings:
show(CONFIG)
The standard usage of this would be to provide default values for any configuration items in the dictionary:
Deleting those values resets the value to the default:
Other parameters can be deleted too as follows:
The CONFIG object supports getter, setter, and delete notification methods. Here's an example from Base that uses a getter method to create compatibility with the old environment variables and converting the input color through the text_colors mapping:
Here's another example from Base at using a setter method to react to changes in the value:
Note that the setter will be called whenever the value is changed, including after a value is deleted (and reverted to default) and right after installing the setter.