-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* initial impl for show_versions * add matplotlib and altair versions * Update lux/utils/debug_utils.py Co-authored-by: Doris Lee <[email protected]> * Update lux/utils/debug_utils.py Co-authored-by: Doris Lee <[email protected]> * Update lux/utils/debug_utils.py Co-authored-by: Doris Lee <[email protected]> * add docs + test * add jupyter information Co-authored-by: Doris Lee <[email protected]>
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
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
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,52 @@ | ||
import re | ||
import subprocess | ||
from typing import Optional | ||
|
||
|
||
def show_versions(return_string: bool = False) -> Optional[str]: | ||
""" | ||
Prints the versions of the principal packages used by Lux for debugging purposes. | ||
Parameters | ||
---------- | ||
return_string: Whether to return the versions as a string or print them. | ||
Returns | ||
------- | ||
If return_string is True, returns a string with the versions else the versions | ||
are printed and None is returned. | ||
""" | ||
import platform | ||
|
||
import altair | ||
import lux | ||
import luxwidget | ||
import matplotlib | ||
import pandas as pd | ||
|
||
jupyter_versions_str = subprocess.check_output(["jupyter", "--version"]) | ||
jupyter_versions = re.findall(r"(\S+)\s+: (.+)\S*", jupyter_versions_str.decode("utf-8")) | ||
|
||
df = pd.DataFrame( | ||
[ | ||
("python", platform.python_version()), | ||
("lux", lux.__version__), | ||
("pandas", pd.__version__), | ||
("luxwidget", luxwidget.__version__), | ||
("matplotlib", matplotlib.__version__), | ||
("altair", altair.__version__), | ||
] | ||
+ jupyter_versions, | ||
columns=["", "Version"], | ||
) | ||
|
||
str_rep = df.to_string(index=False, justify="left") | ||
|
||
if return_string: | ||
return str_rep | ||
else: | ||
print(str_rep) | ||
|
||
|
||
if __name__ == "__main__": | ||
show_versions() |
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,20 @@ | ||
import lux | ||
|
||
|
||
class TestDebugUtils: | ||
def test_show_info(self): | ||
|
||
versions = lux.show_versions(return_string=True) | ||
|
||
assert versions is not None | ||
|
||
assert "python" in versions | ||
assert "lux" in versions | ||
assert "pandas" in versions | ||
assert "luxwidget" in versions | ||
assert "matplotlib" in versions | ||
assert "altair" in versions | ||
|
||
|
||
if __name__ == "__main__": | ||
TestDebugUtils().test_show_info() |