Skip to content
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

enable using davos.configure as a context manager #99

Open
paxtonfitzpatrick opened this issue Sep 25, 2023 · 1 comment
Open

enable using davos.configure as a context manager #99

paxtonfitzpatrick opened this issue Sep 25, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@paxtonfitzpatrick
Copy link
Member

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:

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:

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

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:

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

@paxtonfitzpatrick paxtonfitzpatrick added the enhancement New feature or request label Sep 25, 2023
@paxtonfitzpatrick
Copy link
Member Author

Something similar would be useful (and also easy to implement) for temporarily changing the pip executable Davos uses.
E.g.,

with davos.tmp_pip_executable('/path/to/pip'):
    smuggle foo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant