From e0882cf80a073c7838ccc56dde5fd66385b1da93 Mon Sep 17 00:00:00 2001 From: Han Wang Date: Sun, 15 Nov 2020 16:14:37 -0800 Subject: [PATCH] setup (#1) * setup * update --- .devcontainer/devcontainer.json | 31 ++++++ .github/ISSUE_TEMPLATE/bug_report.md | 25 +++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++ .github/ISSUE_TEMPLATE/questions.md | 8 ++ .github/workflows/lint.yml | 28 +++++ .github/workflows/publish.yml | 36 ++++++ .github/workflows/test.yml | 28 +++++ .gitignore | 130 ++++++++++++++++++++++ .pre-commit-config.yaml | 45 ++++++++ Makefile | 33 ++++++ docs/Makefile | 20 ++++ docs/_config.yml | 1 + docs/_templates/package.rst_t | 41 +++++++ docs/_templates/toc.rst_t | 7 ++ docs/conf.py | 65 +++++++++++ docs/index.rst | 14 +++ docs/make.bat | 35 ++++++ fuggle/__init__.py | 2 + fuggle_version/__init__.py | 1 + requirements.txt | 20 ++++ setup.cfg | 15 +++ setup.py | 34 ++++++ tests/__init__.py | 0 tests/test_dummy.py | 2 + 24 files changed, 641 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/questions.md create mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/test.yml create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml create mode 100644 Makefile create mode 100644 docs/Makefile create mode 100644 docs/_config.yml create mode 100644 docs/_templates/package.rst_t create mode 100644 docs/_templates/toc.rst_t create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 docs/make.bat create mode 100644 fuggle/__init__.py create mode 100644 fuggle_version/__init__.py create mode 100644 requirements.txt create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 tests/__init__.py create mode 100644 tests/test_dummy.py diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..f351adb --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,31 @@ +{ + "name": "Fugue Development Environment", + "image": "fugueproject/devenv:latest", + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "python.pythonPath": "/usr/local/bin/python", + "python.linting.enabled": true, + "python.linting.pylintEnabled": true, + "python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8", + "python.formatting.blackPath": "/usr/local/py-utils/bin/black", + "python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf", + "python.linting.banditPath": "/usr/local/py-utils/bin/bandit", + "python.linting.flake8Path": "/usr/local/py-utils/bin/flake8", + "python.linting.mypyPath": "/usr/local/py-utils/bin/mypy", + "python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle", + "python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle", + "python.linting.pylintPath": "/usr/local/py-utils/bin/pylint" + }, + "extensions": [ + "ms-python.python" + ], + "forwardPorts": [ + 8888 + ], + "postCreateCommand": [ + "make devenv" + ], + "mounts": [ + "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" + ] +} diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..b9f7903 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,25 @@ +--- +name: Bug report +about: Create a report to help us improve +title: "[BUG]" +labels: '' +assignees: '' + +--- + +**Minimal Code To Reproduce** + +```python +``` + +**Describe the bug** +A clear and concise description of what the bug is. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Environment (please complete the following information):** + - Backend: pandas/dask/ray? + - Backend version: + - Python version: + - OS: linux/windows diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..e0c0168 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: "[FEATURE]" +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/ISSUE_TEMPLATE/questions.md b/.github/ISSUE_TEMPLATE/questions.md new file mode 100644 index 0000000..57ecbc6 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/questions.md @@ -0,0 +1,8 @@ +--- +name: Questions +about: General questions +title: "[QUESTION]" +labels: '' +assignees: '' + +--- diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..9a00058 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,28 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Lint + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [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: make dev + - name: Lint + run: make lint diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..bc89f99 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,36 @@ +# This workflows will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +name: Publish + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - name: Install dependencies + run: make dev + - name: Test + run: make test + - name: Coveralls + env: + COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} + run: | + pip install coveralls + coveralls + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + make package + twine upload dist/* diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..2fa1e7a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,28 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions + +name: Test + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + 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: make dev + - name: Test + run: make test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f43a35e --- /dev/null +++ b/.gitignore @@ -0,0 +1,130 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ +pythonenv* + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +.vscode +tmp diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..4cdb6eb --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,45 @@ +default_language_version: + python: python3 + +exclude: | + (?x)( + ^tests/| + ^docs/ + ) +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.2.0 + hooks: + - id: check-ast + - id: check-docstring-first + - id: check-executables-have-shebangs + - id: check-json + - id: check-merge-conflict + - id: check-yaml + - id: debug-statements + - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-vcs-permalinks + - repo: https://gitlab.com/pycqa/flake8 + rev: '3.8.3' + hooks: + - id: flake8 + types: [python] + additional_dependencies: + - flake8-bugbear + - flake8-builtins + # - flake8-docstrings # TODO: add back! + # - flake8-rst-docstrings + - flake8-comprehensions + - flake8-tidy-imports + - pycodestyle + - repo: https://github.com/pre-commit/mirrors-mypy + rev: v0.782 + hooks: + - id: mypy + - repo: https://github.com/ambv/black + rev: 20.8b1 + hooks: + - id: black + types: [python] + language_version: python3 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..192d164 --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +.PHONY: help clean dev docs package test + +help: + @echo "The following make targets are available:" + @echo " devenv create venv and install all deps for dev env (assumes python3 cmd exists)" + @echo " dev install all deps for dev env (assumes venv is present)" + @echo " docs create pydocs for all relveant modules (assumes venv is present)" + @echo " package package for pypi" + @echo " test run all tests with coverage (assumes venv is present)" + +devenv: + pip3 install -r requirements.txt + pre-commit install + +dev: + pip3 install -r requirements.txt + +docs: + rm -rf docs/api + rm -rf docs/build + sphinx-apidoc --no-toc -f -t=docs/_templates -o docs/api fuggle/ + sphinx-build -b html docs/ docs/build/ + +lint: + pre-commit run --all-files + +package: + rm -rf dist/* + python3 setup.py sdist + python3 setup.py bdist_wheel + +test: + python3 -bb -m pytest tests/ diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 0000000..2f7efbe --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-minimal \ No newline at end of file diff --git a/docs/_templates/package.rst_t b/docs/_templates/package.rst_t new file mode 100644 index 0000000..d179cac --- /dev/null +++ b/docs/_templates/package.rst_t @@ -0,0 +1,41 @@ +{%- macro automodule(modname, options) -%} +.. automodule:: {{ modname }} +{%- for option in options %} + :{{ option }}: +{%- endfor %} +{%- endmacro %} + +{%- macro toctree(docnames) -%} +.. toctree:: + :maxdepth: {{ maxdepth }} +{% for docname in docnames %} + {{ docname }} +{%- endfor %} +{%- endmacro %} + +{%- if is_namespace %} +{{- [pkgname, ""] | join(" ") | e | heading }} +{% else %} +{{- [pkgname, ""] | join(" ") | e | heading }} +{% endif %} + +{%- if modulefirst and not is_namespace %} +{{ automodule(pkgname, automodule_options) }} +{% endif %} + +{%- if subpackages %} +{{ toctree(subpackages) }} +{% endif %} + +{%- if submodules %} +{% if separatemodules %} + +{%- else %} +{%- for submodule in submodules %} +{% if show_headings %} +{{- submodule | e | heading(2) }} +{% endif %} +{{ automodule(submodule, automodule_options) }} +{% endfor %} +{%- endif %} +{% endif %} diff --git a/docs/_templates/toc.rst_t b/docs/_templates/toc.rst_t new file mode 100644 index 0000000..878540c --- /dev/null +++ b/docs/_templates/toc.rst_t @@ -0,0 +1,7 @@ +{{ header | heading }} + +.. toctree:: + :maxdepth: {{ maxdepth }} +{% for docname in docnames %} + {{ docname }} +{%- endfor %} diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000..26af754 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,65 @@ +# flake8: noqa +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +import os +import sys +sys.path.insert(0, os.path.abspath("../")) + +from fuggle import __version__ +import sphinx_rtd_theme + +# -- Project information ----------------------------------------------------- + +project = "Fuggle" +version = __version__ +copyright = "2020, Han Wang" # noqa: A001 +author = "Han Wang" + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = ["sphinx.ext.todo", "sphinx.ext.viewcode", + "sphinx.ext.autodoc", "sphinx_rtd_theme"] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = "python" + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [] + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = "sphinx_rtd_theme" + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +master_doc = "index" diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000..2ea2060 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,14 @@ +.. Fuggle documentation master file, created by + sphinx-quickstart on Sun May 17 21:49:44 2020. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to Fuggle's documentation! +================================= + +.. toctree:: + :maxdepth: 3 + :caption: API: + + api/fuggle + diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..6247f7e --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/fuggle/__init__.py b/fuggle/__init__.py new file mode 100644 index 0000000..8ed4906 --- /dev/null +++ b/fuggle/__init__.py @@ -0,0 +1,2 @@ +# flake8: noqa +from fuggle_version import __version__ diff --git a/fuggle_version/__init__.py b/fuggle_version/__init__.py new file mode 100644 index 0000000..f102a9c --- /dev/null +++ b/fuggle_version/__init__.py @@ -0,0 +1 @@ +__version__ = "0.0.1" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..1083c60 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,20 @@ +. + +# test requirements +pre-commit +mypy +flake8 +autopep8 +black +pylint +pytest +pytest-cov +pytest-mock +sphinx +sphinx-rtd-theme + +cloudpickle + +# publish to pypi +wheel +twine diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..e9daa0a --- /dev/null +++ b/setup.cfg @@ -0,0 +1,15 @@ +[metadata] +description-file = README.md + +[tool:pytest] +addopts = + --cov=fuggle + --cov-report=term-missing:skip-covered + -vvv + +[flake8] +ignore = E24,E203,W503 +max-line-length = 88 +format = pylint +exclude = .svc,CVS,.bzr,.hg,.git,__pycache__,venv,tests/*,docs/* +max-complexity = 10 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..80eeec6 --- /dev/null +++ b/setup.py @@ -0,0 +1,34 @@ +from setuptools import setup, find_packages +from fuggle_version import __version__ + + +with open("README.md") as f: + LONG_DESCRIPTION = f.read() + +setup( + name="fuggle", + version=__version__, + packages=find_packages(), + description="Fugue for Kaggle users", + long_description=LONG_DESCRIPTION, + long_description_content_type="text/markdown", + license="Apache-2.0", + author="Han Wang", + author_email="goodwanghan@gmail.com", + keywords="fugue kaggle", + url="http://github.com/fugue-project/fuggle", + install_requires=["fugue[spark]>=0.4.7"], + extras_require={}, + classifiers=[ + # "3 - Alpha", "4 - Beta" or "5 - Production/Stable" + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries :: Python Modules", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3 :: Only", + ], + python_requires=">=3.6", +) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_dummy.py b/tests/test_dummy.py new file mode 100644 index 0000000..10cf3ad --- /dev/null +++ b/tests/test_dummy.py @@ -0,0 +1,2 @@ +def test_dummy(): + pass