Skip to content

Include args in task cache file name hash #4675

@bollwyvl

Description

@bollwyvl

Problem description

As of pixi 0.55.0 (and probably earlier), two "leaf" tasks may depends-on the
same "template" tasks in the same environment, inputs, and outputs, but with
different arg values. As only the environment name and file hashes seem to have an
impact, running the leaf tasks interleaved appears to always encounter a cache miss,
and the tasks always run.

Consider a template task that calls a linter/formatter tool like ruff, which
always considers the same python files.

dependencies.ruff = "*"

[tasks]
touch = """echo 'print("hello world")' > foo.py"""
fix.depends-on = [{task="_ruff", args=["1"]}]
lint.depends-on = ["_ruff"]
_ruff = {args = [{arg="fix", default=""}], inputs = ["*.py"], cmd = """
  ruff format {{ "--check" if not fix }} && ruff check {{ "--fix-only" if fix }}
"""}

[project]
name = "foo"
platforms = ["linux-64", "osx-arm64", "win-64"]
channels = ["conda-forge"]

Then:

pixi r touch
pixi r fix && pixi r lint  # expect to see run...
pixi r fix && pixi r lint  # ... expect to see a cache hit

No amount of doing this will cause the cache to "settle".

design ideas

I think it might be a matter of adding the task args to the hash file name.
Will try a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions