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

ENH: Warn about versions in sys_info #12146

Merged
merged 10 commits into from
Oct 30, 2023
Merged

ENH: Warn about versions in sys_info #12146

merged 10 commits into from
Oct 30, 2023

Conversation

larsoner
Copy link
Member

@larsoner larsoner commented Oct 26, 2023

This is the best formatting I could find:

  1. Add version check right by where the mne version is reported, and
  2. If outdated, add a line at the end gently suggesting to update

With this change I get:

On dev

On my machine I get:

$ mne sys_info
Platform             Linux-6.2.0-35-generic-x86_64-with-glibc2.37
Python               3.11.4 (main, Jun  9 2023, 07:59:55) [GCC 12.3.0]
Executable           /home/larsoner/python/virtualenvs/base/bin/python3
CPU                  x86_64 (8 cores)
Memory               62.7 GB

Core
├☑ mne               1.6.0.dev154+ga320b631a7.d20231024
│                    ✓ Dev version (latest release: 1.5.1)
├☑ numpy             2.0.0.dev0+git20231025.9f6789c (OpenBLAS 0.3.23.dev with 4 threads)
├☑ scipy             1.12.0.dev0+1888.d7f12d3
...
├☑ mne-bids-pipeline 1.4.0
└☐ unavailable       mne-nirs, mne-features, mne-connectivity, mne-icalabel

On stable

Hacking the code to say I'm on stable the above changes to:

├☑ mne               1.5.1
│                    ✓ On the latest release

Outdated

Hacking the code to fake the latest release to be 1.7 we see the two lines change:

$ mne sys_info
Platform             Linux-6.2.0-35-generic-x86_64-with-glibc2.37
Python               3.11.4 (main, Jun  9 2023, 07:59:55) [GCC 12.3.0]
Executable           /home/larsoner/python/virtualenvs/base/bin/python3
CPU                  x86_64 (8 cores)
Memory               62.7 GB

Core
├☑ mne               1.6.0.dev154+ga320b631a7.d20231024
│                    ✗ A newer version 1.7 is available!
├☑ numpy             2.0.0.dev0+git20231025.9f6789c (OpenBLAS 0.3.23.dev with 4 threads)
├☑ scipy             1.12.0.dev0+1888.d7f12d3
...
├☑ mne-bids-pipeline 1.4.0
└☐ unavailable       mne-nirs, mne-features, mne-connectivity, mne-icalabel

To update to the latest supported release version to get bugfixes and improvements, visit https://mne.tools/stable/install/updating.html

Timeout (default 2s)

If I hack the timeout to be tiny enough that it fails for my system, same

├☑ mne               1.6.0.dev154+ga320b631a7.d20231024
│                    Unable to check latest version on GitHub (2.0 sec timeout)

Todo

Just waiting for feedback before finishing:

  • Tests
  • Changelog entry

Closes #12132

Copy link
Member

@drammock drammock left a comment

Choose a reason for hiding this comment

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

thanks for doing this! My (bikeshedding) nitpicks are:

  • prefer to have the message on the same line as the reported version (similar to how we put BLAS info in parentheses after reporting numpy version)
  • instead of an extra check/x-mark in the message, I would consider having the main left-margin checkbox be the indicator, like
    • ✓ (installed stable or dev)
    • x (installed old version)

Comment on lines +20 to +23
from urllib.error import URLError
from urllib.request import urlopen

from packaging.version import parse
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised this passed style checks, shouldn't it fail on import sorting grounds?

Copy link
Member Author

Choose a reason for hiding this comment

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

This makes it a different import block

@larsoner
Copy link
Member Author

larsoner commented Oct 26, 2023

prefer to have the message on the same line as the reported version (similar to how we put BLAS info in parentheses after reporting numpy version)

Actually this split is intentional. It gives people two chances to see the version mismatch. If you really want them EDIT: in one place, I guess I'd prefer and can live with them both in a separate message at the bottom since it's more visible than when it's up by mne.

@drammock
Copy link
Member

prefer to have the message on the same line as the reported version (similar to how we put BLAS info in parentheses after reporting numpy version)

Actually this split is intentional. It gives people two chances to see the version mismatch. If you really want them EDIT: in one place, I guess I'd prefer and can live with them both in a separate message at the bottom since it's more visible than when it's up by mne.

I wasn't being clear. I like that you add a warning-like sentence after the whole results table is done. What I meant was that I don't like the entry for MNE spanning two lines.

@larsoner
Copy link
Member Author

So something like:

Platform             Linux-6.2.0-35-generic-x86_64-with-glibc2.37
Python               3.11.4 (main, Jun  9 2023, 07:59:55) [GCC 12.3.0]
Executable           /home/larsoner/python/virtualenvs/base/bin/python3
CPU                  x86_64 (8 cores)
Memory               62.7 GB

Core
├☒ mne               1.6.0.dev154+ga320b631a7.d20231024 (outdated, release 1.7.0 is available!)
├☑ numpy             2.0.0.dev0+git20231025.9f6789c (OpenBLAS 0.3.23.dev with 4 threads)
...
├☑ mne-bids          0.14.dev0
├☑ mne-bids-pipeline 1.4.0
└☐ unavailable       mne-nirs, mne-features, mne-connectivity, mne-icalabel

To update to the latest supported release version to get bugfixes and improvements, visit https://mne.tools/stable/install/updating.html

and for the other variants:

├☑ mne               1.6.0.dev154+ga320b631a7.d20231024 (devel, latest release is 1.5.1)

├☑ mne               1.5.1 (latest release)

├☑ mne               1.6.0.dev154+ga320b631a7.d20231024 (unable to check for latest version on GitHub, 2.0 sec timeout)

@drammock
Copy link
Member

So something like:

yes exactly!

@larsoner
Copy link
Member Author

Okay pushed a commit for that. Just need to add a couple tests and changelog!

@larsoner
Copy link
Member Author

Okay tests and changelog updated

Copy link
Member

@drammock drammock left a comment

Choose a reason for hiding this comment

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

LGTM except for one oversight I think, see below

mne/utils/config.py Outdated Show resolved Hide resolved
Co-authored-by: Daniel McCloy <dan@mccloy.info>
@hoechenberger
Copy link
Member

We could also query PyPI to ensure the package is already pip-installable by the time we display the message:
https://pypi.python.org/pypi/mne/json

@hoechenberger
Copy link
Member

hoechenberger commented Oct 27, 2023

@larsoner
Something to consider before merging

I'm behind a corporate firewall that injects a self-signed MITM certificate so it can spy on TLS connections

Which can cause troubles connecting to online services unless one explicitly specifies that one trusts this cert

For example, for Python's requests I have to set the REQUESTS_CA_BUNDLE env var or else connections may fail.
(For Node and conda, it's yet another setting. Yeah, real fun, I tell ya…)

I'd like to try out how this branch behaves in different settings (with and without the env var set; connection from the office and remotely through a VPN; on the host machine and inside a Docker Dev Container) before we merge, just to ensure sys_info doesn't suddenly explode or spit out many lines of error messages

But I won't have time to test before next week

Please hold off merging until then if possible

And please do ping me if you don't hear back from me by Wednesday

Thanks

@drammock
Copy link
Member

I'd like to try out how this branch behaves in different settings (with and without the env var set; connection from the office and remotely through a VPN; on the host machine and inside a Docker Dev Container) before we merge

Good idea, IMO there is no rush on this one

@hoechenberger
Copy link
Member

Seems to be working for me, however, I basically immediately see this line when running behind our corporate firewall:

├☑ mne               1.6.0.dev167+gda1747f02 (unable to check for latest version on GitHub, 2.0 sec timeout)

Clearly, 2 sec have not passed, I get this output almost instantaneously

So maybe we should just remove the part of the logging message that mentions the timeout?

@hoechenberger
Copy link
Member

The exception that occurs is:

URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1006)>

@hoechenberger
Copy link
Member

hoechenberger commented Oct 30, 2023

… and the solution (on the user's end) is to set the SSL_CERT_FILE env var to the path of the self-signed root certificate.

❯ SSL_CERT_FILE=... mne sys_info
...
├☑ mne               1.6.0.dev167+gda1747f02 (devel, latest release is 1.5.1)
...

mne/utils/config.py Outdated Show resolved Hide resolved
@larsoner
Copy link
Member Author

So maybe we should just remove the part of the logging message that mentions the timeout?

Now I triage timeouts, SSL errors, and unknown errors. It seemed reasonable to add some explanation to these cases

@hoechenberger
Copy link
Member

@larsoner Works! :)

@drammock drammock merged commit 72225b5 into mne-tools:main Oct 30, 2023
28 checks passed
@drammock drammock deleted the et branch October 30, 2023 17:17
larsoner added a commit to larsoner/mne-python that referenced this pull request Nov 3, 2023
* upstream/main: (35 commits)
  [DOC] Add documentation for setting montage order (mne-tools#12160)
  Fix inferring fiducials from EEGLAB (mne-tools#12165)
  Try to fix ICA Report (mne-tools#12167)
  BUG: Fix bug with Report.add_ica component number (mne-tools#12156)
  MAINT: Add rstcheck to CIs and pre-commit (mne-tools#12163)
  DOC: fix sphinx style typos (mne-tools#12161)
  MAINT: Fix linkcheck (mne-tools#12162)
  ENH: Add multiple label support to source_band_induced_power, source_induced_power (mne-tools#12026)
  Allow automated metadata generation to be bounded by "row events" instead of explicit time windows (mne-tools#12118)
  ENH: Collapse only in doc gen (mne-tools#12145)
  [pre-commit.ci] pre-commit autoupdate (mne-tools#12155)
  BUG: Fix bug with interior points not showing (mne-tools#12148)
  ENH: Warn about versions in sys_info (mne-tools#12146)
  Fix in conftest.py (mne-tools#12150)
  ENH: set color for bad channel with spatial_colors=True (mne-tools#12142)
  DOC: Better documentation of realign_raw (mne-tools#12135)
  Add mne-icalabel wildcard (mne-tools#12143)
  Remove LGTM.com configuration file (mne-tools#12139)
  DOC: Fix typo found by codespell (mne-tools#12140)
  DOC: Document governance updates (mne-tools#12133)
  ...
larsoner added a commit to JD-Zhu/mne-python that referenced this pull request Nov 3, 2023
* upstream/main: (26 commits)
  FIX: Fix bug with coreg scalars (mne-tools#12164)
  Changed casting rule in np.clip to allow reading of raw GDF files (mne-tools#12168)
  [DOC] Add documentation for setting montage order (mne-tools#12160)
  Fix inferring fiducials from EEGLAB (mne-tools#12165)
  Try to fix ICA Report (mne-tools#12167)
  BUG: Fix bug with Report.add_ica component number (mne-tools#12156)
  MAINT: Add rstcheck to CIs and pre-commit (mne-tools#12163)
  DOC: fix sphinx style typos (mne-tools#12161)
  MAINT: Fix linkcheck (mne-tools#12162)
  ENH: Add multiple label support to source_band_induced_power, source_induced_power (mne-tools#12026)
  Allow automated metadata generation to be bounded by "row events" instead of explicit time windows (mne-tools#12118)
  ENH: Collapse only in doc gen (mne-tools#12145)
  [pre-commit.ci] pre-commit autoupdate (mne-tools#12155)
  BUG: Fix bug with interior points not showing (mne-tools#12148)
  ENH: Warn about versions in sys_info (mne-tools#12146)
  Fix in conftest.py (mne-tools#12150)
  ENH: set color for bad channel with spatial_colors=True (mne-tools#12142)
  DOC: Better documentation of realign_raw (mne-tools#12135)
  Add mne-icalabel wildcard (mne-tools#12143)
  Remove LGTM.com configuration file (mne-tools#12139)
  ...
snwnde pushed a commit to snwnde/mne-python that referenced this pull request Mar 20, 2024
Co-authored-by: Daniel McCloy <dan@mccloy.info>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: Actively suggest updating MNE to a supported version
3 participants