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

Add CLI entrypoint #493

Merged
merged 12 commits into from Apr 16, 2019
@@ -1,8 +1,10 @@
import click
import pandas as pd
import pkg_resources

import featuretools
from featuretools.primitives.utils import get_featuretools_root
from featuretools.utils.cli_utils import get_installed_packages, get_sys_info
This conversation was marked as resolved by gsheni

This comment has been minimized.

Copy link
@kmax12

kmax12 Apr 16, 2019

Member

let’s also make them importable from featuretools.utils and access them from there. that way if we change the cli_utils.py file name it doesnt cause problems

This comment has been minimized.

Copy link
@gsheni

gsheni Apr 16, 2019

Author Contributor

Fixed.



@click.group()
@@ -15,6 +17,34 @@ def info():
print("Featuretools version: %s" % featuretools.__version__)
print("Featuretools installation directory: %s" % get_featuretools_root())

print("\nINSTALLED VERSIONS")
print("------------------")
sys_info = get_sys_info()
for k, stat in sys_info:
print("{k}: {stat}".format(k=k, stat=stat))

print("")

installed_packages = get_installed_packages()
deps = [
("numpy", installed_packages['numpy']),
("pandas", installed_packages['pandas']),
("tqdm", installed_packages['tqdm']),
("toolz", installed_packages['toolz']),
("PyYAML", installed_packages['PyYAML']),
("cloudpickle", installed_packages['cloudpickle']),
("future", installed_packages['future']),
("dask", installed_packages['dask']),
("distributed", installed_packages['distributed']),
("psutil", installed_packages['psutil']),
("Click", installed_packages['Click']),
("scikit-learn", installed_packages['scikit-learn']),
("pip", installed_packages['pip']),
("setuptools", installed_packages['setuptools']),
]
for k, stat in deps:
print("{k}: {stat}".format(k=k, stat=stat))


@click.command()
def list_primitives():
@@ -25,6 +55,14 @@ def list_primitives():
cli.add_command(list_primitives)
cli.add_command(info)

for entry_point in pkg_resources.iter_entry_points('featuretools_cli'):
try:
loaded = entry_point.load()
if hasattr(loaded, 'commands'):
for name, cmd in loaded.commands.items():
cli.add_command(cmd=cmd, name=name)
except Exception:
pass

if __name__ == "__main__":
cli()
@@ -0,0 +1,42 @@
import locale
import os
import platform
import struct
import sys

import pkg_resources


# Modified from here
# https://github.com/pandas-dev/pandas/blob/d9a037ec4ad0aab0f5bf2ad18a30554c38299e57/pandas/util/_print_versions.py#L11
def get_sys_info():
This conversation was marked as resolved by gsheni

This comment has been minimized.

Copy link
@kmax12

kmax12 Apr 16, 2019

Member

can we add a test case that calls get_installed_packages and get_sys_info even if it doesn’t check the outputs? that would at least catch any runtime errors

This comment has been minimized.

Copy link
@gsheni

gsheni Apr 16, 2019

Author Contributor

Fixed.

"Returns system information as a dict"

blob = []

try:
(sysname, nodename, release,
version, machine, processor) = platform.uname()
blob.extend([
("python", '.'.join(map(str, sys.version_info))),
("python-bits", struct.calcsize("P") * 8),
("OS", "{sysname}".format(sysname=sysname)),
("OS-release", "{release}".format(release=release)),
("machine", "{machine}".format(machine=machine)),
("processor", "{processor}".format(processor=processor)),
("byteorder", "{byteorder}".format(byteorder=sys.byteorder)),
("LC_ALL", "{lc}".format(lc=os.environ.get('LC_ALL', "None"))),
("LANG", "{lang}".format(lang=os.environ.get('LANG', "None"))),
("LOCALE", '.'.join(map(str, locale.getlocale()))),
])
except (KeyError, ValueError):
pass

return blob


def get_installed_packages():
installed_packages = {}
for d in pkg_resources.working_set:
installed_packages[d.project_name] = d.version
return installed_packages
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.