pymc icon indicating copy to clipboard operation
pymc copied to clipboard

Introduce `pm.config` or `rcParams` for global & local config settings

Open michaelosthege opened this issue 4 years ago • 8 comments

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

  1. Read this thread
  2. Specifically investigate the options here
  3. Decide which route to go for
  4. Open a PR

michaelosthege avatar Apr 21 '21 14:04 michaelosthege

What kind of things would go in here?

ricardoV94 avatar Apr 23 '21 08:04 ricardoV94

  • Switching the return_inferencedata default value
  • Turning the automatic addition of SpecifyShape when full-length shape is passed on/off
  • Default values for compute_convergence_checks or discard_tuned_samples maybe?

michaelosthege avatar Apr 23 '21 14:04 michaelosthege

  • default init in 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

OriolAbril avatar Apr 23 '21 14:04 OriolAbril

I like it, I often use a default-dict for the sample() kwargs.

twiecki avatar Apr 24 '21 05:04 twiecki

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.

michaelosthege avatar Apr 24 '21 09:04 michaelosthege

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.

OriolAbril avatar Apr 24 '21 16:04 OriolAbril

After looking at the size of the ArviZ rcParams implementation 😮 I'd actually recommend the Aesara configparser. It comes down to copyediting the following:

michaelosthege avatar Apr 25 '21 10:04 michaelosthege

I like the idea. There should also be a way to make temporary changes in a context manager like done in matplotlib

ferrine avatar Mar 30 '22 09:03 ferrine