Skip to content

Migrate CI dependency installation from pip to uv#338

Merged
AntObi merged 5 commits into
masterfrom
uv_ci
Dec 1, 2024
Merged

Migrate CI dependency installation from pip to uv#338
AntObi merged 5 commits into
masterfrom
uv_ci

Conversation

@AntObi

@AntObi AntObi commented Dec 1, 2024

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Introduced a new optional dependency group to enhance functionality with additional packages.
  • Improvements

    • Updated the CI workflow for clearer steps and improved caching for Python dependencies, enhancing efficiency in dependency management.

@AntObi AntObi added enhancement github_actions Pull requests that update GitHub Actions code labels Dec 1, 2024
@coderabbitai

coderabbitai Bot commented Dec 1, 2024

Copy link
Copy Markdown
Contributor

Walkthrough

The pull request introduces modifications to the CI workflow and updates to the pyproject.toml file. The CI workflow now includes clearer naming for steps, caching for Python dependencies, and a revised method for installing dependencies. In the pyproject.toml, a new optional dependency group has been added, and the existing strict dependency group has been updated with specific version constraints for various packages, enhancing dependency management.

Changes

File Change Summary
.github/workflows/ci.yml Renamed Checkout repository step; added caching for Python dependencies; modified dependency installation commands.
pyproject.toml Added new optional dependency group with specific packages; updated strict group with exact version constraints for several packages.

Possibly related PRs

  • Dependabot updates #298: The changes in this PR involve updates to dependency management, which aligns with the modifications made in the main PR regarding the installation and management of dependencies in the CI workflow.
  • Try MP_API_KEY in Github Actions #332: This PR also modifies the CI workflow configuration, specifically the .github/workflows/ci.yml file, which is directly related to the changes made in the main PR regarding the CI workflow setup.

Poem

In the meadow where bunnies play,
New dependencies hop in today.
With caching swift, our CI's bright,
Optional friends join the delight!
Hops of joy, with versions clear,
A project strong, we hold so dear! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a2ca918 and f59baf8.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/ci.yml

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 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 or @coderabbitai title 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (1)
pyproject.toml (1)

95-109: Consider reorganising dependency groups

The new optional group contains packages that overlap with existing groups like crystal_space, featurisers, and visualisation. Consider:

  1. Using the existing groups as building blocks for the optional group
  2. Defining the version constraints in a single location to avoid inconsistencies

Example reorganisation:

[project.optional-dependencies]
# Base groups with version constraints
crystal_space = [
    "mp-api==0.42.2",
    "ElementEmbeddings==0.6.1",
    "umap-learn==0.5.3",
    "kaleido==0.2.1",
    "pydantic==2.9.2"
]

# Combined groups
optional = [
    "crystal_space",
    "featurisers",
    "visualisation"
]
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 70122e8 and a2ca918.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml (1 hunks)
  • pyproject.toml (1 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
.github/workflows/ci.yml

[error] 41-41: trailing spaces

(trailing-spaces)

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

33-34: LGTM: Proper cache configuration

The cache configuration is correctly set up with pyproject.toml as the dependency path, which will improve CI performance by caching Python packages between runs.

Comment thread .github/workflows/ci.yml Outdated
Comment on lines +39 to +41
pip install uv
uv pip install -e ".[optional,dev]" --system

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider pinning uv version and fix whitespace

Whilst the migration to UV is a good improvement for faster dependency installation, consider:

  1. Pin the UV version for reproducible builds
  2. Remove the trailing whitespace on line 41

Apply this diff:

-          pip install uv
-          uv pip install -e ".[optional,dev]" --system
-  
+          pip install uv==0.1.5
+          uv pip install -e ".[optional,dev]" --system
📝 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
pip install uv
uv pip install -e ".[optional,dev]" --system
pip install uv==0.1.5
uv pip install -e ".[optional,dev]" --system
🧰 Tools
🪛 yamllint (1.35.1)

[error] 41-41: trailing spaces

(trailing-spaces)

Comment thread pyproject.toml
Comment on lines +95 to +109
optional = [
"pydantic>=2.9.2",
"mp-api>=0.42.2",
"pymatviz>=0.14",
"seaborn>=0.13.2",
"pymatgen>=2024.2.20",
"matminer>=0.9.2",
"umap-learn>=0.5.3",
"kaleido>=0.2.1",
"ase>=3.22.0",
"numpy",
"ElementEmbeddings>=0.4",
"dash>=2.18.2",

]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Version constraints in optional dependencies require adjustment

The codebase analysis reveals:

  • pymatgen is extensively used across the project, particularly in core functionality like structure prediction and screening
  • ElementEmbeddings is not directly imported, only referenced in a comment for an adapted function

Recommendations:

  • Align the optional pymatgen version (>=2024.2.20) closer to the strict version (==2024.11.13) to ensure consistent behaviour, suggest using >=2024.11.13
  • Remove ElementEmbeddings from optional dependencies as it's not actively used in the codebase
🔗 Analysis chain

Review version inconsistencies between optional and strict groups

There are notable version differences between the optional and strict groups:

  1. pymatgen: >=2024.2.20 vs ==2024.11.13
  2. ElementEmbeddings: >=0.4 vs ==0.6.1

These differences could lead to inconsistent behaviour between development and production environments.

Let's verify the compatibility of these versions:


Version differences between optional and strict dependencies need attention

The version history shows significant updates between the specified versions:

  • pymatgen: 20+ releases between 2024.2.20 and 2024.11.13
  • ElementEmbeddings: 4 releases between 0.4 and 0.6.1

Let's verify if these packages are actively used in the codebase to assess the impact:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for breaking changes in the version differences

# Check pymatgen releases between 2024.2.20 and 2024.11.13
curl -s https://pypi.org/pypi/pymatgen/json | jq -r '.releases | keys[]' | grep -E "2024\.(2|3|4|5|6|7|8|9|10|11)\.[0-9]+" | sort -V

# Check ElementEmbeddings releases between 0.4 and 0.6.1
curl -s https://pypi.org/pypi/ElementEmbeddings/json | jq -r '.releases | keys[]' | grep -E "0\.[4-6]" | sort -V

Length of output: 494


Script:

#!/bin/bash
# Check usage of pymatgen and ElementEmbeddings in the codebase
echo "=== pymatgen usage ==="
rg "import.*pymatgen" -A 2
rg "from pymatgen" -A 2

echo -e "\n=== ElementEmbeddings usage ==="
rg "import.*ElementEmbeddings" -A 2
rg "from ElementEmbeddings" -A 2

Length of output: 5785

@codecov

codecov Bot commented Dec 1, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 77.44%. Comparing base (70122e8) to head (f59baf8).
Report is 75 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #338   +/-   ##
=======================================
  Coverage   77.44%   77.44%           
=======================================
  Files          31       31           
  Lines        2589     2589           
=======================================
  Hits         2005     2005           
  Misses        584      584           

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

@AntObi AntObi merged commit 3062f8e into master Dec 1, 2024
@AntObi AntObi deleted the uv_ci branch December 1, 2024 17:00
KingaMas pushed a commit to KingaMas/SMACT that referenced this pull request Apr 25, 2025
Migrate CI dependency installation from pip to uv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant