Skip to content

Sd2 1247 migrate pp from pip to poetry try upgrading packages #340

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

Conversation

KyrianC
Copy link
Collaborator

@KyrianC KyrianC commented Mar 20, 2025

to update version we can run:
poetry version + one of patch, minor, major, prepatch, preminor, premajor, prerelease to bump the version in pyproject.toml, then create git tag

Summary by CodeRabbit

  • New Features
    • Introduced a new function for creating a Natural Language Understanding client with updated authentication.
  • Refactor
    • Improved IBM service integration with a streamlined client setup and enhanced error handling.
  • Chores
    • Revamped project configuration with updated metadata, an increased Python version requirement (≥3.11), and a transition to Poetry for dependency management.
    • Removed legacy dependency tracking files for a cleaner setup.
    • Updated CI/CD workflows to utilize Poetry for dependency installation.
    • Adjusted GitHub Actions workflow to include Poetry installation and updated Python version.

Copy link

coderabbitai bot commented Mar 20, 2025

Walkthrough

The modifications update the IBM API integration and project configuration. A new function, text_client, is introduced in the IBM config to create a NaturalLanguageUnderstandingV1 client using IAMAuthenticator, and related calls in ibm_clients are updated. The exception handling in ibm_helpers.py now imports and catches ApiException from ibm_watson. Additionally, pyproject.toml has been overhauled with updated project metadata, dependencies, and a higher Python version requirement, while both requirements.in and requirements.txt have been completely removed.

Changes

Files Change Summary
edenai_apis/apis/ibm/config.py Added text_client function to encapsulate client creation using IAMAuthenticator and updated ibm_clients to call this new function.
edenai_apis/apis/ibm/ibm_helpers.py Updated import and exception handling: replaced WatsonApiException from watson_developer_cloud with ApiException from ibm_watson.
pyproject.toml Revised project metadata with updated project name (edenai-apis), Python requirement (>=3.11), license filename, and added a new Poetry section including dependencies and build system updates.
requirements.in & requirements.txt Removed all dependency listings; both files have been eliminated, reflecting a shift in dependency management away from these requirement files.
.circleci/config.yml Modified CircleCI configuration to install Poetry and update dependency installation commands from pip to Poetry.
.github/workflows/test.yml Updated GitHub Actions workflow to change Python version to 3.12, added Poetry installation step, and replaced pip dependency installation with Poetry.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client Code
    participant IBMC as ibm_clients
    participant TC as text_client
    participant IAM as IAMAuthenticator
    participant NLU as NaturalLanguageUnderstandingV1

    Client->>IBMC: Request IBM API client
    IBMC->>TC: Call text_client(api_key, version, service_url)
    TC->>IAM: Initialize IAMAuthenticator with api_key
    IAM-->>TC: Return IAM authenticator
    TC->>NLU: Create NaturalLanguageUnderstandingV1 with authenticator & service_url
    NLU-->>TC: Return configured NLU client
    TC-->>IBMC: Return NLU client instance
    IBMC-->>Client: Return IBM API client
Loading

Poem

I'm a bunny with a coder’s cheer,
Hopping through code both far and near.
With text_client lighting up my day,
And exceptions handled in a clever way.
I nibble on carrots, optimizing as I run,
Celebrating clean code under the digital sun!
(_/),🥕, Coding fun!


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🔭 Outside diff range comments (2)
pyproject.toml (2)

37-38: 🛠️ Refactor suggestion

Dynamic dependencies configuration will be ignored

The [tool.setuptools.dynamic] section is trying to load dependencies from "requirements.txt", but you've migrated to Poetry for dependency management. This section is now redundant as Poetry will use the dependencies specified in the [tool.poetry.dependencies] section.

-[tool.setuptools.dynamic]
-dependencies = {file = ["requirements.txt"]}

14-16: 💡 Verification agent

🧩 Analysis chain

Inconsistency between Python version requirement and classifiers

The requires-python field specifies ">=3.11", but the classifiers list Python 3.8, 3.9, and 3.10 compatibility. This inconsistency should be addressed.


🏁 Script executed:

#!/bin/bash
# Check if there are any Python files that might not be compatible with Python 3.11
# Look for syntax or features that were deprecated or changed between Python 3.8-3.10 and 3.11

echo "Python version requirement in pyproject.toml: >=3.11"
echo "Classifiers in pyproject.toml mention Python 3.8, 3.9, and 3.10"
echo "Checking for potential compatibility issues..."

# Check for uses of deprecated features in Python 3.11
echo "Searching for uses of deprecated features in Python 3.11..."
rg -l "collections\.Mapping" || echo "No uses of collections.Mapping found (deprecated in 3.11)"
rg -l "from distutils\." || echo "No uses of distutils found (deprecated in 3.11)"
rg -l "asyncio\.coroutine" || echo "No uses of asyncio.coroutine found (deprecated in 3.11)"

# Check for Python version imports or version checks
echo "Checking for Python version-specific code..."
rg "import sys" -A 2 -B 2 | rg "sys\.version" || echo "No explicit version checks found"

echo "Consider updating the classifiers to match the requires-python field"

Length of output: 1290


Update Python Classifiers in pyproject.toml to Reflect the Actual Version Requirement

  • The requires-python field specifies ">=3.11", while the classifiers still list support for Python 3.8, 3.9, and 3.10.
  • The verification script confirmed that no deprecated features or explicit version checks are present, so the issue is solely with the classifier definitions.
  • Please update the classifiers (lines 14-16 in pyproject.toml) to include supported versions starting from Python 3.11 (and above, as applicable) to ensure consistency.
🧹 Nitpick comments (3)
edenai_apis/apis/ibm/config.py (1)

3-3: Remove unused import

BearerTokenAuthenticator is imported but not used anywhere in the code.

-from ibm_cloud_sdk_core.authenticators import BearerTokenAuthenticator, IAMAuthenticator
+from ibm_cloud_sdk_core.authenticators import IAMAuthenticator
🧰 Tools
🪛 Ruff (0.8.2)

3-3: ibm_cloud_sdk_core.authenticators.BearerTokenAuthenticator imported but unused

Remove unused import: ibm_cloud_sdk_core.authenticators.BearerTokenAuthenticator

(F401)

pyproject.toml (2)

65-78: Duplicate project metadata

There's duplication between the [project] and [tool.poetry] sections, which can lead to confusion and maintenance issues. Consider consolidating this information to avoid inconsistencies.

You have two options:

  1. Keep only the [tool.poetry] section and remove the [project] section if you're using Poetry exclusively
  2. Keep both but ensure they're consistent and document the reason for having both

Since Poetry is now your build system, option 1 is recommended unless you have specific needs for the PEP 621 style metadata.


80-135: Comprehensive dependency specification

The dependencies are now well specified with version constraints, which is good practice. However, there are a lot of dependencies, and some might not be necessary for all users.

Consider organizing dependencies into groups using Poetry's [tool.poetry.group.<name>.dependencies] feature. For example:

[tool.poetry.group.dev.dependencies]
pylint = "^3.3.5"
mypy = "^1.15.0"
pytest = "^7.4.4"
pytest-mock = "^3.14.0"
pytest-cov = "^6.0.0"
pytest-xdist = "^3.6.1"
pytest-timeout = "^2.3.1"

[tool.poetry.group.docs.dependencies]
sphinx = "^8.2.3"
furo = "^2024.8.6"

This would allow users to install only what they need with commands like poetry install --only main or poetry install --with dev.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a8058f1 and 910594e.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • edenai_apis/apis/ibm/config.py (1 hunks)
  • edenai_apis/apis/ibm/ibm_helpers.py (2 hunks)
  • pyproject.toml (2 hunks)
  • requirements.in (0 hunks)
  • requirements.txt (0 hunks)
💤 Files with no reviewable changes (2)
  • requirements.txt
  • requirements.in
🧰 Additional context used
🪛 Ruff (0.8.2)
edenai_apis/apis/ibm/config.py

3-3: ibm_cloud_sdk_core.authenticators.BearerTokenAuthenticator imported but unused

Remove unused import: ibm_cloud_sdk_core.authenticators.BearerTokenAuthenticator

(F401)

🔇 Additional comments (5)
edenai_apis/apis/ibm/ibm_helpers.py (1)

1-1: Correctly updated IBM Watson import and exception handling

The import statement and exception handling have been properly updated to use ApiException from ibm_watson instead of the previous WatsonApiException from watson_developer_cloud.watson_service. This change aligns with the migration to newer IBM Watson APIs.

Also applies to: 14-14

edenai_apis/apis/ibm/config.py (2)

7-15: Well-designed encapsulation of client creation

The new text_client function nicely encapsulates the creation of a NaturalLanguageUnderstandingV1 client. This improves code organization and maintainability by isolating the client creation logic.


20-24: Updated client instantiation approach

The code properly updates the client instantiation to use the new text_client function, which leverages the IAMAuthenticator for authentication instead of the previous iam_apikey approach.

pyproject.toml (2)

2-2: Update project metadata

The project name has been updated to "edenai-apis" and the Python version requirement has been increased to ">=3.11". The license file name has also been corrected to "LICENSE".

Also applies to: 6-7


137-139: Appropriate build system configuration

The build system configuration is correct for a Poetry project.

Copy link
Contributor

@juandavidcruzgomez juandavidcruzgomez left a comment

Choose a reason for hiding this comment

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

I think you need to update the .github/workflows/test.yml because it's still looking for requirements.txt

@juandavidcruzgomez juandavidcruzgomez self-requested a review March 24, 2025 08:33
KyrianC added 3 commits March 24, 2025 10:22
…ckages' of github.com:edenai/edenai-apis into SD2-1247-migrate-pp-from-pip-to-poetry-try-upgrading-packages
@KyrianC KyrianC force-pushed the SD2-1247-migrate-pp-from-pip-to-poetry-try-upgrading-packages branch from 6eb4176 to 0f79194 Compare March 24, 2025 09:39
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
.github/workflows/test.yml (2)

1-1: File Naming Consistency:

The header comment on line 1 indicates # .github/workflows/app.yaml while the file is named .github/workflows/test.yml. Please update the header comment (or the filename) so that they consistently reflect the intended file name.


30-34: Install Poetry Step:

The addition of the "Install Poetry" step using the official installation script is well implemented. As a best practice, consider verifying the integrity/authenticity of the script, if deemed necessary, and confirm that appending "$HOME/.local/bin" to $GITHUB_PATH consistently exposes Poetry on the runner's PATH.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between 622e909 and 41c1cfb.

⛔ Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock
📒 Files selected for processing (1)
  • .github/workflows/test.yml (1 hunks)
🔇 Additional comments (3)
.github/workflows/test.yml (3)

28-29: Python Version Upgrade:

The Python version has been updated to "3.12". Ensure that all project dependencies and tests are compatible with Python 3.12.


35-36: Clear Poetry Cache:

Clearing the Poetry cache before installing dependencies is a solid approach to prevent issues from stale or corrupted cache data.


42-42: Switch to Poetry Dependency Installation:

Replacing the pip-based dependency installation with poetry install --no-interaction --no-root aligns well with the PR’s objective to migrate to Poetry. Confirm that this change meets all dependency resolution requirements across environments.

@KyrianC KyrianC force-pushed the SD2-1247-migrate-pp-from-pip-to-poetry-try-upgrading-packages branch from 41c1cfb to 57f5045 Compare March 24, 2025 10:39
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
.github/workflows/test.yml (1)

36-40: Debugging Configuration Files

The "Debug" step outputs the contents of pyproject.toml and poetry.lock, aiding in troubleshooting and verification of configuration changes. Ensure that this debugging output is acceptable (i.e., no sensitive information is exposed) and consider removing or conditioning it for production environments if not needed permanently.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between 57f5045 and c4052dd.

📒 Files selected for processing (1)
  • .github/workflows/test.yml (1 hunks)
🔇 Additional comments (4)
.github/workflows/test.yml (4)

28-29: Python Version Upgrade to 3.12

The workflow now uses Python 3.12. Please verify that all project dependencies, scripts, and tests are compatible with this version to avoid runtime issues.


30-34: Installation of Poetry

A new step to install Poetry using the official installation script has been added. The configuration appends Poetry’s installation path to the system PATH, ensuring it’s available for subsequent steps. This change aligns with the PR objective of migrating dependency management to Poetry.


41-42: Clearing Poetry Cache

Clearing the Poetry cache (for the PyPI repository) is a useful step to prevent dependency conflicts during installation. Confirm that this step does not introduce significant delays in the CI process over repeated builds.


48-48: Switch to Poetry for Dependency Installation

Replacing the pip-based dependency installation with poetry install --no-interaction --no-root is consistent with the move to Poetry. Ensure that the poetry.lock file is up-to-date and version-controlled for reproducible builds.

@KyrianC KyrianC force-pushed the SD2-1247-migrate-pp-from-pip-to-poetry-try-upgrading-packages branch from c4052dd to b3a0ec2 Compare March 24, 2025 13:04
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
.github/workflows/test.yml (1)

47-47: Install Dependencies with Poetry
Changing the dependency installation command to poetry install --no-interaction --no-root correctly leverages the Poetry-managed dependency tree. As an enhancement, consider caching the Poetry dependencies to further optimize build times in CI.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Lite

📥 Commits

Reviewing files that changed from the base of the PR and between c4052dd and b3a0ec2.

📒 Files selected for processing (1)
  • .github/workflows/test.yml (1 hunks)
🔇 Additional comments (4)
.github/workflows/test.yml (4)

28-28: Update Python Version to 3.12
The workflow now uses Python 3.12. Please ensure that the entire codebase and all dependencies are compatible with this new version to prevent runtime issues.


30-34: Install Poetry Setup
The addition of the "Install Poetry" step is well implemented. Installing Poetry via the official installation script and appending its binary path to the system PATH aligns with our migration from pip to Poetry. Consider optionally verifying the Poetry version post-installation if you need to enforce a minimum version requirement.


36-39: Debug Step for pyproject.toml
Introducing a debug step to output the differences in pyproject.toml is a useful troubleshooting aid. It helps quickly confirm that version bumps or dependency changes are being applied as expected.


40-41: Clear Poetry Cache
Clearing the Poetry cache for PyPI before dependency installation can prevent issues with stale packages. This step is appropriate given the shift to Poetry and will help maintain clean dependency installations.

@juandavidcruzgomez juandavidcruzgomez merged commit cd33f62 into master Mar 24, 2025
3 of 4 checks passed
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.

2 participants