-
Notifications
You must be signed in to change notification settings - Fork 317
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
Fix add_to_spyder_UMR_excludelist for Spyder 6 #6544
base: main
Are you sure you want to change the base?
Conversation
@microsoft-github-policy-service agree |
else: | ||
sitecustomize_found = True | ||
# In Spyder 6 UMR is an attribute of the SpyderCodeRunner object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also encountered qcodes not running with the new Spyder 6. The UserModuleReloader
is also available via a normal import:
import spyder_kernels.customize.umr; spyder_kernels.customize.umr.UserModuleReloader
Using that instead of sitecustomize.UserModuleReloader
works for me so far.
@ccordoba12 Do you have an opinion on how to approach this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that as well.
Unfortunately Spyder6 does not use the global umr. So assignment of the changed UMR has no effect.
That's why I searched for the UMR instance that is being used and modify that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eendebakpt @sldesnoo-Delft I am not using spyder my self at the moment so unlikely to spot this.
At some point a long time ago I did look into addressing this issue on the spyder side spyder-ide/spyder#2451 If anyone have bandwidth to do that it would be great as this is a much cleaner option.
Otherwise happy to merge this once you have converted on the best solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ccordoba12 Do you have an opinion on how to approach this?
I wasn't aware people was adding modules to our UMR programmatically (no one has reported it to our issue tracker).
Since the code to do that for Spyder 6/Spyder-kernels 3 is too convoluted (from what I can see below), we could add a public API at the shell level (i.e. the object you get with get_python()
) to make the life of other projects easier.
@jenshnielsen, @sldesnoo-Delft, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qcodes adds itselft to the list of packages to exclude.
I had a closer look at the UMR. It checks if the module is in the library path. (path_is_library
in utils.py). When qcodes is normally installed, i.e. not in "develop mode", then it will not be reloaded by UMR.
So, I believe the add_to_spyder_UMR_excludelist function is not really needed. It might be a remainder from a distant past.
@jenshnielsen , @eendebakpt do you agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sldesnoo-Delft I think this has ever only been a problem with editable installs. As I recall the problem is that when spyder does reload all singletons are destroyed so instruments are lost. I think that when we originally added this qcodes did not see regular releases, so a lot of users were installing from source. This is much less of an issue now so I think it would be fine to deprecate/remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no strong opinion on this, we usually disable the spyder UMR (other packages have issues with automatic reloading as well). We only noticed because the new spyder 6 would not import qcodes.
If we do remove the functionality, I do think it warrants some attention in the release notes (and maybe the documentation?).
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6544 +/- ##
==========================================
- Coverage 69.33% 68.24% -1.10%
==========================================
Files 340 340
Lines 31261 31268 +7
==========================================
- Hits 21676 21340 -336
- Misses 9585 9928 +343 ☔ View full report in Codecov by Sentry. |
The import of qcodes fails with Spyder 6, because add_to_spyder_UMR_excludelist raises an exception.
This pull request fixes the code to work with Spyder 6.0.
I've removed a bit of old code that was only useful for Spyder 3.x
I don't think this is easy to test with an automatic test, because a test would require Spyder 6.