From 46d9373bdfafd6e3d3ed6a540ebda0022a5d333f Mon Sep 17 00:00:00 2001 From: ragrawal Date: Fri, 20 Nov 2020 15:36:56 -0800 Subject: [PATCH 1/3] switched to nox --- .circleci/config.yml | 4 ++-- CONTRIBUTING.md | 11 +++++------ nox.ini | 13 +++++++++++++ noxfile.py | 24 ++++++++++++++++++++++++ tests/test_dataframe_mapper.py | 9 +-------- tox.ini | 30 ------------------------------ 6 files changed, 45 insertions(+), 46 deletions(-) create mode 100644 nox.ini create mode 100644 noxfile.py delete mode 100644 tox.ini diff --git a/.circleci/config.yml b/.circleci/config.yml index 581bf33..6886a50 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -5,8 +5,8 @@ jobs: - image: circleci/python:3.6 steps: - checkout - - run: pip install --user tox - - run: ~/.local/bin/tox + - run: pip install --user nox + - run: ~/.local/bin/nox workflows: version: 2 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f96fcce..77d3e2b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,12 +2,11 @@ ## Development environment and steps -1. Install `tox` either globally or in a virtualenv: `pip install tox`. -2. Click on the "Fork" button at the top-right of the GitHub page. -3. Clone your fork. Example: `git clone git@github.com:dukebody/sklearn-pandas.git`. -4. Create a new branch to work on the issue/feature you want. -5. Hack out your code. To run the tests and `flake8`, just run `tox`. Tests live in the `tests` subfolder. -6. Submit a new PR with your code, indicating in the PR which issue/feature it relates to. +1. Click on the "Fork" button at the top-right of the GitHub page. +2. Clone your fork. Example: `git clone git@github.com:dukebody/sklearn-pandas.git`. +3. Create a new branch to work on the issue/feature you want. +4. Hack out your code. To run the tests and `flake8`, just run `nox`. Tests live in the `tests` subfolder. +5. Submit a new PR with your code, indicating in the PR which issue/feature it relates to. Note: You don't need to install `sklearn-pandas` in your virtualenv to run the tests. `tox` will automatically create multiple virtual environments to run them with multiple package versions. diff --git a/nox.ini b/nox.ini new file mode 100644 index 0000000..82c0b8d --- /dev/null +++ b/nox.ini @@ -0,0 +1,13 @@ +[flake8] + exclude = + .git + .github + __pycache__ + build + dist + *site-packages/ + *bin/ + *.egg/* + .eggs + .tox + docs \ No newline at end of file diff --git a/noxfile.py b/noxfile.py new file mode 100644 index 0000000..0d391bd --- /dev/null +++ b/noxfile.py @@ -0,0 +1,24 @@ +import nox + +@nox.session +def lint(session): + session.install('pytest==5.3.5', 'setuptools==45.2', + 'wheel==0.34.2', 'flake8==3.7.9', + 'numpy==1.18.1', 'pandas==1.0.5') + session.install('.') + session.run('flake8', 'sklearn_pandas/', 'tests') + +@nox.session +@nox.parametrize('numpy', ['1.18.1', '1.19.4']) +@nox.parametrize('scipy', ['1.4.1', '1.5.4']) +@nox.parametrize('pandas', ['1.0.5', '1.1.4']) +def tests(session, numpy, scipy, pandas): + session.install('pytest==5.3.5', + 'setuptools==45.2', + 'wheel==0.34.2', + f'numpy=={numpy}', + f'scipy=={scipy}', + f'pandas=={pandas}' + ) + session.install('.') + session.run('py.test', 'README.rst', 'tests') diff --git a/tests/test_dataframe_mapper.py b/tests/test_dataframe_mapper.py index 54e8dac..bd2e59b 100644 --- a/tests/test_dataframe_mapper.py +++ b/tests/test_dataframe_mapper.py @@ -1,14 +1,7 @@ # -*- coding: utf8 -*- import pytest - -# In py3, mock is included with the unittest standard library -# In py2, it's a separate package -try: - from unittest.mock import Mock -except ImportError: - from mock import Mock - +from unittest.mock import Mock from pandas import DataFrame import pandas as pd from scipy import sparse diff --git a/tox.ini b/tox.ini deleted file mode 100644 index c67a41a..0000000 --- a/tox.ini +++ /dev/null @@ -1,30 +0,0 @@ -[flake8] -exclude = - .git - __pycache__ - docs/source/conf.py - old - build - dist - *site-packages/ - *bin/ - -[tox] -envlist = {py36,py37}-sklearn{22,23}-pandas{105,110} - -[testenv] -deps = - pytest==5.3.5 - setuptools==45.2 - wheel==0.34.2 - flake8==3.7.9 - numpy==1.18.1 - scipy==1.4.1 - pandas105: pandas==1.0.5 - pandas110: pandas==1.1.0 - sklearn22: scikit-learn==0.22.2 - sklearn23: scikit-learn==0.23.1 - -commands = - flake8 - py.test README.rst tests From a8446367ed7460b10d18d19aacf3e7e56c935073 Mon Sep 17 00:00:00 2001 From: ragrawal Date: Fri, 20 Nov 2020 15:45:18 -0800 Subject: [PATCH 2/3] added test before publishing the package --- .github/workflows/python-publish.yml | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 24cc431..58cafed 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -3,11 +3,32 @@ name: Upload Python Package -on: [workflow_dispatch] +on: + workflow_dispatch: + branches: + - main jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.6, 3.7, 3.8] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install nox + - name: Test with pytest + run: nox + deploy: - + needs: test runs-on: ubuntu-latest steps: From 5c74f1a3ae7b34e4b82db28468bd7661c67940f5 Mon Sep 17 00:00:00 2001 From: ragrawal Date: Fri, 20 Nov 2020 15:47:41 -0800 Subject: [PATCH 3/3] updated readme" --- README.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.rst b/README.rst index 45e54ea..4a61112 100644 --- a/README.rst +++ b/README.rst @@ -451,6 +451,10 @@ Below example shows how to change logging level. >>> import logging >>> logging.getLogger('sklearn_pandas').setLevel(logging.INFO) +Changes Not Yet Published +--------- + +* Using nox for testing Changelog ---------