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

Drop Python 3.9 support #178

Merged
merged 6 commits into from
Jan 9, 2025
Merged

Drop Python 3.9 support #178

merged 6 commits into from
Jan 9, 2025

Conversation

AntObi
Copy link
Collaborator

@AntObi AntObi commented Jan 9, 2025

Dropping Python 3.9 Support

Description

  • Dropped Python 3.9 support in the CI
  • Add Python 3.13 support in the AI
  • Port from setup.py to pyproject.toml
  • Add llvmlite>=0.40 as a requirement to handle umap/numba dependencies

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

  • Tests passed locally with changes
  • Tested installation without the setup.py file

Test Configuration:

  • Python version: 3.10
  • Operating System: macOS

Reviewers

N/A

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Summary by CodeRabbit

  • CI/CD Updates

    • Updated Python version matrix to include Python 3.13 and remove Python 3.9
    • Introduced uv for dependency management and package version checking
  • Project Configuration

    • Updated project metadata in pyproject.toml
    • Bumped project version to 0.6.1
    • Raised minimum Python version requirement to 3.10
    • Removed setup.py in favor of modern project configuration
  • Enhancements

    • Improved robustness of the standardise method in embedding classes to handle different lengths of input iterables without errors in multiple modules.
    • Updated plotting functionality to accommodate varying lengths of input data without errors.

Copy link

coderabbitai bot commented Jan 9, 2025

Warning

Rate limit exceeded

@AntObi has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 49 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 70f691d and e5ada19.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml (2 hunks)
  • pyproject.toml (1 hunks)

Walkthrough

The pull request introduces updates to the CI workflow and project configuration for the ElementEmbeddings project. Key changes include the transition from setup.py to pyproject.toml, the addition of Python 3.13 to the supported versions, and the integration of the uv package manager for dependency management. The pyproject.toml file has been enhanced with comprehensive project metadata, including required and optional dependencies, as well as updated linting configurations.

Changes

File Change Summary
.github/workflows/ci.yml - Updated Python version matrix (removed 3.9, added 3.13)
- Replaced pip with uv for dependency installation and version checking
pyproject.toml - Added comprehensive project metadata
- Updated build system requirements to specify setuptools>=65.0.0
- Defined project dependencies with version constraints
- Added optional dependencies for dev and docs
- Updated Ruff target version to Python 3.10
setup.py - File deleted, replaced by pyproject.toml configuration
src/elementembeddings/_base.py - Modified standardise method to include strict=False in zip function
src/elementembeddings/core.py - Modified standardise method to include strict=False in zip function
src/elementembeddings/plotter.py - Modified species_labels list comprehension to include strict=False in zip function

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant CI as GitHub Actions
    participant UV as UV Package Manager
    participant Python as Python Interpreter

    Dev->>CI: Trigger Workflow
    CI->>Python: Select Python Version (3.10-3.13)
    CI->>UV: Upgrade UV
    UV->>CI: Install Dependencies
    CI->>UV: Check Package Versions
    UV->>CI: Return Version Information
Loading

Poem

🐰 A Rabbit's Ode to Workflow Delight 🚀

Versions dance, from nine to thirteen,
UV's magic makes our pipeline clean.
Dependencies leap with newfound grace,
Configuration finds its rightful place.
Hop along, code's evolutionary might! 🌟

Finishing Touches

  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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: 2

🧹 Nitpick comments (3)
.github/workflows/ci.yml (1)

37-39: Consider adding version output to package checks

The package version checks could be more informative by capturing the actual versions.

-          uv pip show -V elementembeddings
-          uv pip show -V pytest
-          uv pip show -V matplotlib
+          uv pip show elementembeddings | grep -E "^Version|^Name"
+          uv pip show pytest | grep -E "^Version|^Name"
+          uv pip show matplotlib | grep -E "^Version|^Name"
pyproject.toml (2)

3-3: Consider using newer setuptools version

The current minimum version might be outdated. Recent versions have important fixes and improvements.

-requires = ["setuptools>=65.0.0"]  # PEP 508 specifications.
+requires = ["setuptools>=68.0.0"]  # PEP 508 specifications.

44-56: Consider adding pytest-xdist for parallel testing

The dev dependencies look comprehensive, but adding pytest-xdist could speed up the test execution in CI.

dev = [
    "pre-commit",
    "black",
    "isort",
    "pytest",
    "pytest-subtests",
+   "pytest-xdist",
    "nbqa",
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4abe5ac and 73d7b72.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml (2 hunks)
  • pyproject.toml (1 hunks)
  • setup.py (0 hunks)
💤 Files with no reviewable changes (1)
  • setup.py
🧰 Additional context used
🪛 GitHub Actions: ElementEmbeddings CI
.github/workflows/ci.yml

[warning] 20-20: Formatting issue: Missing space after comma in python-version array

🔇 Additional comments (3)
.github/workflows/ci.yml (1)

33-34: Verify uv package manager compatibility

The switch to using uv package manager is a significant change. While it can improve installation speed, we should ensure it's compatible across all platforms.

Run this script to check uv compatibility with the project's dependencies:

✅ Verification successful

UV package manager is compatible with the project

The project uses standard dependency specifications and platform-independent packages from PyPI, making it fully compatible with the UV package manager. The switch to UV is safe as it supports all required features including editable installs and PEP 508 version specifiers.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify uv compatibility with project dependencies
# Test: Check if uv can resolve all dependencies without conflicts

# Get list of dependencies from pyproject.toml
rg -A 1 '^\[project\]' pyproject.toml -B 1 | rg 'dependencies'

Length of output: 62


Script:

#!/bin/bash
# Find Python dependency management files
echo "=== Searching for dependency files ==="
fd -e toml -e txt -e ini . | grep -iE 'pyproject|requirements|setup|pip'

echo -e "\n=== Examining pyproject.toml if exists ==="
fd pyproject.toml -x cat {}

echo -e "\n=== Examining requirements files if exist ==="
fd requirements -e txt -x cat {}

echo -e "\n=== Checking for platform-specific configurations ==="
rg -i "platform|system|windows|linux|darwin" -g "pyproject.toml" -g "requirements*.txt" -g "setup.{py,cfg}"

Length of output: 8944

pyproject.toml (2)

69-71: ⚠️ Potential issue

Update semantic_release configuration

The version_variable still references setup.py which has been removed.

-version_variable = "setup.py:__version__"
+version_variable = "pyproject.toml:project.version"

Likely invalid or redundant comment.


29-41: Review dependency version constraints

The dependency specifications need attention:

  1. Consider adding upper bounds for more dependencies to prevent breaking changes
  2. Verify if llvmlite>=0.40 is sufficient for umap and numba compatibility

Run this script to check for potential version conflicts:

@@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12","3.13"]
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix formatting: Add space after comma in python-version array

Add a space after the comma before "3.13" to maintain consistent formatting.

-        python-version: ["3.10", "3.11", "3.12","3.13"]
+        python-version: ["3.10", "3.11", "3.12", "3.13"]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
python-version: ["3.10", "3.11", "3.12","3.13"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
🧰 Tools
🪛 GitHub Actions: ElementEmbeddings CI

[warning] 20-20: Formatting issue: Missing space after comma in python-version array

version = "0.6.1"
description = "Element Embeddings"
readme = "README.md"
requires-python = ">=3.10"
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Dependencies not ready for Python 3.13

While the project declares Python 3.13 support, several key dependencies don't explicitly support Python 3.13 yet:

  • pymatgen (up to 3.12)
  • seaborn (up to 3.12)
  • umap-learn (up to 3.12)
  • llvmlite (up to 3.12)
  • adjustText (no version info)
  • openTSNE (generic Python 3)

Consider removing Python 3.13 from classifiers until these dependencies add support for it.

🔗 Analysis chain

Verify Python version compatibility

The Python version requirement and classifiers align with dropping Python 3.9 support. However, ensure all dependencies support Python 3.13.

Run this script to check dependency compatibility with Python 3.13:

Also applies to: 16-21

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check dependency compatibility with Python 3.13
# Test: Extract dependencies and check their Python version support

# Get all dependencies
rg '^    "[^"]+[>=<]+[0-9.]+' pyproject.toml | while read -r dep; do
    pkg=$(echo "$dep" | sed 's/^    "\([^"]*\)[>=<].*/\1/')
    echo "Checking $pkg..."
    curl -s "https://pypi.org/pypi/$pkg/json" | jq -r '.info.classifiers[] | select(contains("Programming Language :: Python"))'
done

Length of output: 3305


Script:

#!/bin/bash
# Description: Check dependency compatibility with Python 3.13 (fixed version)
# Get all dependencies including optional ones
rg '^    "[^"]+"' pyproject.toml | sed 's/^    "\([^"]*\).*/\1/' | while read -r pkg; do
    # Skip empty lines and section headers
    if [[ -z "$pkg" || "$pkg" == "["* ]]; then
        continue
    fi
    echo "Checking $pkg..."
    curl -s "https://pypi.org/pypi/${pkg%,}/json" | jq -r '.info.classifiers[] | select(contains("Programming Language :: Python :: 3"))'
done

Length of output: 32163


Script:

#!/bin/bash
# Description: Check dependency compatibility with Python 3.13 (improved version)
# Get dependencies section only
echo "Main dependencies:"
rg '^\[project\.dependencies\]' -A 50 pyproject.toml | while read -r line; do
    if [[ $line == "["* && $line != "[project.dependencies]" ]]; then
        break
    fi
    if [[ $line =~ ^\"([^\"]+)\" ]]; then
        pkg="${BASH_REMATCH[1]}"
        echo "Checking $pkg..."
        curl -s "https://pypi.org/pypi/$pkg/json" | jq -r '.info.classifiers[] | select(contains("Programming Language :: Python :: 3"))'
        echo "---"
    fi
done

Length of output: 116


Script:

#!/bin/bash
# First, let's see the content structure
echo "File content:"
cat pyproject.toml
echo -e "\n=== Now checking dependencies ===\n"
# Extract dependencies using a simpler pattern
cat pyproject.toml | awk '/^dependencies = \[/,/\]/' | grep '"' | tr -d '", ' | while read -r pkg; do
    if [[ $pkg == *"="* ]]; then
        pkg=${pkg%%=*}
    fi
    if [[ -n $pkg ]]; then
        echo "Checking $pkg..."
        curl -s "https://pypi.org/pypi/$pkg/json" | jq -r '.info.classifiers[] | select(contains("Programming Language :: Python :: 3"))'
        echo "---"
    fi
done

Length of output: 11297


Script:

#!/bin/bash
# Check main dependencies for Python 3.13 support
echo "Checking core dependencies for Python 3.13 support:"
for pkg in numpy scipy pymatgen seaborn matplotlib scikit-learn umap-learn adjustText openTSNE typing-extensions llvmlite; do
    echo "=== Checking $pkg ==="
    curl -s "https://pypi.org/pypi/$pkg/json" | jq -r '.info.classifiers[] | select(contains("Programming Language :: Python :: 3"))'
    echo "---"
done

Length of output: 5712

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)
src/elementembeddings/core.py (1)

Line range hint 170-170: Consider centralizing Python version compatibility handling.

The current changes add strict=False to multiple zip calls across different files. Consider:

  1. Creating a utility function that wraps zip with version-specific defaults
  2. Adding version compatibility settings in a central configuration
  3. Documenting the minimum Python version requirements

This would make future version-specific changes easier to manage.

Also applies to: 258-258, 179-179

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 73d7b72 and 70f691d.

📒 Files selected for processing (4)
  • .github/workflows/ci.yml (2 hunks)
  • src/elementembeddings/_base.py (1 hunks)
  • src/elementembeddings/core.py (1 hunks)
  • src/elementembeddings/plotter.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/ci.yml
🔇 Additional comments (3)
src/elementembeddings/plotter.py (1)

179-179: LGTM! Proactive compatibility fix for Python 3.13.

The addition of strict=False maintains the current behavior where zip handles mismatched lengths gracefully. This is important for processing species labels that may have different lengths.

src/elementembeddings/_base.py (1)

170-170: Verify data integrity in standardization process.

While adding strict=False maintains compatibility with Python 3.13, the standardization process should maintain a 1:1 mapping between keys and embeddings. Consider adding validation to ensure data integrity.

Run this script to verify the embeddings integrity:

✅ Verification successful

Data integrity is maintained in standardization process

The implementation guarantees that the number of keys and embeddings remain equal throughout the transformation. The strict=False parameter is safe here as both sequences in the zip operation originate from the same dictionary, and the numpy operations preserve the array length.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that embeddings dictionary keys match the number of embedding arrays
# Test: Search for instances where embeddings dictionary is modified
# Expect: Equal length checks or similar validation

ast-grep --pattern 'embeddings_copy = self.embeddings.copy()
    $$$
    embeddings_array = np.array(list(embeddings_copy.values()))
    $$$'

Length of output: 143


Script:

#!/bin/bash
# Search for the standardize method implementation
ast-grep --pattern 'def standardise($$$):
    $$$'

# Also search with alternative spelling
ast-grep --pattern 'def standardize($$$):
    $$$'

# Backup search using ripgrep for context
rg "def standard" -A 10

Length of output: 4065

src/elementembeddings/core.py (1)

258-258: LGTM! Maintains consistency with base class.

The addition of strict=False aligns with the base class implementation. Consider implementing the same data integrity validation suggested for the base class.

@AntObi AntObi merged commit 4154323 into main Jan 9, 2025
10 of 11 checks passed
@AntObi AntObi deleted the bump_python branch January 9, 2025 15:41
Copy link

codecov bot commented Jan 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.95%. Comparing base (cb93b20) to head (e5ada19).
Report is 23 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #178   +/-   ##
=======================================
  Coverage   90.95%   90.95%           
=======================================
  Files          12       12           
  Lines        1294     1294           
=======================================
  Hits         1177     1177           
  Misses        117      117           

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

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