ContextLab / ContextLab/davos

enable using davos.configure as a context manager

Open
#99 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TeX
Stars
37
Forks
8
PR merge metrics
No merged PRs in 30d

Description

This would be really useful feature for temporarily setting config options while smuggling certain packages, and ensuring that they're reset afterward. There are even a couple use cases for it in the example code from the paper.

For example:
```python
davos.auto_rerun = True
smuggle numpy as np # pip: numpy==1.21.6
smuggle pandas as pd # pip: pandas==1.3.5
davos.auto_rerun = False
```
could become:
```python
with davos.configure(auto_rerun=True):
smuggle numpy as np # pip: numpy==1.21.6
smuggle pandas as pd # pip: pandas==1.3.5
````

And
```python
davos.configure(suppress_stdout=True, noninteractive=True)
smuggle tensorflow as tf # pip: tensorflow==2.9.2
from umap smuggle UMAP # pip: umap-learn[plot,parametric_umap]==0.5.3
davos.configure(suppress_stdout=False, noninteractive=False)
```
could become:
```python
with davos.configure(suppress_stdout=True, noninteractive=True):
smuggle tensorflow as tf # pip: tensorflow==2.9.2
from umap smuggle UMAP # pip: umap-learn[plot,parametric_umap]==0.5.3
```

It also shouldn't be too hard to implement -- I've already done close to the same thing with [`hypertools.set_interactive_backend`](https://github.com/ContextLab/hypertools/blob/564c1d43da447da68ce3d76f51306725291630e0/hypertools/plot/backend.py#L666)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.