Introduce `pm.config` or `rcParams` for global & local config settings
Let me begin with saying that global variables are evil and nobody should be using them.
For things like #4372 it would be really useful to have a place where to make global config changes.
Matplotlib does it and ArviZ too.
Aesara also has a quite powerful config implementation that I refactored quite a bit a few months back.
Or maybe we don't even need/want a place for global configuration settings?
Anyways it would be great to discuss and figure out what we want!
Update 2022-03-30 + ToDo
We have a general consensus that we want to do this. (I'm updating the title+labels in a second.)
Whoever wants to work on this should
- Read this thread
- Specifically investigate the options here
- Decide which route to go for
- Open a PR
What kind of things would go in here?
- Switching the
return_inferencedatadefault value - Turning the automatic addition of
SpecifyShapewhen full-lengthshapeis passed on/off - Default values for
compute_convergence_checksordiscard_tuned_samplesmaybe?
- default
initin sample, and anything else where we have a "you can't trust the default to stay the same" keep_size? for people who wants to live in the past and get flattened samples in sample_posterior_predictive after #4647- going forward not sure if it should be here or in Aesara, default sampling backend, jax, numba, python samples if still around
I like it, I often use a default-dict for the sample() kwargs.
Sounds like we are in favor of global config settings. So how should we implement it?
Option 1: rcParams
➕ Users know it from matplotlib and arviz
➕ Can change options with context managers (I didn't know that - thanks @OriolAbril !)
➖ Mix of two different config schemes (Aesara vs. PyMC3)
Option 2: aesara.configparser
➕ Users know it from theano/aesara
➕ Can change options with context managers
➕ Can work with CLI params/environment variables
➖ Mix of two different config schemes (Aesara+PyMC3 vs. ArviZ)
Feel free to edit this comment to add/edit the ➕/➖ items.
I'd go with whatever is easier to add and maintain. ArviZ/matplotlib version has no dependencies because it has the reader and rcparams object as part of the codebase.
Also not sure what you mean by always global in the matplotlib/arviz one, both can be configured temporarly with context managers.
After looking at the size of the ArviZ rcParams implementation 😮 I'd actually recommend the Aesara configparser.
It comes down to copyediting the following:
- A
_create_default_configfunction inpymc3/configdefaults.py - Creating a
configinstance inpymc3/configdefaults.pyand importing it to the package level:pm.config - Adding default settings with
pm.config.add()as seen in aesara/configdefaults.py
I like the idea. There should also be a way to make temporary changes in a context manager like done in matplotlib