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

Provide control over uv cache key #153

Closed
pvardanis opened this issue Nov 14, 2024 · 2 comments
Closed

Provide control over uv cache key #153

pvardanis opened this issue Nov 14, 2024 · 2 comments

Comments

@pvardanis
Copy link

pvardanis commented Nov 14, 2024

I work on a monorepo with multiple python projects each with its own uv.lock file. I want to be able to cache uv with a name that indicates the package name so I can be able to cache it only when needed, and also to avoid overwriting cached files that belong to different python projects. Currently it's not possible or am I missing something?

@eifinger
Copy link
Collaborator

eifinger commented Nov 14, 2024

Lets assume the following layout (based on uv workspace docs):

albatross
├── packages
│   ├── bird-feeder
│   │   ├── pyproject.toml
│   │   ├── uv.lock
│   │   └── src
│   │       └── bird_feeder
│   │           ├── __init__.py
│   │           └── foo.py
│   └── seeds
│       ├── pyproject.toml
│       ├── uv.lock
│       └── src
│           └── seeds
│               ├── __init__.py
│               └── bar.py
└── README.md

If you want to work with the bird-feeder project you can use:

- name: Use the bird-feeder cache
  id: setup-uv
  uses: astral-sh/setup-uv@v3
  with:
    enable-cache: true
    cache-suffix: "bird-feeder"
    cache-dependency-glob: "**/bird-feeder/uv.lock"

If you want to work with the seeder project you can use:

- name: Use the seeder cache
  id: setup-uv
  uses: astral-sh/setup-uv@v3
  with:
    enable-cache: true
    cache-suffix: "seeder"
    cache-dependency-glob: "**/seeder/uv.lock"

If you want a cache that gets invalidated when any of the two changes:

- name: Invalidate the cache when either project changes
  id: setup-uv
  uses: astral-sh/setup-uv@v3
  with:
    enable-cache: true
    cache-dependency-glob: "**/uv.lock"

It might be easier to maintain to just have a single cache for the whole monorepo and live with the fact that it might always contain dependency DepA even though it is only used in one project.

Based on the differences between the dependencies of your different projects it might be more efficient to use a different cache per project.

Effiency here means that the cache is smaller and therefore faster/cheaper to download from the GitHub Actions cache when one of your workflow runs starts.

@eifinger
Copy link
Collaborator

@pvardanis feel free to reopen this if your question is not answered

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

No branches or pull requests

2 participants