diff --git a/.gitignore b/.gitignore index 7bbc71c..deed7f4 100644 --- a/.gitignore +++ b/.gitignore @@ -87,6 +87,8 @@ celerybeat-schedule venv/ ENV/ +.idea/ + # Spyder project settings .spyderproject .spyproject diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4da9a33 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,11 @@ +language: python +python: +- '3.6' +cache: pip +install: +- make install +script: +- make test +notifications: + slack: + secure: f46jABKvxN82+MbbNFA2rp5dZrRpDJXaQr7tJAOZgVAlvfq5IRWmWgjluczFAZ4ibhChnSRVyfiFY9/ZlWWZ/9lvUgqN0kCollcWXVdp8ic7Ev3c9b+YNxzvYMSnI7GyI7ijT2jCF6fDQxJIKhI8+C0xSfwqboo7indxuYHJWyZje9XEsOLdsXo4uqHTPMU8VP1MNh47Sid+NIz6zlW59rgsYejIb9JlvlO8T2w/I24KyveSxaASRq1wUQEzVlfHW97U160SvS+sGhz7aoBoomWfRVH87P1/vcDLJ7CFSr1TqTERL+UwKG8zJawzNMTR06c9fnd7FZJ7bKumPufiCz982hXzllG3L+wjqzinbBr3/YxPpi9hBbQvS2OjJGjayYC9gYPBqV7Ts4WTmkSNkGcJkb/hxIwamOhREnNE36K9LPILUFUwCTltJuIaZ9H87daqa/tt9h4iKVICP1rUXD9MpwyP8GAc9Mw0DOg4gbtnKIoO5Jh1Eej9xkINJRnMTK2vPR/DVRFN3kemiKp775TucszZIZGWdHoM6kTPwNPTf4gqAfZlbaUh6xYFfizTtT6HZFGxqZ7NPXf+BbLKZqU8fWJ2smHQ2M5TUHiVcbb/BAWhUnNO3wa6Xx8sMaH1H1joLcrUCdVz8GYZSPTyT4lAtaaw782odnlsr5BpAUs= diff --git a/Dockerfile b/Dockerfile index d446a53..3611765 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,16 +4,12 @@ RUN mkdir -p /var/pair WORKDIR /var/pair -COPY test_requirements.txt ./ - -RUN pip3 install -r test_requirements.txt - +COPY dev-requirements.txt ./ COPY requirements.txt ./ - -RUN pip3 install -r requirements.txt - COPY . ./ +RUN pip3 install -r dev-requirements.txt +RUN pip3 install -r requirements.txt RUN pip3 install -e . CMD py.test diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e0afa9e --- /dev/null +++ b/Makefile @@ -0,0 +1,71 @@ +.DEFAULT_GOAL := help + +define PRINT_HELP_PYSCRIPT +import re, sys + + +HEADER = '\033[95m' +OKBLUE = '\033[94m' +OKGREEN = '\033[92m' +WARNING = '\033[93m' +FAIL = '\033[91m' +ENDCOLOR = '\033[0m' +BOLD = '\033[1m' +UNDERLINE = '\033[4m' + +print(OKBLUE + "Welcome! You can run these make commands:\n" + ENDCOLOR) + +for line in sys.stdin: + match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line) + if match: + target, help = match.groups() + print(OKGREEN + "%-30s " % target + ENDCOLOR + "%s" % (help)) +endef +export PRINT_HELP_PYSCRIPT + +help: ## Get help messages + @python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST) +.PHONY: help + +github: ## Open the GitHub repo for this project + open https://github.com/superconductive/cooper-pair +.PHONY: github + +install: ## update your python environment + pip install -r requirements.txt || echo 'No requirements.txt found' + pip install -r dev-requirements.txt || echo 'No dev-requirements.txt found' + pip install -e . + pip list +.PHONY: install-requirements + +notebooks: ## Run juypter lab for your notebooks + jupyter lab +.PHONY: notebooks + +clean: ## Clean out python cache files + find . -name '*.pyc' -delete + find . -name '__pycache__' -type d | xargs rm -fr + rm -fr docs/_build/ + rm -fr dist/* +.PHONY: clean + +dist: clean ## builds source and wheel package + python setup.py sdist + python setup.py bdist_wheel + ls -l dist +.PHONY: dist + +release: dist ## package and upload a release +# TODO using TEST pypi for now +# twine upload dist/* + twine upload --repository-url https://test.pypi.org/legacy/ dist/* +.PHONY: release + +venv: ## Create a new virtualenv in the repo root + rm -rf venv + virtualenv venv +.PHONY: venv + +test: ## Run tests + pytest -s tests +.PHONY: test diff --git a/cooper_pair/__init__.py b/cooper_pair/__init__.py index b84a947..62ce330 100644 --- a/cooper_pair/__init__.py +++ b/cooper_pair/__init__.py @@ -1 +1 @@ -from .pair import CooperPair +from cooper_pair.pair import CooperPair diff --git a/cooper_pair/version.py b/cooper_pair/version.py deleted file mode 100644 index d18f409..0000000 --- a/cooper_pair/version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = '0.0.2' diff --git a/dev-requirements.txt b/dev-requirements.txt new file mode 100644 index 0000000..1eb4a19 --- /dev/null +++ b/dev-requirements.txt @@ -0,0 +1,4 @@ +pandas==0.22.0 +pytest-cov==2.5.1 +pytest==3.2.5 +twine \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index c3760f2..aeef4ba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -pytest-cov==2.5.1 -pytest==3.2.5 +great_expectations==0.4.4 gql==0.1.0 requests==2.20.1 diff --git a/setup.py b/setup.py index db0fd55..b97fa4e 100644 --- a/setup.py +++ b/setup.py @@ -1,31 +1,31 @@ -#!/usr/bin/python +#!/usr/bin/env python -import os -from pip.download import PipSession -from pip.req import parse_requirements -from setuptools import (find_packages, setup) +from setuptools import find_packages, setup -def get_version(): - basedir = os.path.dirname(__file__) - with open(os.path.join(basedir, 'cooper_pair/version.py')) as f: - __version__ = None - exec(f.read()) - return __version__ +with open("README.md", "r") as fh: + long_description = fh.read() if __name__ == '__main__': - install_reqs = list( - parse_requirements( - 'requirements.txt', - session=PipSession())) - dependency_links = [str(r.url) for r in install_reqs if hasattr(r, 'url')] - install_reqs = [str(r.req) for r in install_reqs if r.req] - - setup(name='cooper_pair', - version=get_version(), - author='Superconductive Health', - author_email='dev@superconductivehealth.com', - maintainer='Superconductive Health', - maintainer_email='dev@superconductivehealth.com', - install_requires=install_reqs, - dependency_links=dependency_links, - packages=find_packages()) + setup( + name='cooper_pair', + version='0.0.4', + author='Superconductive Health', + author_email='dev@superconductivehealth.com', + maintainer='Superconductive Health', + maintainer_email='dev@superconductivehealth.com', + url='https://github.com/superconductive/cooper-pair', + packages=find_packages(), + classifiers=[ + 'Programming Language :: Python :: 3', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: OS Independent', + ], + description='A small library that provides programmatic access to Superconductive\'s GraphQL API.', + long_description=long_description, + long_description_content_type="text/markdown", + install_requires=[ + 'gql', + 'requests', + 'great_expectations' + ], + ) diff --git a/test_requirements.txt b/test_requirements.txt deleted file mode 100644 index 38b0c59..0000000 --- a/test_requirements.txt +++ /dev/null @@ -1 +0,0 @@ -pandas==0.22.0 diff --git a/tests/test_pair.py b/tests/test_pair.py index 20ba338..973934d 100644 --- a/tests/test_pair.py +++ b/tests/test_pair.py @@ -16,8 +16,7 @@ except ImportError: from StringIO import StringIO -from cooper_pair import CooperPair -from cooper_pair.version import __version__ +from cooper_pair.pair import CooperPair from graphql.error.syntax_error import GraphQLSyntaxError DQM_GRAPHQL_URL = os.getenv('DQM_GRAPHQL_URL', 'http://0.0.0.0:3010/graphql') @@ -25,7 +24,10 @@ pair = CooperPair( graphql_endpoint=DQM_GRAPHQL_URL, email='machine@superconductivehealth.com', - password='foobar') + password='foobar', + timeout=1, + max_retries=1, +) SAMPLE_EXPECTATIONS_CONFIG = { 'dataset_name': None, @@ -38,9 +40,6 @@ 'meta': {'great_expectations.__version__': '0.4.3'}} -def test_version(): - assert __version__ - # FIXME: This test runs very slowly def test_init(): assert pair.client #This is the slow line. @@ -54,7 +53,7 @@ def test_init_client_without_credentials(): #FIXME: This test runs very slowly def test_login_success(): with pytest.warns(UserWarning): - pair = CooperPair(graphql_endpoint=DQM_GRAPHQL_URL) + pair = CooperPair(graphql_endpoint=DQM_GRAPHQL_URL, timeout=1, max_retries=1) assert pair.login( email='machine@superconductivehealth.com', password='foobar') @@ -62,7 +61,7 @@ def test_login_success(): #FIXME: This test runs very slowly def test_login_failure(): with pytest.warns(UserWarning): - pair = CooperPair(graphql_endpoint=DQM_GRAPHQL_URL) + pair = CooperPair(graphql_endpoint=DQM_GRAPHQL_URL, timeout=1, max_retries=1) with pytest.warns(UserWarning): assert not pair.login( email='sdfjkhkdfsh', @@ -77,7 +76,7 @@ def test_login_failure(): #FIXME: This test runs very slowly def test_unauthenticated_query(): with pytest.warns(UserWarning): - pair = CooperPair(graphql_endpoint=DQM_GRAPHQL_URL) + pair = CooperPair(graphql_endpoint=DQM_GRAPHQL_URL, timeout=1, max_retries=1) with pytest.warns(UserWarning): pair.add_evaluation(dataset_id=1, checkpoint_id=1)