-
Notifications
You must be signed in to change notification settings - Fork 651
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
Implement "modin.pandas.show_versions()" and "python -m modin --versions" #4007
Merged
devin-petersohn
merged 9 commits into
modin-project:master
from
vnlitvinov:show-versions
Jan 24, 2022
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1a43a82
FEAT-#3971: Add modin.utils.show_versions
vnlitvinov 50e6706
Implement "python -m modin --version"
vnlitvinov dd2c53f
Add a test for modin.utils.show_versions
vnlitvinov 6f11fd0
Move things to satisfy flake8
vnlitvinov ffed75d
Fix linting errors
vnlitvinov af47211
Fix capsys fixture usage
vnlitvinov 00f7e47
Replace pandas commit hash with Modin commit hash
vnlitvinov d74810d
Better compat with pandas.show_versions(as_json=True)
vnlitvinov 88f2e8c
Skip __main__.py from code coverage
vnlitvinov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Licensed to Modin Development Team under one or more contributor license agreements. | ||
# See the NOTICE file distributed with this work for additional information regarding | ||
# copyright ownership. The Modin Development Team licenses this file to you under the | ||
# Apache License, Version 2.0 (the "License"); you may not use this file except in | ||
# compliance with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software distributed under | ||
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
# ANY KIND, either express or implied. See the License for the specific language | ||
# governing permissions and limitations under the License. | ||
|
||
"""Command-line interface piece, called when user issues "python -m modin --foo".""" | ||
|
||
import argparse | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser( | ||
"python -m modin", | ||
description="Drop-in pandas replacement; refer to https://modin.readthedocs.io/ for details.", | ||
) | ||
parser.add_argument( | ||
"--versions", | ||
action="store_true", | ||
default=False, | ||
help="Show versions of all known components", | ||
) | ||
|
||
args = parser.parse_args() | ||
if args.versions: | ||
from modin.utils import show_versions | ||
|
||
show_versions() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,20 +12,31 @@ | |
# governing permissions and limitations under the License. | ||
|
||
"""Collection of general utility functions, mostly for internal use.""" | ||
from __future__ import annotations | ||
|
||
import importlib | ||
import types | ||
import re | ||
import sys | ||
import json | ||
import codecs | ||
|
||
from textwrap import dedent, indent | ||
from typing import Union | ||
from packaging import version | ||
|
||
import pandas | ||
import numpy as np | ||
|
||
from pandas.util._decorators import Appender | ||
from pandas.util._print_versions import _get_sys_info, _get_dependency_info | ||
from pandas._typing import JSONSerializable | ||
|
||
from modin.config import Engine, StorageFormat, IsExperimental | ||
|
||
MIN_RAY_VERSION = version.parse("1.4.0") | ||
MIN_DASK_VERSION = version.parse("2.22.0") | ||
|
||
PANDAS_API_URL_TEMPLATE = f"https://pandas.pydata.org/pandas-docs/version/{pandas.__version__}/reference/api/{{}}.html" | ||
|
||
|
||
|
@@ -561,3 +572,103 @@ def import_optional_dependency(name, message): | |
f"Missing optional dependency '{name}'. {message} " | ||
f"Use pip or conda to install {name}." | ||
) from None | ||
|
||
|
||
def _get_modin_deps_info() -> dict[str, JSONSerializable]: | ||
""" | ||
Return Modin-specific dependencies information as a JSON serializable dictionary. | ||
|
||
Returns | ||
------- | ||
dict[str, JSONSerializable] | ||
The dictionary of Modin dependencies and their versions. | ||
""" | ||
import modin # delayed import so modin.__init__ is fully initialized | ||
|
||
result = {"modin": modin.__version__} | ||
|
||
for pkg_name, pkg_version in [ | ||
("ray", MIN_RAY_VERSION), | ||
("dask", MIN_DASK_VERSION), | ||
("distributed", MIN_DASK_VERSION), | ||
]: | ||
try: | ||
pkg = importlib.import_module(pkg_name) | ||
except ImportError: | ||
result[pkg_name] = None | ||
else: | ||
result[pkg_name] = pkg.__version__ + ( | ||
f" (outdated; >={pkg_version} required)" | ||
if version.parse(pkg.__version__) < pkg_version | ||
else "" | ||
) | ||
|
||
try: | ||
# We import ``PyDbEngine`` from this module since correct import of ``PyDbEngine`` itself | ||
# from Omnisci is located in it with all the necessary options for dlopen. | ||
from modin.experimental.core.execution.native.implementations.omnisci_on_native.utils import ( # noqa | ||
PyDbEngine, | ||
) | ||
|
||
result["omniscidbe"] = "present" | ||
except ImportError: | ||
result["omniscidbe"] = None | ||
|
||
return result | ||
|
||
|
||
# Disable flake8 checks for print() in this file | ||
# flake8: noqa: T001 | ||
def show_versions(as_json: str | bool = False) -> None: | ||
""" | ||
Provide useful information, important for bug reports. | ||
|
||
It comprises info about hosting operation system, pandas version, | ||
and versions of other installed relative packages. | ||
|
||
Parameters | ||
---------- | ||
as_json : str or bool, default: False | ||
* If False, outputs info in a human readable form to the console. | ||
* If str, it will be considered as a path to a file. | ||
Info will be written to that file in JSON format. | ||
* If True, outputs info in JSON format to the console. | ||
|
||
Notes | ||
----- | ||
This is mostly a copy of pandas.show_versions() but adds separate listing | ||
of Modin-specific dependencies | ||
vnlitvinov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
sys_info = _get_sys_info() | ||
vnlitvinov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
modin_deps = _get_modin_deps_info() | ||
deps = _get_dependency_info() | ||
|
||
if as_json: | ||
j = { | ||
"system": sys_info, | ||
"modin dependencies": modin_deps, | ||
"pandas dependencies": deps, | ||
} | ||
|
||
if as_json is True: | ||
sys.stdout.writelines(json.dumps(j, indent=2)) | ||
else: | ||
assert isinstance(as_json, str) # needed for mypy | ||
with codecs.open(as_json, "wb", encoding="utf8") as f: | ||
json.dump(j, f, indent=2) | ||
|
||
else: | ||
assert isinstance(sys_info["LOCALE"], dict) # needed for mypy | ||
language_code = sys_info["LOCALE"]["language-code"] | ||
encoding = sys_info["LOCALE"]["encoding"] | ||
sys_info["LOCALE"] = f"{language_code}.{encoding}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to override this value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is mostly a copy-paste from |
||
|
||
maxlen = max(max(len(x) for x in d) for d in (deps, modin_deps)) | ||
print("\nINSTALLED VERSIONS") | ||
print("------------------") | ||
for k, v in sys_info.items(): | ||
print(f"{k:<{maxlen}}: {v}") | ||
for name, d in (("Modin", modin_deps), ("pandas", deps)): | ||
print(f"\n{name} dependencies\n{'-' * (len(name) + 13)}") | ||
for k, v in d.items(): | ||
print(f"{k:<{maxlen}}: {v}") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is there a way to know omniscidbe version?
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 didn't find any (except querying by something like
conda list
). Maybe there's some C API of sorts... @modin-project/modin-omnisci ideas?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.
Currently, we don't have any API to get omniscidbe version
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.
Does
conda list
way make sense to use?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.
Too many assumptions (and
conda list
is a slow thing to me).I would rather we add an API function to get the version.
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.
Also we assume that
conda
is present in the PATH which is not guaranteed.