diff --git a/.bumpversion.cfg b/.bumpversion.cfg new file mode 100644 index 0000000..29c4a8c --- /dev/null +++ b/.bumpversion.cfg @@ -0,0 +1,28 @@ +[bumpversion] +current_version = 0.0.0 +commit = True +tag = True + +[bumpversion:file:setup.py] +search = version="{current_version}" +replace = version="{new_version}" + +[bumpversion:file (badge):README.rst] +search = /v{current_version}.svg +replace = /v{new_version}.svg + +[bumpversion:file (link):README.rst] +search = /v{current_version}...main +replace = /v{new_version}...main + +[bumpversion:file:docs/conf.py] +search = version = release = "{current_version}" +replace = version = release = "{new_version}" + +[bumpversion:file:src/mloq_template/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + +[bumpversion:file:.cookiecutterrc] +search = version: {current_version} +replace = version: {new_version} diff --git a/.cookiecutterrc b/.cookiecutterrc new file mode 100644 index 0000000..84e30ad --- /dev/null +++ b/.cookiecutterrc @@ -0,0 +1,66 @@ +# This file exists so you can easily regenerate your project. +# +# `cookiepatcher` is a convenient shim around `cookiecutter` +# for regenerating projects (it will generate a .cookiecutterrc +# automatically for any template). To use it: +# +# pip install cookiepatcher +# cookiepatcher gh:ionelmc/cookiecutter-pylibrary mloq-template +# +# See: +# https://pypi.org/project/cookiepatcher +# +# Alternatively, you can run: +# +# cookiecutter --overwrite-if-exists --config-file=mloq-template/.cookiecutterrc gh:ionelmc/cookiecutter-pylibrary + +default_context: + c_extension_support: "no" + codacy: "no" + codacy_projectid: "[Get ID from https://app.codacy.com/gh/guillemdb/mloq-template/settings]" + codeclimate: "no" + codecov: "yes" + command_line_interface: "plain" + command_line_interface_bin_name: "mloq-template" + coveralls: "no" + distribution_name: "mloq-template" + docstring_code_line_length: "80" + email: "guillem@fragile.tech" + formatter_quote_style: "double" + full_name: "Guillem Duran Ballester" + function_name: "compute" + github_actions: "yes" + github_actions_osx: "yes" + github_actions_windows: "yes" + license: "BSD 2-Clause License" + line_length: "99" + lock_file_support: false + module_name: "core" + package_name: "mloq_template" + pre_commit: "yes" + project_name: "MLOQ Template" + project_short_description: "An example package. Generated with cookiecutter-pylibrary." + project_slug: "mloq-template" + pypi_badge: "yes" + pypi_disable_upload: "no" + release_date: "today" + repo_hosting: "github.com" + repo_hosting_domain: "github.com" + repo_main_branch: "main" + repo_name: "mloq-template" + repo_url: "https://github.com/guillemdb/mloq-template" + repo_username: "guillemdb" + scrutinizer: "no" + setup_py_uses_setuptools_scm: "no" + sphinx_docs: "yes" + sphinx_docs_hosting: "https://mloq-template.readthedocs.io/" + sphinx_doctest: "no" + sphinx_theme: "furo" + target_python_version: "3.10" + test_matrix_separate_coverage: "no" + tests_inside_package: "no" + version: "0.0.0" + version_manager: "bump2version" + website: "fragile.tech" + year_from: "2024" + year_to: "2024" diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..3956574 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,16 @@ +[paths] +source = + src + */site-packages + +[run] +branch = true +source = + mloq_template + tests +parallel = true + +[report] +show_missing = true +precision = 2 +omit = *migrations* diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..586c736 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# see https://editorconfig.org/ +root = true + +[*] +# Use Unix-style newlines for most files (except Windows files, see below). +end_of_line = lf +trim_trailing_whitespace = true +indent_style = space +insert_final_newline = true +indent_size = 4 +charset = utf-8 + +[*.{bat,cmd,ps1}] +end_of_line = crlf + +[*.{yml,yaml}] +indent_size = 2 + +[*.tsv] +indent_style = tab diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..29c9ecf --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,21 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly + - package-ecosystem: pip + directory: "/.github/workflows" + schedule: + interval: weekly + - package-ecosystem: pip + directory: "/docs" + schedule: + interval: weekly + - package-ecosystem: pip + directory: "/" + schedule: + interval: weekly + versioning-strategy: lockfile-only + allow: + - dependency-type: "all" diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 0000000..3a300b6 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,66 @@ +--- +# Labels names are important as they are used by Release Drafter to decide +# regarding where to record them in changelog or if to skip them. +# +# The repository labels will be automatically configured using this file and +# the GitHub Action https://github.com/marketplace/actions/github-labeler. +- name: breaking + description: Breaking Changes + color: bfd4f2 +- name: bug + description: Something isn't working + color: d73a4a +- name: build + description: Build System and Dependencies + color: bfdadc +- name: ci + description: Continuous Integration + color: 4a97d6 +- name: dependencies + description: Pull requests that update a dependency file + color: 0366d6 +- name: documentation + description: Improvements or additions to documentation + color: 0075ca +- name: duplicate + description: This issue or pull request already exists + color: cfd3d7 +- name: enhancement + description: New feature or request + color: a2eeef +- name: github_actions + description: Pull requests that update Github_actions code + color: "000000" +- name: good first issue + description: Good for newcomers + color: 7057ff +- name: help wanted + description: Extra attention is needed + color: 008672 +- name: invalid + description: This doesn't seem right + color: e4e669 +- name: performance + description: Performance + color: "016175" +- name: python + description: Pull requests that update Python code + color: 2b67c6 +- name: question + description: Further information is requested + color: d876e3 +- name: refactoring + description: Refactoring + color: ef67c4 +- name: removal + description: Removals and Deprecations + color: 9ae7ea +- name: style + description: Style + color: c120e5 +- name: testing + description: Testing + color: b1fc6f +- name: wontfix + description: This will not be worked on + color: ffffff diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000..bf4fae5 --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,42 @@ +name-template: '$RESOLVED_VERSION' +tag-template: 'v$RESOLVED_VERSION' + +categories: + - title: '🚀 Features' + labels: + - 'feat' + - 'enhancement' + - title: '🐛 Bug Fixes' + labels: + - 'fix' + - 'bug' + - title: 'Other updates' + labels: + - 'refactor' + - 'chore' + - 'docs' + - 'perf' + - 'test' + - 'documentation' + +change-template: '- $TITLE @$AUTHOR (#$NUMBER)' +change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. + +version-resolver: + major: + labels: + - 'major' + minor: + labels: + - 'minor' + patch: + labels: + - 'patch' + default: patch + +template: | + ## Changes + + $CHANGES + + Special thanks to: $CONTRIBUTORS diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..be57209 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,75 @@ +name: Build + +on: [push, pull_request] + +jobs: + test: + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + python_version: ['3.10'] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python_version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install hatch pre-commit + hatch env create + - name: Lint and typecheck + run: | + hatch run lint:all + - name: Run Tests + run: | + hatch run test:pytest + - uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + fail_ci_if_error: true + verbose: true + + release: + runs-on: ubuntu-latest + environment: release + needs: test + if: startsWith(github.ref, 'refs/tags/') + permissions: + contents: write + id-token: write + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python_version }} + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Install dependencies + shell: bash + run: | + python -m pip install --upgrade pip + pip install hatch pre-commit + - name: Build + run: | + hatch build + - name: Publish 📦 to Test PyPI + if: startsWith(github.ref, 'refs/heads/main') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + skip_existing: true + user: __token__ + password: ${{ secrets.TEST_PYPI_SECRECT }} + packages-dir: dist/ + repository-url: https://test.pypi.org/legacy/ + - name: Publish 📦 to PyPI + if: startsWith(github.ref, 'refs/heads/main') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_SECRECT }} + packages-dir: dist/ diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 0000000..2a8a2f1 --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,56 @@ +name: Build documentation + +on: + push: + branches: + - main + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow one concurrent deployment +concurrency: + group: "pages" + cancel-in-progress: true + +# Default to bash +defaults: + run: + shell: bash + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install hatch pre-commit + hatch env create docs + - name: Build + run: hatch run docs:build-check + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: ./site + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/draft.yml b/.github/workflows/draft.yml new file mode 100644 index 0000000..a3df871 --- /dev/null +++ b/.github/workflows/draft.yml @@ -0,0 +1,19 @@ +name: Release Drafter + +on: + push: + branches: + - main + +jobs: + update-draft: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + # Drafts your next Release notes as Pull Requests are merged into "main" + - uses: release-drafter/release-drafter@v6 + with: + disable-autolabeler: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 0000000..bd8ae32 --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,24 @@ +name: Labeler + +on: + push: + branches: + - main + +permissions: + actions: read + contents: read + security-events: write + pull-requests: write + +jobs: + labeler: + runs-on: ubuntu-latest + steps: + - name: Check out the repository + uses: actions/checkout@v4 + + - name: Run Labeler + uses: crazy-max/ghaction-github-labeler@v5.0.0 + with: + skip-delete: true diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml deleted file mode 100644 index b0d977c..0000000 --- a/.github/workflows/push.yml +++ /dev/null @@ -1,225 +0,0 @@ -name: Push - -on: - push: - branches: - - master - pull_request: - branches: - - master - -env: - PROJECT_NAME: project_name - VERSION_FILE: project_name/version.py - DEFAULT_BRANCH: master - BOT_NAME: BOT_NAME - BOT_EMAIL: BOT_EMAIL - BOT_AUTH_TOKEN: ${{ secrets.BOT_AUTH_TOKEN }} - TEST_PYPI_PASS: ${{ secrets.TEST_PYPI_PASS }} - PYPI_PASS: ${{ secrets.PYPI_PASS }} - DOCKER_ORG: gh_owner - DOCKER_USERNAME: ${{ secrets.DOCKERHUB_LOGIN }} - DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PASS }} - -jobs: - Style-check: - if: "!contains(github.event.head_commit.message, 'Bump version')" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: "3.8" - - name: Install lint dependencies - run: | - python -m pip install --upgrade pip - if [ -f requirements-lint.txt ]; then pip install -r requirements-lint.txt; fi - - name: Run style check and linter - run: | - make check - - Pytest: - needs: Style-check - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.6', '3.7', '3.8', '3.9'] - steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install test and package dependencies - run: | - python -m pip install --upgrade pip - if [ -f requirements-test.txt ]; then pip install -r requirements-test.txt; fi - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - pip install . - - name: Test with pytest - run: | - pytest --cov=./ --cov-report=xml - - name: Upload coverage report - if: ${{ matrix.python-version=='3.8' }} - uses: codecov/codecov-action@v1 - - Test-docker: - needs: Style-check - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Build container - run: | - make docker-build - - name: Run tests - run: | - make docker-test - - Build-pypi: - needs: Style-check - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2 - - run: | - git fetch --prune --unshallow - - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - - name: Install dependencies - run: | - python -m pip install -U pip - python -m pip install -U setuptools twine wheel bumpversion - - - name: Create unique version for test.pypi - run: | - set -e - git pull --no-edit origin $DEFAULT_BRANCH - current_version=$(grep __version__ $VERSION_FILE | cut -d\" -f2) - ts=$(date +%s) - new_version="$current_version$ts" - bumpversion --current-version $current_version --new-version $new_version patch $VERSION_FILE - - - name: Build package - run: | - python setup.py --version - python setup.py bdist_wheel sdist --format=gztar - twine check dist/* - - - name: Publish package to TestPyPI - if: "'$TEST_PYPI_PASS' != ''" - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.TEST_PYPI_PASS }} - repository_url: https://test.pypi.org/legacy/ - skip_existing: true - - Test-pypi: - if: "'$TEST_PYPI_PASS' != ''" - needs: Build-pypi - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - - name: Install dependencies - run: | - python -m pip install -U pip - python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple $PROJECT_NAME - python -m pip install -r requirements-test.txt - - - name: Test package - run: | - mv $PROJECT_NAME/tests ./tests - rm -rf $PROJECT_NAME - pytest - - Bump-version: - if: "!contains(github.event.head_commit.message, 'Bump version') && github.ref == 'refs/heads/master' && '$BOT_AUTH_TOKEN' != ''" - needs: - - Test-pypi - - Pytest - - Test-docker - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 100 - persist-credentials: false - - - name: Setup Python - uses: actions/setup-python@v2 - with: - python-version: '3.8' - - - name: Install dependencies - run: | - git config --global user.name "${BOT_NAME}" - git config --global user.email "${BOT_EMAIL}" - git config --global pull.rebase false - pip install bump2version - - - name: Run bump version - run: | - set -x - git pull --no-edit origin $DEFAULT_BRANCH - current_version=$(grep __version__ $VERSION_FILE | cut -d\" -f2) - bumpversion --tag --current-version $current_version --commit patch $VERSION_FILE - git remote add ${BOT_NAME}-remote https://${BOT_NAME}:${BOT_AUTH_TOKEN}@github.com/$GITHUB_REPOSITORY - git push --tags ${BOT_NAME}-remote HEAD:$DEFAULT_BRANCH - set +e - - Push-Docker-container: - runs-on: ubuntu-latest - if: "contains(github.event.head_commit.message, 'Bump version') && github.ref == 'refs/heads/master' && '$DOCKER_PASSWORD' != ''" - steps: - - uses: actions/checkout@v2 - - name: Login to DockerHub - run: | - docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" docker.io - - - name: Build container - run: | - CONTAINER_VERSION=v$(grep __version__ $VERSION_FILE | cut -d\" -f2) - make docker-build VERSION=$CONTAINER_VERSION PROJECT=$PROJECT_NAME DOCKER_ORG=$DOCKER_ORG - - name: Push images - - run: | - CONTAINER_VERSION=v$(grep __version__ $VERSION_FILE | cut -d\" -f2) - make -f scripts/makefile.docker docker-push VERSION=$CONTAINER_VERSION PROJECT=$PROJECT_NAME DOCKER_ORG=$DOCKER_ORG - - Release-package: - if: "contains(github.event.head_commit.message, 'Bump version') && github.ref == 'refs/heads/master' && '$PYPI_PASS' != ''" - runs-on: ubuntu-18.04 - steps: - - uses: actions/checkout@v2 - - run: | - git fetch --prune --unshallow - - name: Set up Python 3.8 - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - - name: Install dependencies - run: | - python -m pip install -U pip - python -m pip install -U setuptools twine wheel - - - name: Build package - run: | - python setup.py --version - python setup.py bdist_wheel sdist --format=gztar - twine check dist/* - - - name: Publish package to PyPI - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.PYPI_PASS }} \ No newline at end of file diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..2493e0e --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,41 @@ +name: Tests + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +defaults: + run: + shell: bash + +jobs: + tests: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + python-version: ["3.9", "3.10", "3.11", "3.12"] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python_version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python_version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install hatch pre-commit + hatch env create + - name: Lint and typecheck + run: | + hatch run lint:all + - name: Run Tests + run: | + hatch run test:pytest diff --git a/.gitignore b/.gitignore index 6081300..77973dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,129 +1,74 @@ - -#Mac OS -*.DS_Store - -#PyCharm IDE -.idea/ - -# Documentation build templates -doc/_build/ -doc/ast2vec.rst -doc/modules.rst - -# Byte-compiled / optimized / DLL templates -__pycache__/ *.py[cod] -*$py.class +__pycache__ + +# Temp files +.*.sw[po] +*~ +*.bak +.DS_Store # C extensions *.so -# Distribution / packaging -.Python -env/ -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata -*.egg-info/ -.installed.cfg +# Build and package files *.egg - -# PyInstaller -# Usually these templates 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 +*.egg-info +.bootstrap +.build +.cache +.eggs +.env +.installed.cfg +.ve +bin +build +develop-eggs +dist +eggs +lib +lib64 +parts +pip-wheel-metadata/ +pyvenv*/ +sdist +var +venv*/ +wheelhouse # Installer logs pip-log.txt -pip-delete-this-directory.txt # Unit test / coverage reports -htmlcov/ -.tox/ +.benchmarks .coverage .coverage.* -.cache -nosetests.xml +.pytest +.pytest_cache/ +.tox coverage.xml -*.cover -.hypothesis/ +htmlcov +nosetests.xml # Translations *.mo -*.pot - -# Django stuff: -*.log -local_settings.py - -# Flask stuff: -instance/ -.webassets-cache -# Scrapy stuff: -.scrapy +# Buildout +.mr.developer.cfg -# Sphinx documentation -docsrc/_build/ +# IDE project files +*.iml +*.komodoproject +.idea +.project +.pydevproject +.vscode -# PyBuilder -target/ +# Complexity +output/*.html +output/*/index.html -# Jupyter Notebook -.ipynb_checkpoints +# Sphinx +docs/_build -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule - -# SageMath parsed templates -*.sage.py - -# dotenv -.env - -# virtualenv -.venv -venv/ -ENV/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy +# Mypy Cache .mypy_cache/ - -# CI -.ci - -# Notebooks by default are ignored -*.ipynb - -data/ - -docs/ -examples/ -*.pck -*.npy - -Pipfile.lock diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..0da324c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,19 @@ +# To install the git pre-commit hooks run: +# pre-commit install --install-hooks +# To update the versions: +# pre-commit autoupdate +exclude: '^(\.tox|ci/templates|\.bumpversion\.cfg)(/|$)' +# Note the order is intentional to avoid multiple passes of the hooks +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: main + hooks: + - id: ruff + args: [--fix, --exit-non-zero-on-fix, --show-fixes] + - id: ruff-format + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: main + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: debug-statements diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 0000000..009a913 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,14 @@ +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details +version: 2 +sphinx: + configuration: docs/conf.py +formats: all +build: + os: ubuntu-22.04 + tools: + python: "3" +python: + install: + - requirements: docs/requirements.txt + - method: pip + path: . diff --git a/AUTHORS.rst b/AUTHORS.rst new file mode 100644 index 0000000..ae7b5f6 --- /dev/null +++ b/AUTHORS.rst @@ -0,0 +1,5 @@ + +Authors +======= + +* Guillem Duran Ballester - fragile.tech diff --git a/CHANGELOG.rst b/CHANGELOG.rst new file mode 100644 index 0000000..f338324 --- /dev/null +++ b/CHANGELOG.rst @@ -0,0 +1,8 @@ + +Changelog +========= + +0.0.0 (2024-09-28) +------------------ + +* First release on PyPI. diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst new file mode 100644 index 0000000..2627d07 --- /dev/null +++ b/CONTRIBUTING.rst @@ -0,0 +1,85 @@ +============ +Contributing +============ + +Contributions are welcome, and they are greatly appreciated! Every +little bit helps, and credit will always be given. + +Bug reports +=========== + +When `reporting a bug `_ please include: + + * Your operating system name and version. + * Any details about your local setup that might be helpful in troubleshooting. + * Detailed steps to reproduce the bug. + +Documentation improvements +========================== + +MLOQ Template could always use more documentation, whether as part of the +official MLOQ Template docs, in docstrings, or even on the web in blog posts, +articles, and such. + +Feature requests and feedback +============================= + +The best way to send feedback is to file an issue at https://github.com/guillemdb/mloq-template/issues. + +If you are proposing a feature: + +* Explain in detail how it would work. +* Keep the scope as narrow as possible, to make it easier to implement. +* Remember that this is a volunteer-driven project, and that code contributions are welcome :) + +Development +=========== + +To set up `mloq-template` for local development: + +1. Fork `mloq-template `_ + (look for the "Fork" button). +2. Clone your fork locally:: + + git clone git@github.com:YOURGITHUBNAME/mloq-template.git + +3. Create a branch for local development:: + + git checkout -b name-of-your-bugfix-or-feature + + Now you can make your changes locally. + +4. When you're done making changes run all the checks and docs builder with one command:: + + tox + +5. Commit your changes and push your branch to GitHub:: + + git add . + git commit -m "Your detailed description of your changes." + git push origin name-of-your-bugfix-or-feature + +6. Submit a pull request through the GitHub website. + +Pull Request Guidelines +----------------------- + +If you need some code review or feedback while you're developing the code just make the pull request. + +For merging, you should: + +1. Include passing tests (run ``hatch``). +2. Update documentation when there's new API, functionality etc. +3. Add a note to ``CHANGELOG.rst`` about the changes. +4. Add yourself to ``AUTHORS.rst``. + +Tips +---- + +To run a subset of tests:: + + tox -e envname -- pytest -k test_myfeature + +To run all the test environments in *parallel*:: + + tox -p auto diff --git a/DCO.md b/DCO.md deleted file mode 100644 index e440da9..0000000 --- a/DCO.md +++ /dev/null @@ -1,36 +0,0 @@ -Developer Certificate of Origin -Version 1.1 - -Copyright (C) 2004, 2006 The Linux Foundation and its contributors. -660 York Street, Suite 102, -San Francisco, CA 94110 USA - -Everyone is permitted to copy and distribute verbatim copies of this -license document, but changing it is not allowed. - - -Developer's Certificate of Origin 1.1 - -By making a contribution to this project, I certify that: - -(a) The contribution was created in whole or in part by me and I - have the right to submit it under the open source license - indicated in the file; or - -(b) The contribution is based upon previous work that, to the best - of my knowledge, is covered under an appropriate open source - license and I have the right under that license to submit that - work with modifications, whether created in whole or in part - by me, under the same open source license (unless I am - permitted to submit under a different license), as indicated - in the file; or - -(c) The contribution was provided directly to me by some other - person who certified (a), (b) or (c) and I have not modified - it. - -(d) I understand and agree that this project and the contribution - are public and that a record of the contribution (including all - personal information I submit with it, including my sign-off) is - maintained indefinitely and may be redistributed consistent with -this project or the open source license(s) involved. diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index faf9c9f..0000000 --- a/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM fragiletech/ubuntu20.04-base-py39 -ARG JUPYTER_PASSWORD="" -ENV BROWSER=/browser \ - LC_ALL=en_US.UTF-8 \ - LANG=en_US.UTF-8 - -COPY . project_name/ - -RUN cd project_name \ - && python3 -m pip install -U pip \ - && pip3 install -r requirements-lint.txt \ - && pip3 install -r requirements-test.txt \ - && pip3 install -r requirements.txt \ - && pip install ipython jupyter \ - && pip3 install -e . --no-use-pep517 -RUN make -f project_name/scripts/makefile.docker remove-dev-packages -RUN mkdir /root/.jupyter && \ - echo 'c.NotebookApp.token = "'${JUPYTER_PASSWORD}'"' > /root/.jupyter/jupyter_notebook_config.py -CMD pipenv run jupyter notebook --allow-root --port 8080 --ip 0.0.0.0 \ No newline at end of file diff --git a/LICENSE b/LICENSE index ab64d25..cf98779 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,10 @@ -MIT License +BSD 2-Clause License -Copyright (c) 2020 COPYRIGHT_HOLDER +Copyright (c) 2024, Guillem Duran Ballester. All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..d0dac9c --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,22 @@ +graft docs +graft src +graft ci +graft tests + +include .bumpversion.cfg +include .cookiecutterrc +include .coveragerc +include .editorconfig +include .github/workflows/github-actions.yml +include .pre-commit-config.yaml +include .readthedocs.yml +include pytest.ini +include tox.ini + +include AUTHORS.rst +include CHANGELOG.rst +include CONTRIBUTING.rst +include LICENSE +include README.rst + +global-exclude *.py[cod] __pycache__/* *.so *.dylib diff --git a/MLproject b/MLproject deleted file mode 100644 index 1d9a636..0000000 --- a/MLproject +++ /dev/null @@ -1,9 +0,0 @@ -name: project_name - -docker_env: - image: project_name - volumes: [":/project_name"] - -entry_points: - main: - command: "python -m project_name" \ No newline at end of file diff --git a/Makefile b/Makefile deleted file mode 100644 index 526b840..0000000 --- a/Makefile +++ /dev/null @@ -1,64 +0,0 @@ -current_dir = $(shell pwd) - -PROJECT = project_name -DOCKER_ORG = gh_owner -VERSION ?= latest - -.POSIX: -style: - black . - isort . - -.POSIX: -check: - !(grep -R /tmp ${PROJECT}/tests) - flakehell lint ${PROJECT} - pylint ${PROJECT} - black --check ${PROJECT} - -.PHONY: test -test: - find -name "*.pyc" -delete - pytest -s - -.PHONY: pipenv-install -pipenv-install: - rm -rf *.egg-info && rm -rf build && rm -rf __pycache__ - rm -f Pipfile && rm -f Pipfile.lock - pipenv install --dev -r requirements-test.txt - pipenv install --pre --dev -r requirements-lint.txt - pipenv install -r requirements.txt - pipenv install . - pipenv lock - -.PHONY: pipenv-test -pipenv-test: - find -name "*.pyc" -delete - pipenv run pytest -s - -.PHONY: docker-test -docker-test: - find -name "*.pyc" -delete - docker run --rm -it -v $(pwd):/io --network host -w /${PROJECT} --entrypoint python3 ${DOCKER_ORG}/${PROJECT}:${VERSION} -m pytest - - -.PHONY: docker-build -docker-build: - docker build --pull -t ${DOCKER_ORG}/${PROJECT}:${VERSION} . - - -.PHONY: remove-dev-packages -remove-dev-packages: - pip3 uninstall -y cython && \ - apt-get remove -y cmake pkg-config flex bison curl libpng-dev \ - libjpeg-turbo8-dev zlib1g-dev libhdf5-dev libopenblas-dev gfortran \ - libfreetype6-dev libjpeg8-dev libffi-dev && \ - apt-get autoremove -y && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -.PHONY: docker-push -docker-push: - docker push ${DOCKER_ORG}/${DOCKER_TAG}:${VERSION} - docker tag ${DOCKER_ORG}/${DOCKER_TAG}:${VERSION} ${DOCKER_ORG}/${DOCKER_TAG}:latest - docker push ${DOCKER_ORG}/${DOCKER_TAG}:latest \ No newline at end of file diff --git a/README.md b/README.md index aa057c2..fb2ab30 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,97 @@ -# project_name -[![Documentation Status](https://readthedocs.org/projects/fragile/badge/?version=latest)](https://project_name.readthedocs.io/en/latest/?badge=latest) -[![Code coverage](https://codecov.io/github/gh_owner/project_name/coverage.svg)](https://codecov.io/github/gh_owner/project_name) -[![PyPI package](https://badgen.net/pypi/v/project_name)](https://pypi.org/project/project_name/) -[![Latest docker image](https://badgen.net/docker/pulls/gh_owner/project_name)](https://hub.docker.com/r/gh_owner/project_name/tags) -[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) -[![license: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT) - -Template project generated with mloq. \ No newline at end of file +======== +Overview +======== + +.. start-badges + +.. list-table:: + :stub-columns: 1 + + * - docs + - |docs| + * - tests + - |github-actions| |codecov| + * - package + - |version| |wheel| |supported-versions| |supported-implementations| |commits-since| +.. |docs| image:: https://readthedocs.org/projects/mloq-template/badge/?style=flat + :target: https://readthedocs.org/projects/mloq-template/ + :alt: Documentation Status + +.. |github-actions| image:: https://github.com/guillemdb/mloq-template/actions/workflows/github-actions.yml/badge.svg + :alt: GitHub Actions Build Status + :target: https://github.com/guillemdb/mloq-template/actions + +.. |codecov| image:: https://codecov.io/gh/guillemdb/mloq-template/branch/main/graphs/badge.svg?branch=main + :alt: Coverage Status + :target: https://app.codecov.io/github/guillemdb/mloq-template + +.. |version| image:: https://img.shields.io/pypi/v/mloq-template.svg + :alt: PyPI Package latest release + :target: https://pypi.org/project/mloq-template + +.. |wheel| image:: https://img.shields.io/pypi/wheel/mloq-template.svg + :alt: PyPI Wheel + :target: https://pypi.org/project/mloq-template + +.. |supported-versions| image:: https://img.shields.io/pypi/pyversions/mloq-template.svg + :alt: Supported versions + :target: https://pypi.org/project/mloq-template + +.. |supported-implementations| image:: https://img.shields.io/pypi/implementation/mloq-template.svg + :alt: Supported implementations + :target: https://pypi.org/project/mloq-template + +.. |commits-since| image:: https://img.shields.io/github/commits-since/guillemdb/mloq-template/v0.0.0.svg + :alt: Commits since latest release + :target: https://github.com/guillemdb/mloq-template/compare/v0.0.0...main + + + +.. end-badges + +An example package. Generated with cookiecutter-pylibrary. + +* Free software: BSD 2-Clause License + +Installation +============ + +:: + + pip install mloq-template + +You can also install the in-development version with:: + + pip install https://github.com/guillemdb/mloq-template/archive/main.zip + + +Documentation +============= + + +https://mloq-template.readthedocs.io/ + + +Development +=========== + +To run all the tests run:: + + tox + +Note, to combine the coverage data from all the tox environments run: + +.. list-table:: + :widths: 10 90 + :stub-columns: 1 + + - - Windows + - :: + + set PYTEST_ADDOPTS=--cov-append + tox + + - - Other + - :: + + PYTEST_ADDOPTS=--cov-append tox diff --git a/__pytest.ini b/__pytest.ini new file mode 100644 index 0000000..617ccd8 --- /dev/null +++ b/__pytest.ini @@ -0,0 +1,30 @@ +[pytest] +# If a pytest section is found in one of the possible config files +# (pytest.ini, tox.ini or setup.cfg), then pytest will not look for any others, +# so if you add a pytest config section elsewhere, +# you will need to delete this section from setup.cfg. +norecursedirs = + migrations + +python_files = + test_*.py + *_test.py + tests.py +addopts = + -ra + --strict-markers + --doctest-modules + --doctest-glob=\*.rst + --tb=short +testpaths = + tests +# If you want to switch back to tests outside package just remove --pyargs +# and edit testpaths to have "tests/" instead of "mloq_template". + +# Idea from: https://til.simonwillison.net/pytest/treat-warnings-as-errors +filterwarnings = + error +# You can add exclusions, some examples: +# ignore:'mloq_template' defines default_app_config:PendingDeprecationWarning:: +# ignore:The {{% if::: +# ignore:Coverage disabled via --no-cov switch! diff --git a/code_of_conduct.md b/code_of_conduct.md deleted file mode 100644 index c5fa251..0000000 --- a/code_of_conduct.md +++ /dev/null @@ -1,132 +0,0 @@ - -# Contributor Covenant Code of Conduct - -## Our Pledge - -We as members, contributors, and leaders pledge to make participation in our -community a harassment-free experience for everyone, regardless of age, body -size, visible or invisible disability, ethnicity, sex characteristics, gender -identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, religion, or sexual identity -and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, -diverse, inclusive, and healthy community. - -## Our Standards - -Examples of behavior that contributes to a positive environment for our -community include: - -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, - and learning from the experience -* Focusing on what is best not just for us as individuals, but for the - overall community - -Examples of unacceptable behavior include: - -* The use of sexualized language or imagery, and sexual attention or - advances of any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email - address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a - professional setting - -## Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of -acceptable behavior and will take appropriate and fair corrective action in -response to any behavior that they deem inappropriate, threatening, offensive, -or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions that are -not aligned to this Code of Conduct, and will communicate reasons for moderation -decisions when appropriate. - -## Scope - -This Code of Conduct applies within all community spaces, and also applies when -an individual is officially representing the community in public spaces. -Examples of representing our community include using an official e-mail address, -posting via an official social media account, or acting as an appointed -representative at an online or offline event. - -## Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported to the community leaders responsible for enforcement at OWNER_EMAIL. -All complaints will be reviewed and investigated promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the -reporter of any incident. - -## Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining -the consequences for any action they deem in violation of this Code of Conduct: - -### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed -unprofessional or unwelcome in the community. - -**Consequence**: A private, written warning from community leaders, providing -clarity around the nature of the violation and an explanation of why the -behavior was inappropriate. A public apology may be requested. - -### 2. Warning - -**Community Impact**: A violation through a single incident or series -of actions. - -**Consequence**: A warning with consequences for continued behavior. No -interaction with the people involved, including unsolicited interaction with -those enforcing the Code of Conduct, for a specified period of time. This -includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or -permanent ban. - -### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including -sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public -communication with the community for a specified period of time. No public or -private interaction with the people involved, including unsolicited interaction -with those enforcing the Code of Conduct, is allowed during this period. -Violating these terms may lead to a permanent ban. - -### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an -individual, or aggression toward or disparagement of classes of individuals. - -**Consequence**: A permanent ban from any sort of public interaction within -the community. - -## Attribution - -This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.0, available at -[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0]. - -Community Impact Guidelines were inspired by -[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. - -For answers to common questions about this code of conduct, see the FAQ at -[https://www.contributor-covenant.org/faq][FAQ]. Translations are available -at [https://www.contributor-covenant.org/translations][translations]. - -[homepage]: https://www.contributor-covenant.org -[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html -[Mozilla CoC]: https://github.com/mozilla/diversity -[FAQ]: https://www.contributor-covenant.org/faq -[translations]: https://www.contributor-covenant.org/translations diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 0000000..2ecf1ad --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1,112 @@ +####################################################################################### +# A default configuration that will be loaded for all jupyter books +# Users are expected to override these values in their own `_config.yml` file. +# This is also the "master list" of all allowed keys and values. + +####################################################################################### +# Book settings +title : "MLOQ Template" # The title of the book. Will be placed in the left navbar. +author : "Guillem Duran Ballester" # The author of the book +copyright : "2024" # Copyright year to be placed in the footer +logo : "logo.png" # A path to the book logo +# Patterns to skip when building the book. Can be glob-style (e.g. "*skip.ipynb") +exclude_patterns : [_build, Thumbs.db, .DS_Store, "**.ipynb_checkpoints"] +# Auto-exclude files not in the toc +only_build_toc_files : false + +####################################################################################### +# Execution settings +execute: + execute_notebooks : auto # Whether to execute notebooks at build time. Must be one of ("auto", "force", "cache", "off") + cache : "" # A path to the jupyter cache that will be used to store execution artifacts. Defaults to `_build/.jupyter_cache/` + exclude_patterns : [] # A list of patterns to *skip* in execution (e.g. a notebook that takes a really long time) + timeout : 30 # The maximum time (in seconds) each notebook cell is allowed to run. + run_in_temp : false # If `True`, then a temporary directory will be created and used as the command working directory (cwd), + # otherwise the notebook's parent directory will be the cwd. + allow_errors : false # If `False`, when a code cell raises an error the execution is stopped, otherwise all cells are always run. + stderr_output : show # One of 'show', 'remove', 'remove-warn', 'warn', 'error', 'severe' + +####################################################################################### +# Parse and render settings +parse: + myst_enable_extensions: # default extensions to enable in the myst parser. See https://myst-parser.readthedocs.io/en/latest/using/syntax-optional.html + - amsmath + - colon_fence + - deflist + - dollarmath + - html_admonition + - html_image + - linkify + - replacements + - smartquotes + - substitution + - tasklist + myst_url_schemes: [mailto, http, https] # URI schemes that will be recognised as external URLs in Markdown links + myst_dmath_double_inline: true # Allow display math ($$) within an inline context + +####################################################################################### +# HTML-specific settings +html: + favicon : "favicon.png" # A path to a favicon image + use_edit_page_button : false # Whether to add an "edit this page" button to pages. If `true`, repository information in repository: must be filled in + use_repository_button : false # Whether to add a link to your repository button + use_issues_button : false # Whether to add an "open an issue" button + use_multitoc_numbering : true # Continuous numbering across parts/chapters + extra_footer : "" # Will be displayed underneath the footer. + google_analytics_id : "" # A GA id that can be used to track book views. + home_page_in_navbar : true # Whether to include your home page in the left Navigation Bar + baseurl : "" # The base URL where your book will be hosted. Used for creating image previews and social links. e.g.: https://mypage.com/mybook/ + analytics: + plausible_analytics_url: https://plausible.io/js/script.js + + comments: + hypothesis : false + utterances : false + announcement : "" # A banner announcement at the top of the site. + +####################################################################################### +# LaTeX-specific settings +latex: + latex_engine : pdflatex # one of 'pdflatex', 'xelatex' (recommended for unicode), 'luatex', 'platex', 'uplatex' + use_jupyterbook_latex : true # use sphinx-jupyterbook-latex for pdf builds as default + +####################################################################################### +# Launch button settings +launch_buttons: + notebook_interface : classic # The interface interactive links will activate ["classic", "jupyterlab"] + binderhub_url : "" # The URL of the BinderHub (e.g., https://mybinder.org) + jupyterhub_url : "" # The URL of the JupyterHub (e.g., https://datahub.berkeley.edu) + thebe : false # Add a thebe button to pages (requires the repository to run on Binder) + colab_url : "" # The URL of Google Colab (https://colab.research.google.com) + +repository: + url : "https://github.com/guillemdb/mloq-template" # The URL to your book's repository + path_to_book : "" # A path to your book's folder, relative to the repository root. + branch : "main" # Which branch of the repository should be used when creating links + +####################################################################################### +####################################################################################### +# Advanced and power-user settings +sphinx: + extra_extensions : # A list of extra extensions to load by Sphinx (added to those already used by JB). + - sphinx.ext.autodoc + - sphinx.ext.doctest + - sphinx.ext.intersphinx + - sphinx.ext.todo + - sphinx.ext.coverage + - sphinx.ext.imgmath + - sphinx.ext.viewcode + - sphinx.ext.napoleon + - sphinx.ext.autosectionlabel + - sphinx.ext.autodoc.typehints + - sphinx.ext.githubpages + - sphinxcontrib.mermaid + - autoapi.extension + local_extensions : # A list of local extensions to load by sphinx specified by "name: path" items + recursive_update : false # A boolean indicating whether to overwrite the Sphinx config (true) or recursively update (false) + config : # key-value pairs to directly over-ride the Sphinx configuration + autoapi_dirs : [ "../src" ] + napoleon_google_docstring : true + napoleon_numpy_docstring : false + autodoc_typehints : "description" + autoapi_add_toctree_entry : true diff --git a/docs/_toc.yml b/docs/_toc.yml new file mode 100644 index 0000000..74d5c71 --- /dev/null +++ b/docs/_toc.yml @@ -0,0 +1,9 @@ +# Table of contents +# Learn more at https://jupyterbook.org/customize/toc.html + +format: jb-book +root: intro +chapters: +- file: markdown +- file: notebooks +- file: markdown-notebooks diff --git a/docs/favicon.png b/docs/favicon.png new file mode 100644 index 0000000..adb0b33 Binary files /dev/null and b/docs/favicon.png differ diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..3db50dd --- /dev/null +++ b/docs/index.md @@ -0,0 +1,15 @@ +# Welcome to MLOQ Template Jupyter Book + +This is the main documentation page for **MLOQ Template**. + +For the API reference, check out the [API documentation](api/index.md). + +This is a small sample book to give you a feel for how book content is +structured. +It shows off a few of the major file types, as well as some sample content. +It does not go in-depth into any particular topic - check out [the Jupyter Book documentation](https://jupyterbook.org) for more information. + +Check out the content pages bundled with this sample book to see more. + +```{tableofcontents} +``` diff --git a/docs/logo.png b/docs/logo.png new file mode 100644 index 0000000..3e057d5 Binary files /dev/null and b/docs/logo.png differ diff --git a/docs/logo.svg b/docs/logo.svg new file mode 100644 index 0000000..1b4d08c --- /dev/null +++ b/docs/logo.svg @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + diff --git a/docs/markdown-notebooks.md b/docs/markdown-notebooks.md new file mode 100644 index 0000000..a057a32 --- /dev/null +++ b/docs/markdown-notebooks.md @@ -0,0 +1,53 @@ +--- +jupytext: + formats: md:myst + text_representation: + extension: .md + format_name: myst + format_version: 0.13 + jupytext_version: 1.11.5 +kernelspec: + display_name: Python 3 + language: python + name: python3 +--- + +# Notebooks with MyST Markdown + +Jupyter Book also lets you write text-based notebooks using MyST Markdown. +See [the Notebooks with MyST Markdown documentation](https://jupyterbook.org/file-types/myst-notebooks.html) for more detailed instructions. +This page shows off a notebook written in MyST Markdown. + +## An example cell + +With MyST Markdown, you can define code cells with a directive like so: + +```{code-cell} +print(2 + 2) +``` + +When your book is built, the contents of any `{code-cell}` blocks will be +executed with your default Jupyter kernel, and their outputs will be displayed +in-line with the rest of your content. + +```{seealso} +Jupyter Book uses [Jupytext](https://jupytext.readthedocs.io/en/latest/) to convert text-based files to notebooks, and can support [many other text-based notebook files](https://jupyterbook.org/file-types/jupytext.html). +``` + +## Create a notebook with MyST Markdown + +MyST Markdown notebooks are defined by two things: + +1. YAML metadata that is needed to understand if / how it should convert text files to notebooks (including information about the kernel needed). + See the YAML at the top of this page for example. +2. The presence of `{code-cell}` directives, which will be executed with your book. + +That's all that is needed to get started! + +## Quickly add YAML metadata for MyST Notebooks + +If you have a markdown file and you'd like to quickly add YAML metadata to it, so that Jupyter Book will treat it as a MyST Markdown Notebook, run the following command: + +``` +jupyter-book myst init path/to/markdownfile.md +``` diff --git a/docs/markdown.md b/docs/markdown.md new file mode 100644 index 0000000..faeea60 --- /dev/null +++ b/docs/markdown.md @@ -0,0 +1,55 @@ +# Markdown Files + +Whether you write your book's content in Jupyter Notebooks (`.ipynb`) or +in regular markdown files (`.md`), you'll write in the same flavor of markdown +called **MyST Markdown**. +This is a simple file to help you get started and show off some syntax. + +## What is MyST? + +MyST stands for "Markedly Structured Text". It +is a slight variation on a flavor of markdown called "CommonMark" markdown, +with small syntax extensions to allow you to write **roles** and **directives** +in the Sphinx ecosystem. + +For more about MyST, see [the MyST Markdown Overview](https://jupyterbook.org/content/myst.html). + +## Sample Roles and Directives + +Roles and directives are two of the most powerful tools in Jupyter Book. They +are like functions, but written in a markup language. They both +serve a similar purpose, but **roles are written in one line**, whereas +**directives span many lines**. They both accept different kinds of inputs, +and what they do with those inputs depends on the specific role or directive +that is being called. + +Here is a "note" directive: + +```{note} +Here is a note +``` + +It will be rendered in a special box when you build your book. + +Here is an inline directive to refer to a document: {doc}`markdown-notebooks`. + + +## Citations + +You can also cite references that are stored in a `bibtex` file. For example, +the following syntax: `` {cite}`holdgraf_evidence_2014` `` will render like +this: {cite}`holdgraf_evidence_2014`. + +Moreover, you can insert a bibliography into your page with this syntax: +The `{bibliography}` directive must be used for all the `{cite}` roles to +render properly. +For example, if the references for your book are stored in `references.bib`, +then the bibliography is inserted with: + +```{bibliography} +``` + +## Learn more + +This is just a simple starter to get you started. +You can learn a lot more at [jupyterbook.org](https://jupyterbook.org). diff --git a/docs/notebooks.ipynb b/docs/notebooks.ipynb new file mode 100644 index 0000000..fdb7176 --- /dev/null +++ b/docs/notebooks.ipynb @@ -0,0 +1,122 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Content with notebooks\n", + "\n", + "You can also create content with Jupyter Notebooks. This means that you can include\n", + "code blocks and their outputs in your book.\n", + "\n", + "## Markdown + notebooks\n", + "\n", + "As it is markdown, you can embed images, HTML, etc into your posts!\n", + "\n", + "![](https://myst-parser.readthedocs.io/en/latest/_static/logo-wide.svg)\n", + "\n", + "You can also $add_{math}$ and\n", + "\n", + "$$\n", + "math^{blocks}\n", + "$$\n", + "\n", + "or\n", + "\n", + "$$\n", + "\\begin{aligned}\n", + "\\mbox{mean} la_{tex} \\\\ \\\\\n", + "math blocks\n", + "\\end{aligned}\n", + "$$\n", + "\n", + "But make sure you \\$Escape \\$your \\$dollar signs \\$you want to keep!\n", + "\n", + "## MyST markdown\n", + "\n", + "MyST markdown works in Jupyter Notebooks as well. For more information about MyST markdown, check\n", + "out [the MyST guide in Jupyter Book](https://jupyterbook.org/content/myst.html),\n", + "or see [the MyST markdown documentation](https://myst-parser.readthedocs.io/en/latest/).\n", + "\n", + "## Code blocks and outputs\n", + "\n", + "Jupyter Book will also embed your code blocks and output in your book.\n", + "For example, here's some sample Matplotlib code:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from matplotlib import rcParams, cycler\n", + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "plt.ion()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Fixing random state for reproducibility\n", + "np.random.seed(19680801)\n", + "\n", + "N = 10\n", + "data = [np.logspace(0, 1, 100) + np.random.randn(100) + ii for ii in range(N)]\n", + "data = np.array(data).T\n", + "cmap = plt.cm.coolwarm\n", + "rcParams['axes.prop_cycle'] = cycler(color=cmap(np.linspace(0, 1, N)))\n", + "\n", + "\n", + "from matplotlib.lines import Line2D\n", + "custom_lines = [Line2D([0], [0], color=cmap(0.), lw=4),\n", + " Line2D([0], [0], color=cmap(.5), lw=4),\n", + " Line2D([0], [0], color=cmap(1.), lw=4)]\n", + "\n", + "fig, ax = plt.subplots(figsize=(10, 5))\n", + "lines = ax.plot(data)\n", + "ax.legend(custom_lines, ['Cold', 'Medium', 'Hot']);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "There is a lot more that you can do with outputs (such as including interactive outputs)\n", + "with your book. For more information about this, see [the Jupyter Book documentation](https://jupyterbook.org)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.0" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/docs/references.bib b/docs/references.bib new file mode 100644 index 0000000..957d686 --- /dev/null +++ b/docs/references.bib @@ -0,0 +1,57 @@ +--- +--- + +@inproceedings{holdgraf_evidence_2014, + address = {Brisbane, Australia, Australia}, + title = {Evidence for {Predictive} {Coding} in {Human} {Auditory} {Cortex}}, + booktitle = {International {Conference} on {Cognitive} {Neuroscience}}, + publisher = {Frontiers in Neuroscience}, + author = {Holdgraf, Christopher Ramsay and de Heer, Wendy and Pasley, Brian N. and Knight, Robert T.}, + year = {2014} +} + +@article{holdgraf_rapid_2016, + title = {Rapid tuning shifts in human auditory cortex enhance speech intelligibility}, + volume = {7}, + issn = {2041-1723}, + url = {http://www.nature.com/doifinder/10.1038/ncomms13654}, + doi = {10.1038/ncomms13654}, + number = {May}, + journal = {Nature Communications}, + author = {Holdgraf, Christopher Ramsay and de Heer, Wendy and Pasley, Brian N. and Rieger, Jochem W. and Crone, Nathan and Lin, Jack J. and Knight, Robert T. and Theunissen, Frédéric E.}, + year = {2016}, + pages = {13654}, + file = {Holdgraf et al. - 2016 - Rapid tuning shifts in human auditory cortex enhance speech intelligibility.pdf:C\:\\Users\\chold\\Zotero\\storage\\MDQP3JWE\\Holdgraf et al. - 2016 - Rapid tuning shifts in human auditory cortex enhance speech intelligibility.pdf:application/pdf} +} + +@inproceedings{holdgraf_portable_2017, + title = {Portable learning environments for hands-on computational instruction using container-and cloud-based technology to teach data science}, + volume = {Part F1287}, + isbn = {978-1-4503-5272-7}, + doi = {10.1145/3093338.3093370}, + abstract = {© 2017 ACM. There is an increasing interest in learning outside of the traditional classroom setting. This is especially true for topics covering computational tools and data science, as both are challenging to incorporate in the standard curriculum. These atypical learning environments offer new opportunities for teaching, particularly when it comes to combining conceptual knowledge with hands-on experience/expertise with methods and skills. Advances in cloud computing and containerized environments provide an attractive opportunity to improve the effciency and ease with which students can learn. This manuscript details recent advances towards using commonly-Available cloud computing services and advanced cyberinfrastructure support for improving the learning experience in bootcamp-style events. We cover the benets (and challenges) of using a server hosted remotely instead of relying on student laptops, discuss the technology that was used in order to make this possible, and give suggestions for how others could implement and improve upon this model for pedagogy and reproducibility.}, + booktitle = {{ACM} {International} {Conference} {Proceeding} {Series}}, + author = {Holdgraf, Christopher Ramsay and Culich, A. and Rokem, A. and Deniz, F. and Alegro, M. and Ushizima, D.}, + year = {2017}, + keywords = {Teaching, Bootcamps, Cloud computing, Data science, Docker, Pedagogy} +} + +@article{holdgraf_encoding_2017, + title = {Encoding and decoding models in cognitive electrophysiology}, + volume = {11}, + issn = {16625137}, + doi = {10.3389/fnsys.2017.00061}, + abstract = {© 2017 Holdgraf, Rieger, Micheli, Martin, Knight and Theunissen. Cognitive neuroscience has seen rapid growth in the size and complexity of data recorded from the human brain as well as in the computational tools available to analyze this data. This data explosion has resulted in an increased use of multivariate, model-based methods for asking neuroscience questions, allowing scientists to investigate multiple hypotheses with a single dataset, to use complex, time-varying stimuli, and to study the human brain under more naturalistic conditions. These tools come in the form of “Encoding” models, in which stimulus features are used to model brain activity, and “Decoding” models, in which neural features are used to generated a stimulus output. Here we review the current state of encoding and decoding models in cognitive electrophysiology and provide a practical guide toward conducting experiments and analyses in this emerging field. Our examples focus on using linear models in the study of human language and audition. We show how to calculate auditory receptive fields from natural sounds as well as how to decode neural recordings to predict speech. The paper aims to be a useful tutorial to these approaches, and a practical introduction to using machine learning and applied statistics to build models of neural activity. The data analytic approaches we discuss may also be applied to other sensory modalities, motor systems, and cognitive systems, and we cover some examples in these areas. In addition, a collection of Jupyter notebooks is publicly available as a complement to the material covered in this paper, providing code examples and tutorials for predictive modeling in python. The aimis to provide a practical understanding of predictivemodeling of human brain data and to propose best-practices in conducting these analyses.}, + journal = {Frontiers in Systems Neuroscience}, + author = {Holdgraf, Christopher Ramsay and Rieger, J.W. and Micheli, C. and Martin, S. and Knight, R.T. and Theunissen, F.E.}, + year = {2017}, + keywords = {Decoding models, Encoding models, Electrocorticography (ECoG), Electrophysiology/evoked potentials, Machine learning applied to neuroscience, Natural stimuli, Predictive modeling, Tutorials} +} + +@book{ruby, + title = {The Ruby Programming Language}, + author = {Flanagan, David and Matsumoto, Yukihiro}, + year = {2008}, + publisher = {O'Reilly Media} +} + diff --git a/mloq.yml b/mloq.yml deleted file mode 100644 index 8185e91..0000000 --- a/mloq.yml +++ /dev/null @@ -1,22 +0,0 @@ -template: - project_name: project_name - description: Template project generated with mloq. - owner: gh_owner - email: OWNER_EMAIL - author: AUTHOR - copyright_holder: COPYRIGHT_HOLDER - project_url: https://github.com/gh_owner/project_name - download_url: https://github.com/gh_owner/project_name.git - bot_name: BOT_NAME - bot_email: BOT_EMAIL - license: MIT - python_versions: - - '3.6' - - '3.7' - - '3.8' - - '3.9' - default_branch: master -requirements: - - data-science - - data-viz -workflow: python diff --git a/project_name/__main__.py b/project_name/__main__.py deleted file mode 100644 index 32c1da2..0000000 --- a/project_name/__main__.py +++ /dev/null @@ -1,9 +0,0 @@ -import sys - - -def main(): - return 1 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/project_name/tests/__init__.py b/project_name/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/project_name/tests/test_main.py b/project_name/tests/test_main.py deleted file mode 100644 index ac601bc..0000000 --- a/project_name/tests/test_main.py +++ /dev/null @@ -1,7 +0,0 @@ -import pytest - -from project_name.__main__ import main - - -def test_main(): - main() diff --git a/project_name/version.py b/project_name/version.py deleted file mode 100644 index 2665310..0000000 --- a/project_name/version.py +++ /dev/null @@ -1,2 +0,0 @@ -"""Current version of the project. Do not modify manually.""" -__version__ = "0.0.0" diff --git a/pyproject.toml b/pyproject.toml index f6d4976..4965e39 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,31 +1,226 @@ -# NOTE: you have to use single-quoted strings in TOML for regular expressions. -# It's the equivalent of r-strings in Python. Multiline strings are treated as -# verbose regular expressions by Black. Use [ ] to denote a significant space -# character. +[build-system] +requires = ["hatchling", "hatch-vcs"] +build-backend = "hatchling.build" + +[project] +name = "mloq-template" +description = "An example package. Generated with cookiecutter-pylibrary." +readme = "README.md" +requires-python = ">=3.10" +license = { file = "LICENSE" } +# keywords for easier look-up on PyPI +keywords = [] # ToDo: Modify according to your needs! +authors = [ + { name = "Guillem Duran Ballester", email = "guillem@fragile.tech" }, +] +maintainers = [ + { name = "Guillem Duran Ballester", email = "guillem@fragile.tech" }, +] +# options under https://pypi.org/classifiers/ +classifiers = [ + # complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Operating System :: Unix", + "Operating System :: POSIX", + "Operating System :: Microsoft :: Windows", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + # uncomment if you test on these interpreters: + # "Programming Language :: Python :: Implementation :: IronPython", + # "Programming Language :: Python :: Implementation :: Jython", + # "Programming Language :: Python :: Implementation :: Stackless", + "Topic :: Utilities", + ] +dynamic = ["version"] +# direct dependencies of this package, installed when users `pip install mloq-template` later. +dependencies = ["flogging"] # ToDo: Modify according to your needs! +[project.urls] +# important URLs for this project +Documentation = "https://mloq-template.readthedocs.io/" +Changelog = "https://mloq-template.readthedocs.io/en/latest/changelog.html" +Tracker = "https://github.com/guillemdb/mloq-template/issues" +[project.optional-dependencies] +lint= ["mypy", "ruff"] +test = ["pytest", "pytest-cov", "pytest-xdist"] +docs = [ + "autoapi", + "jupyter-book", + "sphinx", + "linkify-it-py", + "myst-parser", + "myst-nb", + "ruyaml", + "sphinx-autoapi", + "pydata-sphinx-theme", + "sphinx-autodoc2", + "sphinxcontrib-mermaid", + "sphinx_book_theme", + "sphinx_rtd_theme", + "jupyter-cache", + "sphinx-copybutton", + "sphinx-togglebutton", + "sphinxext-opengraph", + "sphinxcontrib-bibtex", +] +[tool.rye] +managed = true +universal = true +dev-dependencies = [ + "autoapi>=2.0.1", + "ruff", + "sphinx", + "linkify-it-py", + "myst-parser", + "myst-nb", + "ruyaml", + "sphinx-autoapi", + "pydata-sphinx-theme", + "sphinx-autodoc2", + "sphinxcontrib-mermaid", + "sphinx_book_theme", + "sphinx_rtd_theme", + "jupyter-cache", + "sphinx-copybutton", + "sphinx-togglebutton", + "sphinxext-opengraph", + "sphinxcontrib-bibtex", +] +[tool.hatch.metadata] +# direct dependency references, e.g `pip @ git+https://github.com/pypa/pip.git@master` +allow-direct-references = true + +[tool.hatch.version] +path = "src/mloq_template/version.py" + +[tool.hatch.build] +packages = ["src/mloq_template"] -# Example configuration for Black. -[tool.black] +[tool.hatch.build.targets.sdist] +exclude = [ + "/.github", +] + +[tool.rye.scripts] +lint = { cmd = "hatch run lint:all" } +style = { cmd = "hatch run lint:style" } +check = { cmd = "hatch run lint:check" } +test = { cmd = "hatch run test:test" } +doctest = { cmd = "hatch run test:doctest" } +cov = { cmd = "hatch run test:cov" } +no-cov = { cmd = "hatch run test:no-cov" } +debug = { cmd = "hatch run test:debug" } +docs = { cmd = "hatch run docs:docs" } +build-docs = { cmd = "hatch run docs:build"} +sphinx = { cmd = "hatch run docs:sphinx" } +serve-docs = { cmd = "hatch run docs:serve" } + +[tool.ruff] +# Assume Python 3.10 +target-version = "py310" + +preview = true +include = ["*.py", "*.pyi", "**/pyproject.toml"] +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".mypy_cache", + ".nox", + ".pants.d", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + ".idea", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "output", + "venv", + "experimental", + ".pytest_cache", + "**/.ipynb_checkpoints/**", + "**/proto/**", + "data", + "config", +] +# Same as Black. line-length = 99 -target-version = ['py36', 'py37', 'py38'] -include = '\.pyi?$' -exclude = ''' -/( - \.eggs - | \.git - | \.hg - | \.mypy_cache - | \.tox - | \.venv - | _build - | buck-out - | build - | dist -)/ -''' -# Isort configuration to manage imports +[tool.ruff.lint] +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" +select = [ + "ARG", "C4", "D", "E", "EM", "F", "FBT", + "FLY", "FIX", "FURB", "N", "NPY", + "INP", "ISC", "PERF", "PIE", "PL", + "PTH", "RET", "RUF", "S", "T10", + "TD", "T20", "UP", "YTT", "W", +] +ignore = [ + "D100", "D211", "D213", "D104", "D203", "D301", "D407", "S101", + "FBT001", "FBT002", "FIX002", "ISC001", "PLR0913", "RUF012", "TD003", + "PTH123", "PLR6301", "PLR0917", "S311", "S403", "PLR0914", "PLR0915", "S608", + "EM102", "PTH111", "FIX004", "UP035", "PLW2901", "S318", "S404", + "S408", 'S405', 'S607', 'S603', + 'E902', "TD001", "TD002", "FIX001", "T201", +] +# Allow autofix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +# unfixable = ["I"] + +[tool.ruff.lint.flake8-import-conventions.aliases] +# Declare the default aliases. +altair = "alt" +"matplotlib.pyplot" = "plt" +numpy = "np" +pandas = "pd" +seaborn = "sns" +scipy = "sp" +holoviews = "hv" +panel = "pn" +polars = "pl" +"polars.selectors" = "cs" + +[tool.ruff.lint.flake8-quotes] +docstring-quotes = "double" + +[tool.ruff.lint.per-file-ignores] +"__init__.py" = ["E402", "F401"] +"cli.py" = ["PLC0415", "D205", "D400", "D415"] +"**/docs/**" = ["INP001", "PTH100"] +"**/{tests,docs}/*" = [ + "E402", "F401", "F811", "D", "S101", "PLR2004", "S105", + "PLW1514", "PTH123", "PTH107", "N811", "PLC0415", "ARG002", +] +# Enable reformatting of code snippets in docstrings. +[tool.ruff.format] +docstring-code-line-length = 80 +docstring-code-format = true +indent-style = "space" +line-ending = "auto" +preview = true +quote-style = "double" + [tool.isort] profile = "black" -line_length = 99 +line_length = "99" multi_line_output = 3 order_by_type = false force_alphabetical_sort_within_sections = true @@ -35,49 +230,30 @@ include_trailing_comma = true color_output = true lines_after_imports = 2 honor_noqa = true +skip = [".venv", "venv"] +skip_glob = ["*.pyx"] -# Code coverage config -[tool.coverage.run] -branch = true -source = ["project_name"] +[tool.ruff.lint.isort] +known-first-party = ["mloq_template"] +forced-separate = ["conftest"] +force-single-line = true -[tool.coverage.report] -exclude_lines =["no cover", - 'raise NotImplementedError', - 'if __name__ == "__main__":'] -ignore_errors = true -omit = ["project_name/tests/*"] - -# Flakehell config -[tool.flakehell] -# optionally inherit from remote config (or local if you want) -base = "https://raw.githubusercontent.com/life4/flakehell/master/pyproject.toml" -# specify any flake8 options. For example, exclude "example.py": -exclude = [".git", "docs", ".ipynb*", "*.ipynb", ".pytest_cache"] -format = "grouped" # make output nice -max_line_length = 99 # show line of source code in output -show_source = true -inline_quotes='"' -import_order_style = "appnexus" -application_package_names = ["project_name"] -application_import_names = ["project_name"] - -[tool.flakehell.plugins] -'flake8*' = ["+*", "-D*"] # disable docs by default -pylint = ["+*", "-D*"] -pyflakes = ["+*"] -pycodestyle = ["+*" ,"-B008","-B301","-C815","-C816","-C812","-D100", - "-D105","-D200","-D202","-D301","-D402","-E121","-E123","-E126","-E203","-E226", - "-E24","-E704","-F821","-W503","-W504"] - -[tool.flakehell.exceptions."**/__init__.py"] -"flake8*" = ["-D*"] -pylint = ["-D*"] - -# match by prefix -[tool.flakehell.exceptions."**/tests/*"] -pycodestyle = ["-F401", "-F811"] # disable a check -pyflakes = ["-*"] # disable a plugin +[tool.ruff.lint.flake8-pytest-style] +fixture-parentheses = false +mark-parentheses = false + +[tool.ruff.lint.flake8-tidy-imports] +ban-relative-imports = "all" + +[tool.mypy] +files = ["src/mloq_template", "tests"] +disallow_untyped_defs = false +follow_imports = "normal" # "silent" for not following +ignore_missing_imports = true +pretty = true +show_column_numbers = true +warn_no_return = false +warn_unused_ignores = true [tool.pylint.master] ignore = 'tests' @@ -92,6 +268,118 @@ enable = """, missing-return-doc, """ -[build-system] -requires = ["setuptools >= 50.3.2", "wheel", "importlib"] -build-backend = "setuptools.build_meta" \ No newline at end of file +[tool.pytest.ini_options] +# To disable a specific warning --> action:message:category:module:line +filterwarnings = ["ignore::UserWarning", 'ignore::DeprecationWarning'] +addopts = "--ignore=scripts --doctest-continue-on-failure" + +# Code coverage config +[tool.coverage.run] +branch = true +source = ["src/mloq_template"] +omit = [ + "version.py", # automatically created by hatch-vcs, not in repo +] +[tool.coverage.paths] +source = [ + "src/", + "*/site-packages/", +] + +[tool.coverage.report] +# Regexes for lines to exclude from consideration +exclude_lines = [ + # Have to re-enable the standard pragma + "pragma: no cover", + + # Don't complain about missing debug-only code: + "def __repr__", + "if self\\.debug", + + # Don't complain if tests don't hit defensive assertion code: + "raise AssertionError", + "raise NotImplementedError", + + # Don't complain if non-runnable code isn't run: + "if 0:", + "if __name__ == .__main__.:", + "if TYPE_CHECKING:", +] +ignore_errors = true +omit = ["tests/*"] + +##################### +# Environment Setup # +##################### + +# Default environment with production dependencies +[tool.hatch.envs.default] +installer = "uv" +python = "3.10" +post-install-commands = ["pre-commit install"] +dependencies = [] +# Test environment with test-only dependencies +[tool.hatch.envs.test] +description = "Run tests and coverage" +features = ["test"] +[tool.hatch.envs.test.scripts] +run_pytest = "pytest -s -o log_cli=true -o log_cli_level=info {args}" +doctest = "run_pytest --doctest-modules -n 0 {args:src}" +test = ["doctest", "run_pytest {args:tests}"] +cov = "run_pytest -n ${N} --cov-report=term-missing --cov-config=pyproject.toml --cov=src/mloq_template --cov=tests {args}" +no-cov = "cov --no-cov {args}" +debug = "cov --no-cov --pdb --pdbcls=IPython.core.debugger:Pdb {args}" +[tool.hatch.envs.test.env-vars] +N = "auto" +# Docs environment +[tool.hatch.envs.docs] +description = "Build and serve documentation using Jupyter Book and Sphinx" +features = ["docs"] +[tool.hatch.envs.docs.env-vars] +SOURCE_DATE_EPOCH = "1580601600" +PYTHONUNBUFFERED = "1" +[tool.hatch.envs.docs.scripts] +features = ["docs"] +build = [ + "jupyter-book build docs/ ", + "freeze > docs/requirements.txt", +] +serve = "python3 -m http.server --directory docs/_build/html {args}" +sphinx = [ + "jupyter-book config sphinx docs/ --overwrite", + "sphinx-build -b html docs/ docs/_build/html", + "freeze > docs/requirements.txt", +] +docs = ["build", "serve"] +# Lint environment +[tool.hatch.envs.lint] +description = "Run linting checks with ruff and mypi" +template = "lint" # don't inherit from default! +features = ["lint"] +skip-install = true +dependencies = [ + "mypy", + "ruff", +] +[tool.hatch.envs.lint.scripts] +typing = [ + "echo \"MYPY VERSION: `mypy --version`\"", + "mypy --install-types --non-interactive {args}" +] +style = [ + "echo \"RUFF VERSION: `ruff --version`\"", + "ruff check --fix-only --unsafe-fixes {args:.}", "ruff format {args:.}", +] +check = [ + "ruff check {args:.}", "ruff format --diff {args:.}","mypy {args:.}" , +] +all = [ + "style", + "check", + "typing", +] + +# Test matrix for various Python versions replacing the functionality of tox +[[tool.hatch.envs.py-test.matrix]] +template = ["test"] +python = ["39", "310", "311", "312"] diff --git a/requirements-dev.lock b/requirements-dev.lock new file mode 100644 index 0000000..177bfed --- /dev/null +++ b/requirements-dev.lock @@ -0,0 +1,362 @@ +# generated by rye +# use `rye lock` or `rye sync` to update this lockfile +# +# last locked with the following flags: +# pre: false +# features: [] +# all-features: true +# with-sources: false +# generate-hashes: false +# universal: true + +-e file:. +accessible-pygments==0.0.5 + # via pydata-sphinx-theme +alabaster==1.0.0 + # via sphinx +appnope==0.1.4 ; platform_system == 'Darwin' + # via ipykernel +astroid==3.3.4 + # via sphinx-autoapi + # via sphinx-autodoc2 +asttokens==2.4.1 + # via stack-data +attrs==24.2.0 + # via jsonschema + # via jupyter-cache + # via referencing +autoapi==2.0.1 + # via mloq-template +babel==2.16.0 + # via pydata-sphinx-theme + # via sphinx +beautifulsoup4==4.12.3 + # via nbconvert + # via pydata-sphinx-theme +bleach==6.1.0 + # via nbconvert +certifi==2024.8.30 + # via requests +cffi==1.17.1 ; implementation_name == 'pypy' + # via pyzmq +charset-normalizer==3.3.2 + # via requests +click==8.1.7 + # via jupyter-cache +colorama==0.4.6 ; sys_platform == 'win32' or platform_system == 'Windows' + # via click + # via ipython + # via pytest + # via sphinx + # via tqdm +comm==0.2.2 + # via ipykernel +coverage==7.6.1 + # via pytest-cov +debugpy==1.8.6 + # via ipykernel +decorator==5.1.1 + # via ipython +defusedxml==0.7.1 + # via nbconvert +distro==1.9.0 + # via ruyaml +docutils==0.21.2 + # via myst-parser + # via pybtex-docutils + # via pydata-sphinx-theme + # via sphinx + # via sphinx-togglebutton + # via sphinxcontrib-bibtex +exceptiongroup==1.2.2 ; python_full_version < '3.11' + # via ipython + # via pytest +execnet==2.1.1 + # via pytest-xdist +executing==2.1.0 + # via stack-data +fastjsonschema==2.20.0 + # via nbformat +greenlet==3.1.1 ; (python_full_version < '3.13' and platform_machine == 'AMD64') or (python_full_version < '3.13' and platform_machine == 'WIN32') or (python_full_version < '3.13' and platform_machine == 'aarch64') or (python_full_version < '3.13' and platform_machine == 'amd64') or (python_full_version < '3.13' and platform_machine == 'ppc64le') or (python_full_version < '3.13' and platform_machine == 'win32') or (python_full_version < '3.13' and platform_machine == 'x86_64') + # via sqlalchemy +idna==3.10 + # via requests +imagesize==1.4.1 + # via sphinx +importlib-metadata==8.5.0 + # via jupyter-cache + # via myst-nb +iniconfig==2.0.0 + # via pytest +ipykernel==6.29.5 + # via jupyter-book + # via myst-nb +ipython==8.27.0 + # via ipykernel + # via myst-nb +jedi==0.19.1 + # via ipython +jinja2==3.1.4 + # via myst-parser + # via nbconvert + # via sphinx + # via sphinx-autoapi +jsonschema==4.23.0 + # via nbformat +jsonschema-specifications==2023.12.1 + # via jsonschema +jupyter-book==0.6.5 + # via mloq-template +jupyter-cache==1.0.0 + # via mloq-template + # via myst-nb +jupyter-client==8.6.3 + # via ipykernel + # via jupyter-book + # via nbclient +jupyter-core==5.7.2 + # via ipykernel + # via jupyter-client + # via nbclient + # via nbconvert + # via nbformat +jupyterlab-pygments==0.3.0 + # via nbconvert +jupytext==1.16.4 + # via jupyter-book +latexcodec==3.0.0 + # via pybtex +libsass==0.23.0 + # via jupyter-book +linkify-it-py==2.0.3 + # via mloq-template +markdown-it-py==3.0.0 + # via jupytext + # via mdit-py-plugins + # via myst-parser +markupsafe==2.1.5 + # via jinja2 + # via nbconvert +matplotlib-inline==0.1.7 + # via ipykernel + # via ipython +mdit-py-plugins==0.4.2 + # via jupytext + # via myst-parser +mdurl==0.1.2 + # via markdown-it-py +mistune==3.0.2 + # via nbconvert +mypy==1.11.2 + # via mloq-template +mypy-extensions==1.0.0 + # via mypy +myst-nb==1.1.2 + # via mloq-template +myst-parser==4.0.0 + # via mloq-template + # via myst-nb +nbclient==0.10.0 + # via jupyter-cache + # via myst-nb + # via nbconvert +nbconvert==7.16.4 + # via jupyter-book +nbformat==5.10.4 + # via jupyter-book + # via jupyter-cache + # via jupytext + # via myst-nb + # via nbclient + # via nbconvert +nest-asyncio==1.6.0 + # via ipykernel +packaging==24.1 + # via ipykernel + # via jupytext + # via nbconvert + # via pydata-sphinx-theme + # via pytest + # via sphinx +pandocfilters==1.5.1 + # via nbconvert +parso==0.8.4 + # via jedi +pexpect==4.9.0 ; sys_platform != 'emscripten' and sys_platform != 'win32' + # via ipython +platformdirs==4.3.6 + # via jupyter-core +pluggy==1.5.0 + # via pytest +prompt-toolkit==3.0.48 + # via ipython +psutil==6.0.0 + # via ipykernel +ptyprocess==0.7.0 ; sys_platform != 'emscripten' and sys_platform != 'win32' + # via pexpect +pure-eval==0.2.3 + # via stack-data +pybtex==0.24.0 + # via pybtex-docutils + # via sphinxcontrib-bibtex +pybtex-docutils==1.0.3 + # via sphinxcontrib-bibtex +pycparser==2.22 ; implementation_name == 'pypy' + # via cffi +pydata-sphinx-theme==0.15.4 + # via mloq-template + # via sphinx-book-theme +pygments==2.18.0 + # via accessible-pygments + # via ipython + # via nbconvert + # via pydata-sphinx-theme + # via sphinx +pytest==8.3.3 + # via jupyter-book + # via mloq-template + # via pytest-cov + # via pytest-xdist +pytest-cov==5.0.0 + # via mloq-template +pytest-xdist==3.6.1 + # via mloq-template +python-dateutil==2.9.0.post0 + # via jupyter-client +pywin32==306 ; platform_python_implementation != 'PyPy' and sys_platform == 'win32' + # via jupyter-core +pyyaml==6.0.2 + # via jupyter-book + # via jupyter-cache + # via jupytext + # via myst-nb + # via myst-parser + # via pybtex + # via sphinx-autoapi +pyzmq==26.2.0 + # via ipykernel + # via jupyter-client +referencing==0.35.1 + # via jsonschema + # via jsonschema-specifications +requests==2.32.3 + # via sphinx +rpds-py==0.20.0 + # via jsonschema + # via referencing +ruamel-yaml==0.18.6 + # via jupyter-book +ruamel-yaml-clib==0.2.8 ; python_full_version < '3.13' and platform_python_implementation == 'CPython' + # via ruamel-yaml +ruff==0.6.8 + # via mloq-template +ruyaml==0.91.0 + # via mloq-template +setuptools==75.1.0 + # via jupyter-book + # via ruyaml + # via sphinx-togglebutton + # via sphinxcontrib-bibtex +six==1.16.0 + # via asttokens + # via bleach + # via pybtex + # via python-dateutil +snowballstemmer==2.2.0 + # via sphinx +soupsieve==2.6 + # via beautifulsoup4 +sphinx==8.0.2 + # via autoapi + # via mloq-template + # via myst-nb + # via myst-parser + # via pydata-sphinx-theme + # via sphinx-autoapi + # via sphinx-book-theme + # via sphinx-copybutton + # via sphinx-rtd-theme + # via sphinx-togglebutton + # via sphinxcontrib-bibtex + # via sphinxext-opengraph +sphinx-autoapi==3.3.2 + # via mloq-template +sphinx-autodoc2==0.5.0 + # via mloq-template +sphinx-book-theme==1.1.3 + # via mloq-template +sphinx-copybutton==0.5.2 + # via mloq-template +sphinx-rtd-theme==0.5.1 + # via mloq-template +sphinx-togglebutton==0.3.2 + # via mloq-template +sphinxcontrib-applehelp==2.0.0 + # via sphinx +sphinxcontrib-bibtex==2.6.3 + # via mloq-template +sphinxcontrib-devhelp==2.0.0 + # via sphinx +sphinxcontrib-htmlhelp==2.1.0 + # via sphinx +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-mermaid==0.9.2 + # via mloq-template +sphinxcontrib-qthelp==2.0.0 + # via sphinx +sphinxcontrib-serializinghtml==2.0.0 + # via sphinx +sphinxext-opengraph==0.9.1 + # via mloq-template +sqlalchemy==2.0.35 + # via jupyter-cache +stack-data==0.6.3 + # via ipython +tabulate==0.9.0 + # via jupyter-cache +tinycss2==1.3.0 + # via nbconvert +tomli==2.0.1 ; python_full_version <= '3.11' + # via coverage + # via jupytext + # via mypy + # via pytest + # via sphinx + # via sphinx-autodoc2 +tornado==6.4.1 + # via ipykernel + # via jupyter-client +tqdm==4.66.5 + # via jupyter-book +traitlets==5.14.3 + # via comm + # via ipykernel + # via ipython + # via jupyter-client + # via jupyter-core + # via matplotlib-inline + # via nbclient + # via nbconvert + # via nbformat +typing-extensions==4.12.2 + # via astroid + # via ipython + # via mypy + # via myst-nb + # via pydata-sphinx-theme + # via sphinx-autodoc2 + # via sqlalchemy +uc-micro-py==1.0.3 + # via linkify-it-py +urllib3==2.2.3 + # via requests +wcwidth==0.2.13 + # via prompt-toolkit +webencodings==0.5.1 + # via bleach + # via tinycss2 +wheel==0.44.0 + # via sphinx-togglebutton +zipp==3.20.2 + # via importlib-metadata diff --git a/requirements-lint.txt b/requirements-lint.txt deleted file mode 100644 index 3812cce..0000000 --- a/requirements-lint.txt +++ /dev/null @@ -1,10 +0,0 @@ -black ==19.10b0 -flake8==3.8.4 -flake8-bugbear==20.1.4 -flake8-docstrings==1.5.0 -flake8-import-order==0.18.1 -flake8-quotes==3.2.0 -isort==5.6.4 -pylint==2.6.0 -pydocstyle==5.1.1 -flakehell==0.7.0 \ No newline at end of file diff --git a/requirements-test.txt b/requirements-test.txt deleted file mode 100644 index affa563..0000000 --- a/requirements-test.txt +++ /dev/null @@ -1,3 +0,0 @@ -pytest==6.1.2 -pytest-cov==2.10.1 -hypothesis==5.43.3 \ No newline at end of file diff --git a/requirements.lock b/requirements.lock new file mode 100644 index 0000000..40d99c3 --- /dev/null +++ b/requirements.lock @@ -0,0 +1,349 @@ +# generated by rye +# use `rye lock` or `rye sync` to update this lockfile +# +# last locked with the following flags: +# pre: false +# features: [] +# all-features: true +# with-sources: false +# generate-hashes: false +# universal: true + +-e file:. +accessible-pygments==0.0.5 + # via pydata-sphinx-theme +alabaster==0.7.16 + # via sphinx +appnope==0.1.4 ; platform_system == 'Darwin' + # via ipykernel +astroid==3.3.4 + # via sphinx-autoapi + # via sphinx-autodoc2 +asttokens==2.4.1 + # via stack-data +attrs==24.2.0 + # via jsonschema + # via jupyter-cache + # via referencing +autoapi==2.0.1 + # via mloq-template +babel==2.16.0 + # via pydata-sphinx-theme + # via sphinx +beautifulsoup4==4.12.3 + # via pydata-sphinx-theme +certifi==2024.8.30 + # via requests +cffi==1.17.1 ; implementation_name == 'pypy' + # via pyzmq +charset-normalizer==3.3.2 + # via requests +click==8.1.7 + # via jupyter-book + # via jupyter-cache + # via sphinx-external-toc +colorama==0.4.6 ; sys_platform == 'win32' or platform_system == 'Windows' + # via click + # via ipython + # via pytest + # via sphinx +comm==0.2.2 + # via ipykernel +coverage==7.6.1 + # via pytest-cov +debugpy==1.8.6 + # via ipykernel +decorator==5.1.1 + # via ipython +distro==1.9.0 + # via ruyaml +docutils==0.20.1 + # via myst-parser + # via pybtex-docutils + # via pydata-sphinx-theme + # via sphinx + # via sphinx-rtd-theme + # via sphinx-togglebutton + # via sphinxcontrib-bibtex +exceptiongroup==1.2.2 ; python_full_version < '3.11' + # via ipython + # via pytest +execnet==2.1.1 + # via pytest-xdist +executing==2.1.0 + # via stack-data +fastjsonschema==2.20.0 + # via nbformat +greenlet==3.1.1 ; (python_full_version < '3.13' and platform_machine == 'AMD64') or (python_full_version < '3.13' and platform_machine == 'WIN32') or (python_full_version < '3.13' and platform_machine == 'aarch64') or (python_full_version < '3.13' and platform_machine == 'amd64') or (python_full_version < '3.13' and platform_machine == 'ppc64le') or (python_full_version < '3.13' and platform_machine == 'win32') or (python_full_version < '3.13' and platform_machine == 'x86_64') + # via sqlalchemy +idna==3.10 + # via requests +imagesize==1.4.1 + # via sphinx +importlib-metadata==8.5.0 + # via jupyter-cache + # via myst-nb +iniconfig==2.0.0 + # via pytest +ipykernel==6.29.5 + # via myst-nb +ipython==8.27.0 + # via ipykernel + # via myst-nb +jedi==0.19.1 + # via ipython +jinja2==3.1.4 + # via jupyter-book + # via myst-parser + # via sphinx + # via sphinx-autoapi +jsonschema==4.23.0 + # via jupyter-book + # via nbformat +jsonschema-specifications==2023.12.1 + # via jsonschema +jupyter-book==1.0.2 + # via mloq-template +jupyter-cache==1.0.0 + # via mloq-template + # via myst-nb +jupyter-client==8.6.3 + # via ipykernel + # via nbclient +jupyter-core==5.7.2 + # via ipykernel + # via jupyter-client + # via nbclient + # via nbformat +latexcodec==3.0.0 + # via pybtex +linkify-it-py==2.0.3 + # via jupyter-book + # via mloq-template +markdown-it-py==3.0.0 + # via mdit-py-plugins + # via myst-parser +markupsafe==2.1.5 + # via jinja2 +matplotlib-inline==0.1.7 + # via ipykernel + # via ipython +mdit-py-plugins==0.4.2 + # via myst-parser +mdurl==0.1.2 + # via markdown-it-py +mypy==1.11.2 + # via mloq-template +mypy-extensions==1.0.0 + # via mypy +myst-nb==1.1.2 + # via jupyter-book + # via mloq-template +myst-parser==2.0.0 + # via jupyter-book + # via mloq-template + # via myst-nb +nbclient==0.10.0 + # via jupyter-cache + # via myst-nb +nbformat==5.10.4 + # via jupyter-cache + # via myst-nb + # via nbclient +nest-asyncio==1.6.0 + # via ipykernel +packaging==24.1 + # via ipykernel + # via pydata-sphinx-theme + # via pytest + # via sphinx + # via sphinx-jupyterbook-latex +parso==0.8.4 + # via jedi +pexpect==4.9.0 ; sys_platform != 'emscripten' and sys_platform != 'win32' + # via ipython +platformdirs==4.3.6 + # via jupyter-core +pluggy==1.5.0 + # via pytest +prompt-toolkit==3.0.48 + # via ipython +psutil==6.0.0 + # via ipykernel +ptyprocess==0.7.0 ; sys_platform != 'emscripten' and sys_platform != 'win32' + # via pexpect +pure-eval==0.2.3 + # via stack-data +pybtex==0.24.0 + # via pybtex-docutils + # via sphinxcontrib-bibtex +pybtex-docutils==1.0.3 + # via sphinxcontrib-bibtex +pycparser==2.22 ; implementation_name == 'pypy' + # via cffi +pydata-sphinx-theme==0.15.4 + # via mloq-template + # via sphinx-book-theme +pygments==2.18.0 + # via accessible-pygments + # via ipython + # via pydata-sphinx-theme + # via sphinx +pytest==8.3.3 + # via mloq-template + # via pytest-cov + # via pytest-xdist +pytest-cov==5.0.0 + # via mloq-template +pytest-xdist==3.6.1 + # via mloq-template +python-dateutil==2.9.0.post0 + # via jupyter-client +pywin32==306 ; platform_python_implementation != 'PyPy' and sys_platform == 'win32' + # via jupyter-core +pyyaml==6.0.2 + # via jupyter-book + # via jupyter-cache + # via myst-nb + # via myst-parser + # via pybtex + # via sphinx-autoapi + # via sphinx-external-toc +pyzmq==26.2.0 + # via ipykernel + # via jupyter-client +referencing==0.35.1 + # via jsonschema + # via jsonschema-specifications +requests==2.32.3 + # via sphinx +rpds-py==0.20.0 + # via jsonschema + # via referencing +ruff==0.6.8 + # via mloq-template +ruyaml==0.91.0 + # via mloq-template +setuptools==75.1.0 + # via ruyaml + # via sphinx-togglebutton + # via sphinxcontrib-bibtex +six==1.16.0 + # via asttokens + # via pybtex + # via python-dateutil +snowballstemmer==2.2.0 + # via sphinx +soupsieve==2.6 + # via beautifulsoup4 +sphinx==7.4.7 + # via autoapi + # via jupyter-book + # via mloq-template + # via myst-nb + # via myst-parser + # via pydata-sphinx-theme + # via sphinx-autoapi + # via sphinx-book-theme + # via sphinx-comments + # via sphinx-copybutton + # via sphinx-design + # via sphinx-external-toc + # via sphinx-jupyterbook-latex + # via sphinx-multitoc-numbering + # via sphinx-rtd-theme + # via sphinx-thebe + # via sphinx-togglebutton + # via sphinxcontrib-bibtex + # via sphinxcontrib-jquery + # via sphinxext-opengraph +sphinx-autoapi==3.3.2 + # via mloq-template +sphinx-autodoc2==0.5.0 + # via mloq-template +sphinx-book-theme==1.1.3 + # via jupyter-book + # via mloq-template +sphinx-comments==0.0.3 + # via jupyter-book +sphinx-copybutton==0.5.2 + # via jupyter-book + # via mloq-template +sphinx-design==0.6.1 + # via jupyter-book +sphinx-external-toc==1.0.1 + # via jupyter-book +sphinx-jupyterbook-latex==1.0.0 + # via jupyter-book +sphinx-multitoc-numbering==0.1.3 + # via jupyter-book +sphinx-rtd-theme==2.0.0 + # via mloq-template +sphinx-thebe==0.3.1 + # via jupyter-book +sphinx-togglebutton==0.3.2 + # via jupyter-book + # via mloq-template +sphinxcontrib-applehelp==2.0.0 + # via sphinx +sphinxcontrib-bibtex==2.6.3 + # via jupyter-book + # via mloq-template +sphinxcontrib-devhelp==2.0.0 + # via sphinx +sphinxcontrib-htmlhelp==2.1.0 + # via sphinx +sphinxcontrib-jquery==4.1 + # via sphinx-rtd-theme +sphinxcontrib-jsmath==1.0.1 + # via sphinx +sphinxcontrib-mermaid==0.9.2 + # via mloq-template +sphinxcontrib-qthelp==2.0.0 + # via sphinx +sphinxcontrib-serializinghtml==2.0.0 + # via sphinx +sphinxext-opengraph==0.9.1 + # via mloq-template +sqlalchemy==2.0.35 + # via jupyter-cache +stack-data==0.6.3 + # via ipython +tabulate==0.9.0 + # via jupyter-cache +tomli==2.0.1 ; python_full_version <= '3.11' + # via coverage + # via mypy + # via pytest + # via sphinx + # via sphinx-autodoc2 +tornado==6.4.1 + # via ipykernel + # via jupyter-client +traitlets==5.14.3 + # via comm + # via ipykernel + # via ipython + # via jupyter-client + # via jupyter-core + # via matplotlib-inline + # via nbclient + # via nbformat +typing-extensions==4.12.2 + # via astroid + # via ipython + # via mypy + # via myst-nb + # via pydata-sphinx-theme + # via sphinx-autodoc2 + # via sqlalchemy +uc-micro-py==1.0.3 + # via linkify-it-py +urllib3==2.2.3 + # via requests +wcwidth==0.2.13 + # via prompt-toolkit +wheel==0.44.0 + # via sphinx-togglebutton +zipp==3.20.2 + # via importlib-metadata diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 5611238..0000000 --- a/requirements.txt +++ /dev/null @@ -1,17 +0,0 @@ -bokeh==2.2.3 -holoviews==1.13.5 -hvplot==0.6.0 -matplotlib==3.3.2 -networkx==2.5 -numba==0.51.2 -numpy==1.19.2 -opencv-python==4.4.0.44 -pandas==1.1.3 -panel==0.10.0 -param==1.10.0 -pillow-simd==7.0.0.post3 -plotly==4.12.0 -scikit-learn==0.23.2 -scipy==1.5.3 -selenium==3.141.0 -streamz==0.6.0 \ No newline at end of file diff --git a/scripts/Dockerfile_aarch64 b/scripts/Dockerfile_aarch64 deleted file mode 100644 index f0aa852..0000000 --- a/scripts/Dockerfile_aarch64 +++ /dev/null @@ -1,11 +0,0 @@ -FROM quay.io/pypa/manylinux2014_aarch64 as build - -ENV PLAT=manylinux2014_aarch64 -RUN mkdir -p /io/ -COPY . /io/ -WORKDIR /io/ - -RUN ./scripts/build-manylinux-wheels.sh - -FROM scratch as release -COPY --from=build /io/dist /wheelhouse diff --git a/scripts/build-manylinux-wheels.sh b/scripts/build-manylinux-wheels.sh deleted file mode 100644 index 4b2aaf3..0000000 --- a/scripts/build-manylinux-wheels.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -set -e -x - -# This is to be run by Docker inside a Docker image. -# You can test it locally on a Linux machine by installing Docker and running from this -# repo's root: -# $ docker run -e PLAT=manylinux1_x86_64 -v `pwd`:/io quay.io/pypa/manylinux1_x86_64 /io/scripts/build-manylinux-wheels.sh - -# The -e just defines an environment variable PLAT=[docker name] inside the Docker: -# auditwheel can't detect the Docker name automatically. - -# The -v gives a directory alias for passing files in and out of the Docker. -# (/io is arbitrary). E.g the setup.py script can be accessed in the Docker via -# /io/setup.py quay.io/pypa/manylinux1_x86_64 is the full Docker image name. Docker -# downloads it automatically. - -# The last argument is a shell command that the Docker will execute. Filenames must be -# from the Docker's perspective. - -# Wheels are initially generated as you would usually, but put in a temp directory temp-wheels. -# The pip-cache is optional but can speed up local builds having a real permanent pip-cache dir. -mkdir -p /io/pip-cache -mkdir -p /io/temp-wheels - -# Clean out any old existing wheels. -find /io/temp-wheels/ -type f -delete - -for PYBIN in /opt/python/cp3[6789]*/bin; do - "${PYBIN}/pip" install -q -U setuptools wheel pytest --cache-dir /io/pip-cache - (cd /io/ && "${PYBIN}/python" -m pip install .) - (cd /io/ && "${PYBIN}/python" -m pytest) - (cd /io/ && "${PYBIN}/python" setup.py -q bdist_wheel -d /io/temp-wheels) -done - -"$PYBIN/pip" install -q auditwheel - -# Wheels aren't considered manylinux unless they have been through -# auditwheel. Audited wheels go in /io/dist/. -mkdir -p /io/dist/ - -for whl in /io/temp-wheels/*.whl; do - auditwheel repair "$whl" --plat $PLAT -w /io/dist/ -done diff --git a/scripts/makefile.docker b/scripts/makefile.docker deleted file mode 100644 index 6cbdc00..0000000 --- a/scripts/makefile.docker +++ /dev/null @@ -1,42 +0,0 @@ -current_dir = $(shell pwd) - -PROJECT = project_name -DOCKER_ORG = -VERSION ?= latest -UBUNTU_NAME = $(lsb_release -s -c) - -# Installation commands used by Dockerfiles -# Install system packages -.PHONY: install-common-dependencies -install-common-dependencies: - apt-get update && \ - apt-get install -y --no-install-suggests --no-install-recommends \ - ca-certificates locales pkg-config apt-utils gcc g++ wget make cmake git curl flex ssh gpgv \ - libffi-dev libjpeg-turbo-progs libjpeg8-dev libjpeg-turbo8 libjpeg-turbo8-dev gnupg2 \ - libpng-dev libpng16-16 libglib2.0-0 bison gfortran lsb-release \ - libsm6 libxext6 libxrender1 libfontconfig1 libhdf5-dev libopenblas-base libopenblas-dev \ - libfreetype6 libfreetype6-dev zlib1g-dev zlib1g xvfb python-opengl ffmpeg && \ - ln -s /usr/lib/x86_64-linux-gnu/libz.so /lib/ && \ - ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /lib/ && \ - echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \ - locale-gen && \ - wget -O - https://bootstrap.pypa.io/get-pip.py | python3 && \ - rm -rf /var/lib/apt/lists/* && \ - echo '#!/bin/bash\n\\n\echo\n\echo " $@"\n\echo\n\' > /browser && \ - chmod +x /browser - -.PHONY: remove-dev-packages -remove-dev-packages: - pip3 uninstall -y cython && \ - apt-get remove -y cmake pkg-config flex bison curl libpng-dev \ - libjpeg-turbo8-dev zlib1g-dev libhdf5-dev libopenblas-dev gfortran \ - libfreetype6-dev libjpeg8-dev libffi-dev && \ - apt-get autoremove -y && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -.PHONY: docker-push -docker-push: - docker push ${DOCKER_ORG}/${PROJECT}:${VERSION} - docker tag ${DOCKER_ORG}/${PROJECT}:${VERSION} ${DOCKER_ORG}/${PROJECT}:latest - docker push ${DOCKER_ORG}/${PROJECT}:latest \ No newline at end of file diff --git a/scripts/rename_testpypi_wheels.py b/scripts/rename_testpypi_wheels.py deleted file mode 100644 index 5d4891a..0000000 --- a/scripts/rename_testpypi_wheels.py +++ /dev/null @@ -1,36 +0,0 @@ -from distutils.version import StrictVersion -import os -from pathlib import Path -import sys - -import requests - - -def get_versions(package_name): - url = "https://test.pypi.org/pypi/%s/json" % (package_name,) - resp = requests.get(url) - data = resp.json() - versions = data["releases"].keys() - try: - versions = sorted(versions, key=lambda x: StrictVersion(x)) - except Exception: - versions = sorted(versions, key=str) - return versions - - -def rename_wheels(new_version=None): - dist_dir = Path(os.getcwd()) / "dist" - for file in os.listdir(str(dist_dir)): - version = file.split("-")[1] - new_file = file.replace(version, new_version) - os.rename(str(dist_dir / file), str(dist_dir / new_file)) - - -def main(): - project = os.environ.get("PROJECT_NAME", "project_name") - last_version = get_versions(project)[-1] - rename_wheels(last_version) - - -if __name__ == "__main__": - sys.exit(main()) \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index 74a6d02..0000000 --- a/setup.py +++ /dev/null @@ -1,41 +0,0 @@ -from importlib.machinery import SourceFileLoader -from pathlib import Path - -from setuptools import find_packages, setup - - -version = SourceFileLoader( - "project_name.version", str(Path(__file__).parent / "project_name" / "version.py"), -).load_module() - -with open(Path(__file__).with_name("README.md"), encoding="utf-8") as f: - long_description = f.read() - -setup( - name="project_name", - description="Template project generated with mloq.", - long_description=long_description, - long_description_content_type="text/markdown", - packages=find_packages(), - version=version.__version__, - license="MIT", - author="AUTHOR", - author_email="", - url="", - download_url="", - keywords=["Machine learning", "artificial intelligence"], - tests_require=["pytest>=5.3.5", "hypothesis>=5.6.0"], - extras_require={}, - install_requires=[], - package_data={"": ["README.md"]}, - classifiers=[ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Topic :: Software Development :: Libraries", - ], # TODO: Add classifiers according to license type -) \ No newline at end of file diff --git a/src/mloq_template/__init__.py b/src/mloq_template/__init__.py new file mode 100644 index 0000000..586f9b9 --- /dev/null +++ b/src/mloq_template/__init__.py @@ -0,0 +1,7 @@ +__version__ = "0.0.0" + +from .core import compute + +__all__ = [ + "compute", +] diff --git a/src/mloq_template/__main__.py b/src/mloq_template/__main__.py new file mode 100644 index 0000000..1e81294 --- /dev/null +++ b/src/mloq_template/__main__.py @@ -0,0 +1,13 @@ +"""Entrypoint module, in case you use `python -m mloq_template`. + +Why does this file exist, and why __main__? For more info, read: + +- https://www.python.org/dev/peps/pep-0338/ +- https://docs.python.org/2/using/cmdline.html#cmdoption-m +- https://docs.python.org/3/using/cmdline.html#cmdoption-m +""" + +from mloq_template.cli import run + +if __name__ == "__main__": + run() diff --git a/src/mloq_template/cli.py b/src/mloq_template/cli.py new file mode 100644 index 0000000..d09de14 --- /dev/null +++ b/src/mloq_template/cli.py @@ -0,0 +1,33 @@ +"""Module that contains the command line app. + +Why does this file exist, and why not put this in __main__? + + You might be tempted to import things from __main__ later, but that will cause + problems: the code will get executed twice: + + - When you run `python -mmloq_template` python will execute + ``__main__.py`` as a script. That means there will not be any + ``mloq_template.__main__`` in ``sys.modules``. + - When you import __main__ it will get executed again (as a module) because + there"s no ``mloq_template.__main__`` in ``sys.modules``. + + Also see (1) from http://click.pocoo.org/5/setuptools/#setuptools-integration +""" + +import sys + +from .core import compute + + +def run(argv=sys.argv): + """Print the result of the computation. + + Args: + argv (list): List of arguments. + + Returns: + int: A return code. + + """ + print(compute(argv)) + sys.exit(0) diff --git a/src/mloq_template/core.py b/src/mloq_template/core.py new file mode 100644 index 0000000..c8a8a3d --- /dev/null +++ b/src/mloq_template/core.py @@ -0,0 +1,3 @@ +def compute(args): + """Compute a placeholder for the compute function.""" + return max(args, key=len) diff --git a/src/mloq_template/version.py b/src/mloq_template/version.py new file mode 100644 index 0000000..6c8e6b9 --- /dev/null +++ b/src/mloq_template/version.py @@ -0,0 +1 @@ +__version__ = "0.0.0" diff --git a/project_name/__init__.py b/tests/__init__.py similarity index 100% rename from project_name/__init__.py rename to tests/__init__.py diff --git a/tests/test_cli.py b/tests/test_cli.py new file mode 100644 index 0000000..bfdcd65 --- /dev/null +++ b/tests/test_cli.py @@ -0,0 +1,5 @@ +import subprocess + + +def test_main(): + assert subprocess.check_output(["mloq-template", "foo", "foobar"], text=True) == "foobar\n" diff --git a/tests/test_core.py b/tests/test_core.py new file mode 100644 index 0000000..2ce2927 --- /dev/null +++ b/tests/test_core.py @@ -0,0 +1,5 @@ +from mloq_template import compute + + +def test_compute(): + assert compute(["a", "bc", "abc"]) == "abc"