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

[f] Upgrade Python version from 3.9 to 3.11 #13

Merged
merged 1 commit into from
Oct 31, 2024

Conversation

lamle-ea
Copy link
Contributor

@lamle-ea lamle-ea commented Oct 31, 2024

Description

  • Upgrade Python version from 3.9 to 3.11 to resolve the conflict dependencies.

Summary by CodeRabbit

  • New Features

    • Updated the minimum required Python version to 3.11 across workflows and project configurations.
  • Bug Fixes

    • Ensured compatibility with Python 3.11 in various workflows, enhancing stability and performance.

Copy link

coderabbitai bot commented Oct 31, 2024

Walkthrough

The pull request introduces updates to the Python version across multiple GitHub Actions workflow files and the Pipfile. Specifically, the Python version has been changed from 3.9 to 3.11 in the .github/workflows/archive.yml, .github/workflows/ci.yml, and .github/workflows/cron.yml files, as well as in the Pipfile. These modifications ensure that the workflows and project dependencies utilize Python 3.11 moving forward.

Changes

File Path Change Summary
.github/workflows/archive.yml Updated PYTHON_VERSION from 3.9 to 3.11.
.github/workflows/ci.yml Updated python-version in job matrix from 3.9 to 3.11.
.github/workflows/cron.yml Updated PYTHON_VERSION from 3.9 to 3.11.
Pipfile Updated python_version from "3.9" to "3.11".

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CI
    participant Archive
    participant Cron
    participant Pipfile

    User->>CI: Trigger CI workflow
    CI->>CI: Set up Python 3.11
    CI->>Archive: Run Archive workflow
    Archive->>Archive: Set up Python 3.11
    Archive->>Cron: Run Cron workflow
    Cron->>Cron: Set up Python 3.11
    Pipfile->>Pipfile: Update Python version to 3.11
Loading

Poem

In the garden where bunnies play,
Python's grown a brand new way.
From three point nine to three point eleven,
Our scripts now dance like clouds in heaven.
Hops and skips, with joy we sing,
Celebrate the change that autumn brings! 🐇✨


🪧 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: 1

🧹 Outside diff range and nitpick comments (2)
Pipfile (1)

Line range hint 1-23: Consider pinning dependency versions for better reproducibility.

Most of your dependencies use "*" which could lead to unexpected breaking changes. Consider pinning versions, especially for critical dependencies like scrapy and scrapy-wayback-middleware.

Example of pinned versions:

[packages]
-scrapy = "*"
+scrapy = "~=2.11.0"
scrapy-sentry-errors = "1.0.0"
city-scrapers-core = {ref = "main", git = "https://github.com/City-Bureau/city-scrapers-core.git", extras = ["azure"]}
-scrapy-wayback-middleware = "*"
+scrapy-wayback-middleware = "~=0.3.0"
-python-dateutil = "*"
+python-dateutil = "~=2.8.2"
-importlib-resources = "*"
+importlib-resources = "~=6.1.1"
-pdfminer-six = "*"
+pdfminer-six = "~=20221105"
.github/workflows/cron.yml (1)

10-10: LGTM! Python 3.11 upgrade looks good.

The upgrade to Python 3.11 is a good choice as it brings significant performance improvements, especially for CPU-intensive tasks like web scraping. The version is consistently referenced throughout the workflow.

You might see improved scraping performance due to Python 3.11's optimizations, particularly:

  • Up to 10-60% faster CPU-intensive tasks
  • Improved error messages
  • Enhanced typing system
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f93cc6f and c512d27.

⛔ Files ignored due to path filters (1)
  • Pipfile.lock is excluded by !**/*.lock
📒 Files selected for processing (4)
  • .github/workflows/archive.yml (1 hunks)
  • .github/workflows/ci.yml (1 hunks)
  • .github/workflows/cron.yml (1 hunks)
  • Pipfile (1 hunks)
🔇 Additional comments (6)
Pipfile (1)

23-23: LGTM on Python version upgrade!

The upgrade to Python 3.11 is a good choice as it offers significant performance improvements over 3.9.

Let's verify the compatibility of city-scrapers-core with Python 3.11:

✅ Verification successful

Python 3.11 upgrade is compatible with dependencies

The verification shows that city-scrapers-core supports Python versions >=3.6,<4.0, which includes Python 3.11. The package's dependencies (jsonschema, pytz, requests, scrapy) are all mature packages with Python 3.11 support.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if city-scrapers-core main branch supports Python 3.11
gh repo clone City-Bureau/city-scrapers-core
cd city-scrapers-core
rg -l "python_version|Python" setup.py pyproject.toml

Length of output: 234


Script:

#!/bin/bash
# Check the content of setup.py to verify Python version requirements
cat city-scrapers-core/setup.py

Length of output: 1160

.github/workflows/archive.yml (2)

Line range hint 31-35: Cache configuration looks good

The cache key properly includes the Python version, which will automatically invalidate caches when switching between Python versions. This ensures clean dependency installations.


10-10: LGTM! Verify dependency compatibility with Python 3.11

The Python version upgrade to 3.11 is a good move as it brings performance improvements and new features. However, we should ensure all dependencies are compatible with Python 3.11.

Let's verify the dependencies compatibility:

✅ Verification successful

Python 3.11 upgrade is compatible with all dependencies

The verification shows that:

  • All dependencies in Pipfile are specified with flexible version constraints (*) except black==22.6
  • Core dependencies like scrapy, python-dateutil, and others don't have Python version constraints
  • Requirements files show compatible versions of common packages
  • No Python version-specific dependencies or markers are found that would conflict with Python 3.11
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check Pipfile.lock for any potential compatibility issues with Python 3.11

# Test: Look for any version constraints or Python version specifications in Pipfile
cat Pipfile | grep -A 5 "python_version"

# Test: Check if there are any known problematic dependencies
cat Pipfile.lock | jq -r '.default | keys[]' | while read pkg; do
  echo "Checking $pkg..."
  rg --type=yaml "package: $pkg" -A 5 -g "*.yml"
done

Length of output: 228


Script:

#!/bin/bash
# Let's verify Python dependencies and their compatibility

# Check Pipfile for Python version and dependencies
echo "=== Checking Pipfile ==="
cat Pipfile

# Check if there are any Python version specific dependencies or markers
echo -e "\n=== Checking requirements files ==="
fd "requirements.*\.txt$" --exec cat {}

# Check workflow files for any Python package installation steps
echo -e "\n=== Checking workflow files for package installation ==="
fd "\.yml$" --type f -E "**/node_modules/**" -E "**/.git/**" --exec grep -l "pip install\|poetry install\|pipenv install" {} \; | while read -r file; do
    echo "=== $file ==="
    cat "$file"
done

Length of output: 1157

.github/workflows/cron.yml (2)

Line range hint 39-43: Verify cache behavior after Python version upgrade.

The cache key strategy is well-implemented, using both Python version and Pipfile.lock for specificity. The version change will naturally invalidate old caches, ensuring clean dependency installation.

Let's verify the Pipfile.lock compatibility:

✅ Verification successful

Cache configuration is correctly aligned with Python version requirements

The verification confirms that the Pipfile.lock specifies Python 3.11, which matches the cache key strategy in the workflow. The cache invalidation will work as expected when Python versions change.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check if Pipfile.lock exists and verify its Python version requirement

# Test: Check if Pipfile.lock exists and contains Python 3.11
if [ -f "Pipfile.lock" ]; then
    echo "Checking Pipfile.lock Python version..."
    jq -r '."_meta".requires.python_version' Pipfile.lock
fi

# Test: Look for any version-specific dependencies
rg -l "python_version" Pipfile.lock

Length of output: 224


Line range hint 52-56: Consider adjusting scraper concurrency settings.

With Python 3.11's improved performance, you might want to experiment with the AUTOTHROTTLE_TARGET_CONCURRENCY setting (currently set to 3.0 in the environment variables) to potentially handle more concurrent requests.

Let's check the current concurrency settings:

.github/workflows/ci.yml (1)

18-18: LGTM! Verify dependency compatibility with Python 3.11

The Python version upgrade looks good. The workflow configuration properly handles the new version through the matrix strategy and cache keys.

Let's verify the project's dependencies are compatible with Python 3.11:

✅ Verification successful

All dependencies are compatible with Python 3.11

Based on the Pipfile.lock analysis:

  • All production dependencies have version constraints that include Python 3.11
  • Development dependencies (black, flake8, pytest, etc.) also support Python 3.11
  • No packages have upper version bounds that would conflict with Python 3.11
  • The only package with a potential constraint is zipp which is only required for Python < 3.10, but this is not an issue for 3.11
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check Pipfile.lock for any potential Python 3.11 compatibility issues

# Test: Look for any version constraints or Python requirements in Pipfile
rg -A 5 'python_version|requires' Pipfile

# Test: Check Pipfile.lock for any packages with Python version constraints
rg -A 5 '"markers"|"python_version"' Pipfile.lock

Length of output: 15973

@@ -15,7 +15,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.9]
python-version: [3.11]
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider adding explicit Python compatibility checks

To ensure a smooth transition to Python 3.11, consider adding checks for Python 3.11 syntax compatibility.

Add a step to verify Python compatibility:

      - name: Lint with flake8
        run: |
          pipenv run flake8 .

+      - name: Check Python compatibility
+        run: |
+          pipenv install pyupgrade
+          pipenv run pyupgrade --py311-plus **/*.py
+
      - name: Test with pytest

Committable suggestion was skipped due to low confidence.

@lamle-ea lamle-ea merged commit aaa6fd5 into main Oct 31, 2024
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.

1 participant