When Poetry 1.2 dependency groups are defined in pyproject.toml and actions/setup-python@v4 caching is enabled with cache: "poetry", the caching does not work very well.
Let's say you have a few dependency groups which you install in your CI with different kind of commands:
Dependency group
Install command
main
poetry install --only main
docs
poetry install --only docs
linting
poetry install --only linting
testing
poetry install --only main,testing
typing
poetry install --only main,testing,typing
Defined like this (semi-real world example) in pyproject.toml:
Whichever cache is written first will be used for all these CI jobs. Let's say the docs dependency group finishes first and will be written as the cache.
The end result seems to be here that all the other dependency groups will only get the docs deps cached. And in this example they are not needed for any of the other dependency groups. So for example, the typing CI job will always have to install all its dependencies even if a cache exists.
Now, I'm wondering if I can somehow utilize the cache-dependency-path option to e.g. set this for each CI job so to produce one cache per dependency group. Or is this use case simply not supported today?
It's possible that this won't be supported and if so, I think the docs should include a recommendation on e.g. not using the built-in caching and instead rely on something like this:
@panticmilos I see this got labeled as bug and you self-assigned this recently. Do you have anything to share on this topic yet?
I'm thinking whether I should use the cache-dependency-path to work around this problem or if you have something else in mind? 😄
First of all, sorry for the delayed response, and thank you for your patience 🙏
We have discussed your issue with our team and this is the conclusion. I don’t think we can utilize cache-dependency-path here since all of the dependencies groups are in the same file at the end. If there was some poetry command which would tell you which dependency group is installed, then it would make sense to implement such a thing. Otherwise, we would need one more input for it, which would make the solution the same as for actions/cache with an expanded primary key with a dependency group, and therefore we don’t see the need to implement such a thing, since we want to keep cache input as minimal as possible for setup actions.
I will close this issue now, but we can continue the conversation. Also, feel free to reopen it any time
Activity
panticmilos commented on Sep 22, 2022
hi @fredrikaverpil thank you for the report, we will take a look.
fredrikaverpil commented on Oct 8, 2022
@panticmilos I see this got labeled as bug and you self-assigned this recently. Do you have anything to share on this topic yet?
I'm thinking whether I should use the cache-dependency-path to work around this problem or if you have something else in mind? 😄
panticmilos commented on Oct 10, 2022
Hi @fredrikaverpil,
First of all, sorry for the delayed response, and thank you for your patience 🙏
We have discussed your issue with our team and this is the conclusion. I don’t think we can utilize cache-dependency-path here since all of the dependencies groups are in the same file at the end. If there was some poetry command which would tell you which dependency group is installed, then it would make sense to implement such a thing. Otherwise, we would need one more input for it, which would make the solution the same as for actions/cache with an expanded primary key with a dependency group, and therefore we don’t see the need to implement such a thing, since we want to keep cache input as minimal as possible for setup actions.
I will close this issue now, but we can continue the conversation. Also, feel free to reopen it any time
fredrikaverpil commented on Oct 10, 2022
@panticmilos I think this makes a lot of sense 👍
How about adding a note about this in your docs though?
For others who may stumble across this thread; a custom action supporting caching of poetry dependency groups:
Add workflow for testing with all deps (#4410)
Add workflow for testing with all deps (langchain-ai#4410)
Add workflow for testing with all deps (langchain-ai#4410)
Merge all dependency groups into `dev` (#101)
Add pre-commit caching and fix poetry extras cache (#817)
Add workflow for testing with all deps (langchain-ai#4410)
Add pre-commit caching and fix poetry extras cache (python-kasa#817)