Skip to content

CLN: Deduplicate show_versions #26816

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

Merged
merged 4 commits into from
Jun 21, 2019

Conversation

TomAugspurger
Copy link
Contributor

@TomAugspurger TomAugspurger commented Jun 12, 2019

Closes #26814

The old version had special cases for numpy, scipy, and pytz. All those now provide a standard __version__. xlrd and xlwt are the only special ones now (__version__)

I messed up the minimum xlwt version in the last PR. I copied openpyxl's rather than xlwt's. That's now fixed.

I prettied up the output format a bit, to align the version numbers. Hope that 's OK.

INSTALLED VERSIONS
------------------
commit           : cbc6edf8bfad33c8bc698a3d035b593d921b0112
python           : 3.7.3.final.0
python-bits      : 64
OS               : Darwin
OS-release       : 18.6.0
machine          : x86_64
processor        : i386
byteorder        : little
LC_ALL           : None
LANG             : en_US.UTF-8
LOCALE           : en_US.UTF-8

pandas           : 0.25.0.dev0+729.gcbc6edf8b
pytest           : 4.6.2
pip              : 19.1.1
setuptools       : 41.0.1
Cython           : 0.29.10
numpy            : 1.17.0.dev0+5b06588
scipy            : 1.3.0
pyarrow          : 0.13.0
xarray           : 0.12.1
IPython          : 7.5.0
sphinx           : 1.8.5
patsy            : 0.5.1
dateutil         : 2.7.3
pytz             : 2018.5
blosc            : 1.5.1
bottleneck       : 1.2.1
tables           : 3.5.1
numexpr          : 2.6.8
feather          : 0.4.0
matplotlib       : 3.1.0
openpyxl         : 2.5.11
xlrd             : 1.1.0
xlwt             : 1.3.0
xlsxwriter       : 1.1.2
lxml.etree       : 4.2.5
bs4              : 4.7.1
html5lib         : 1.0.1
sqlalchemy       : 1.2.14
pymysql          : 0.9.2
psycopg2         : 2.7.6.1 (dt dec pq3 ext lo64)
jinja2           : 2.10.1
s3fs             : 0.1.6
fastparquet      : None
pandas_gbq       : 0.10.0
pandas_datareader: None
gcsfs            : 0.1.2

@jreback jreback added CI Continuous Integration Dependencies Required and optional dependencies labels Jun 12, 2019
@jreback jreback added this to the 0.25.0 milestone Jun 12, 2019
@jreback
Copy link
Contributor

jreback commented Jun 12, 2019

formatting looks nice!

@codecov
Copy link

codecov bot commented Jun 12, 2019

Codecov Report

Merging #26816 into master will decrease coverage by <.01%.
The diff coverage is 27.77%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #26816      +/-   ##
==========================================
- Coverage   91.87%   91.86%   -0.01%     
==========================================
  Files         180      180              
  Lines       50746    50748       +2     
==========================================
- Hits        46623    46622       -1     
- Misses       4123     4126       +3
Flag Coverage Δ
#multiple 90.46% <27.77%> (ø) ⬆️
#single 41.12% <27.77%> (-0.07%) ⬇️
Impacted Files Coverage Δ
pandas/compat/_optional.py 100% <ø> (ø) ⬆️
pandas/util/_test_decorators.py 93.84% <100%> (+0.19%) ⬆️
pandas/io/pytables.py 90.29% <100%> (ø) ⬆️
pandas/util/_print_versions.py 15.71% <7.14%> (ø) ⬆️
pandas/io/gbq.py 88.88% <0%> (-11.12%) ⬇️
pandas/core/frame.py 96.89% <0%> (-0.12%) ⬇️
pandas/util/testing.py 90.94% <0%> (+0.1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cfd65e9...e384c40. Read the comment docs.

@TomAugspurger
Copy link
Contributor Author

Got a bit carried away here, sorry.

  1. Fixed xlwt version in the docs / VERSIONS
  2. Updated pytables to use the new way, added to docs / VERSIONS
  3. Added a test decorator for skipping if a library is installed
  4. Deduplicate show_versions (the intent of this PR).

updated output:


INSTALLED VERSIONS
------------------
commit           : a8e0c2dff540ceada75fec07c6ccd4e6f0e79039
python           : 3.7.3.final.0
python-bits      : 64
OS               : Darwin
OS-release       : 18.6.0
machine          : x86_64
processor        : i386
byteorder        : little
LC_ALL           : None
LANG             : en_US.UTF-8
LOCALE           : en_US.UTF-8

pandas           : 0.25.0.dev0+730.ga8e0c2dff.dirty
numpy            : 1.17.0.dev0+5b06588
pytz             : 2018.5
dateutil         : 2.7.3
pip              : 19.1.1
setuptools       : 41.0.1
Cython           : 0.29.10
pytest           : 4.6.2
hypothesis       : 3.59.1
sphinx           : 1.8.5
blosc            : 1.5.1
feather          : 0.4.0
xlsxwriter       : 1.1.2
lxml.etree       : 4.2.5
html5lib         : 1.0.1
pymysql          : 0.9.2
psycopg2         : 2.7.6.1 (dt dec pq3 ext lo64)
jinja2           : 2.10.1
IPython          : 7.5.0
pandas_datareader: None
bs4              : 4.7.1
bottleneck       : 1.2.1
fastparquet      : None
gcsfs            : 0.1.2
matplotlib       : 3.1.0
numexpr          : 2.6.8
openpyxl         : 2.5.11
pandas_gbq       : 0.10.0
pyarrow          : 0.13.0
tables           : 3.5.2
s3fs             : 0.1.6
scipy            : 1.3.0
sqlalchemy       : 1.2.14
xarray           : 0.12.1
xlrd             : 1.1.0
xlwt             : 1.3.0

@@ -140,6 +140,17 @@ def skip_if_no(
)


def skip_if_installed(
Copy link
Contributor

Choose a reason for hiding this comment

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

are u using this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://github.com/pandas-dev/pandas/pull/26816/files#diff-56c44e2fe6ac59a333e18f097db07524R57.

We should probably have a basic test like this for all our optional deps. Thoughts?

It can't go in test_pytables.py since that does an importorskip at the top of the file.

Copy link
Contributor Author

@TomAugspurger TomAugspurger Jun 12, 2019

Choose a reason for hiding this comment

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

Alternatively, we could try monkeypatching / mocking the module, and never skipping these tests, but I've never had luck working around Python's import caching.

Copy link
Contributor

@jreback jreback Jun 12, 2019

Choose a reason for hiding this comment

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

not sure i understand? we already test all of the optional deps but using them
are you suggesting something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

are you suggesting something else?

Yeah, testing when that aren't present.

@@ -50,3 +52,11 @@ def test_no_version_raises():

with pytest.raises(ImportError, match="Can't determine .* fakemodule"):
import_optional_dependency(name)


@td.skip_if_installed("tables")
Copy link
Member

Choose a reason for hiding this comment

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

in the interest of better coverage, would it not be better to monkeypatch builtins.__import__ as was done in #26685 for tests like this rather than skip?

@TomAugspurger

This comment has been minimized.

@jreback
Copy link
Contributor

jreback commented Jun 13, 2019

lgtm. merge on green.

@TomAugspurger
Copy link
Contributor Author

Apologies for the force push.

I've given up on my missing_dependency fixture. Split that off to #26902.

This was referenced Jun 17, 2019
Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

IIRC this had a lot more changes (meaning this actually did the de-duplication of show_versions)


@td.skip_if_installed("tables")
def test_pytables_raises():
df = pd.DataFrame({"A": [1, 2]})
Copy link
Contributor

Choose a reason for hiding this comment

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

can you go ahead and create

pandas/tests/io/pytables/test_missing_deps.py and put this there (we need to split test_pytables anyhow)

@TomAugspurger
Copy link
Contributor Author

IIRC this had a lot more changes (meaning this actually did the de-duplication of show_versions)

Sorry, that de-duplication is restored now.

@jreback jreback merged commit 7f8dd72 into pandas-dev:master Jun 21, 2019
@jreback
Copy link
Contributor

jreback commented Jun 21, 2019

thanks @TomAugspurger very nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration Dependencies Required and optional dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up code duplication in _optional and _print_versions
4 participants