Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate to pyproject.toml #251

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open

chore: migrate to pyproject.toml #251

wants to merge 5 commits into from

Conversation

JaeAeich
Copy link

@JaeAeich JaeAeich commented Feb 20, 2025

Description

migrate to using pyproject instead of setuptools.

Fixes #232

Summary by Sourcery

Migrates the project to use pyproject.toml and Poetry for dependency management and build configuration. This includes updating the Dockerfile, CI workflow, and development scripts to use Poetry, as well as removing obsolete files and adding a Makefile for common development tasks.

Enhancements:

  • Replaces resource_filename with files from importlib.resources for improved resource handling.

Build:

  • Migrates the build system from setup.py and requirements.txt to pyproject.toml and Poetry for dependency management.
  • Updates the Dockerfile to use multi-stage builds and Poetry for installing dependencies, resulting in a cleaner and more efficient image build process.

CI:

  • Updates the CI workflow to use Poetry for dependency installation and running linters, type checkers, and tests.

Chores:

  • Removes obsolete files such as requirements.txt, setup.py, setup.cfg, MANIFEST.in, requirements_dev.txt, and requirements_docs.txt.
  • Adds a Makefile to provide convenient commands for development tasks such as installing dependencies, running tests, and performing code quality checks.

Copy link

sourcery-ai bot commented Feb 20, 2025

Reviewer's Guide by Sourcery

This pull request migrates the project to use pyproject.toml and Poetry for dependency management, updates the Dockerfile to use multi-stage builds with Poetry, modifies the GitHub Actions workflow to use Poetry for running checks, and updates the Makefile to use Poetry for managing dependencies and running commands. It also includes minor fixes for line length issues and replaces deprecated resource_filename with files.

Sequence diagram for GitHub Actions CI workflow

Loading
sequenceDiagram
    participant GH Actions
    participant Poetry
    participant flake8
    participant mypy
    participant pytest
    GH Actions->>Poetry: Install dependencies
    Poetry-->>GH Actions: Dependencies installed
    GH Actions->>flake8: Run linting
    flake8-->>GH Actions: Linting results
    GH Actions->>mypy: Run type checking
    mypy-->>GH Actions: Type checking results
    GH Actions->>pytest: Run tests
    pytest-->>GH Actions: Test results

Updated class diagram for project dependencies

Loading
classDiagram
    class pyproject.toml {
        -build-system
        -tool.poetry
            -dependencies
                -python
                -addict
                -celery
                -connexion
                -cryptography
                -Flask
                -flask-authz
                -Flask-Cors
                -Flask-PyMongo
                -pydantic
                -PyJWT
                -pymongo
                -PyYAML
                -requests
                -swagger-ui-bundle
                -toml
                -typing
                -Werkzeug
            -group.code_quality.dependencies
                -flake8
                -Flake8-pyproject
                -mypy
                -mypy-extensions
                -pylint
            -group.docs.dependencies
                -Sphinx
                -readthedocs-sphinx-ext
                -sphinx-rtd-theme
            -group.test.dependencies
                -coverage
                -mongomock
                -pytest
            -group.types.dependencies
                -types-PyYAML
                -types-requests
                -types-setuptools
                -types-urllib3
                -typing_extensions
    }
    note for pyproject.toml "Replaces requirements.txt and setup.py for dependency management"

File-Level Changes

Change Details Files
Migrated the project to use pyproject.toml for dependency management and build configuration.
  • Replaced setup.py, setup.cfg, requirements.txt, requirements_dev.txt, and requirements_docs.txt with pyproject.toml.
  • Configured build system using Poetry.
  • Defined project metadata, dependencies, and development dependencies in pyproject.toml.
  • Configured mypy and flake8 settings within pyproject.toml.
pyproject.toml
setup.py
setup.cfg
requirements.txt
requirements_dev.txt
requirements_docs.txt
Updated the Dockerfile to use multi-stage builds with Poetry for managing dependencies.
  • Introduced a poetry stage to install Poetry.
  • Used Poetry to install dependencies and build the project in a builder stage.
  • Copied the built wheel file to the final image and installed it using pip.
  • Removed the installation of development dependencies in the Dockerfile.
  • Added labels to the final image.
docker/Dockerfile
Modified the GitHub Actions workflow to use Poetry for dependency management and running checks.
  • Installed Poetry in the workflow.
  • Used poetry install to install dependencies with different groups (code_quality, docs, test, types).
  • Used poetry run to execute linting, type checking, and testing commands.
  • Removed the explicit installation of setuptools.
.github/workflows/checks.yml
Updated the Makefile to use Poetry for managing dependencies and running commands.
  • Replaced pip commands with poetry run for linting, type checking, and testing.
  • Added a target to create a virtual environment using python -m venv.
  • Added a target to install dependencies using poetry.
Makefile
Removed unused files.
  • Removed MANIFEST.in and .flake8 files.
MANIFEST.in
.flake8
Fixed line length issues in test file.
  • Added noqa E501 to lines exceeding maximum length.
tests/api/test_register_openapi.py
Replaced deprecated resource_filename with files.
  • Replaced resource_filename with files from importlib.resources.
tests/security/access_control/test_access_control_server.py
Fixed line length issues in foca file.
  • Added noqa E501 to lines exceeding maximum length.
foca/api/register_openapi.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @JaeAeich - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider adding a poetry.lock file to the repository to ensure consistent dependency versions across environments.
  • The removal of setup.py and requirements.txt is expected, but double-check that all references to these files have been removed from other parts of the project.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

codecov bot commented Feb 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (d4d1632) to head (663efe9).
Report is 1 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #251   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           20        20           
  Lines          966       969    +3     
=========================================
+ Hits           966       969    +3     
Flag Coverage Δ
test_unit 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JaeAeich JaeAeich requested a review from uniqueg February 20, 2025 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

build: use Poetry and pyproject.toml
1 participant