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

Add support for Spyder in tqdm.auto #1559

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

eendebakpt
Copy link

The Spyder environment console uses IPython, and are therefore recognized by tqdm as notebooks. The progress bar does only work with tqmd.std though. In this PR we detect Spyder and import the correct packages.

The reason for making the change here is that with third-party packages we cannot always control whether tqdm is imported from auto, autonotebook or std.

An alternative would be to check in tqdm.autonotebook for a special environment variable that overrides the automatic detection.

@@ -21,7 +22,11 @@
except Exception:
from .std import tqdm, trange
else: # pragma: no cover
from .notebook import tqdm, trange
if "SPY_TESTING" in os.environ:
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • is SPY_TESTING always defined inside a spyder environment?
  • is it fairly plausible for SPY_TESTING to be defined outside spyder?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have used this approach for many years without any issues. Checking environment variables of the form SPY_XXXX is also suggested in https://stackoverflow.com/questions/53829284/how-to-know-if-a-script-is-running-in-spyder-or-any-other-python-ide.

I will create an issue at the Spyder issue tracker to check this is a good approach.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@casperdcl I have updated the detection method based on the suggestion by the Spyder devs. See spyder-ide/spyder#21929

@casperdcl casperdcl added need-feedback 📢 We need your response (question) p2-bug-warning ⚠ Visual output bad submodule-notebook 📓 Much web such IDE c1-quick 🕐 Complexity low labels Mar 25, 2024
@casperdcl casperdcl added this to To Do in Casper Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c1-quick 🕐 Complexity low need-feedback 📢 We need your response (question) p2-bug-warning ⚠ Visual output bad submodule-notebook 📓 Much web such IDE
Projects
Casper
  
To Do
Development

Successfully merging this pull request may close these issues.

None yet

2 participants