Skip to content

task args: allow passing args to depends-on #3538

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
lucascolley opened this issue Apr 7, 2025 · 1 comment · Fixed by #3668
Closed

task args: allow passing args to depends-on #3538

lucascolley opened this issue Apr 7, 2025 · 1 comment · Fixed by #3668
Labels
enhancement Feature request

Comments

@lucascolley
Copy link
Contributor

lucascolley commented Apr 7, 2025

Problem description

Closely related to gh-3533.

To echo @bollwyvl's issues, super excited about task args! It looks like there is a missing piece for my use-case, though, trying to enable customisable parallelism. Relevant section of my pixi.toml:

[feature.build.tasks.build-only]
# just build without configure
cmd = ["cmake", "--build", "build", "-j{{ parallel }}"]
cwd = "."
args = [{ arg = "parallel", default = "2" }]
...
[feature.tests.tasks]
# build for tests
build-tests.depends-on = [
  "configure-tests",
  { "task" = "build-only", "args" = ["{{ parallel }}"] },
]
build-tests.args = [{ arg = "parallel", default = "2" }]
# just run tests
tests-only.cmd = ["ctest", "--output-on-failure", "--test-dir", "build/tests", "-j{{ parallel }}"]
tests-only.cwd = "."
tests-only.args = [{ arg = "parallel", default = "2" }]
# build and run tests
tests.cwd = "."
tests.depends-on = [
  "clone-xsref",
  { "task" = "build-tests", "args" = ["{{ parallel }}"] },
  { "task" = "tests-only", args = ["{{ parallel }}"] },
]
tests.args = [{ arg = "parallel", default = "2" }]

This fails for two reasons. In the first place, there are errors like

Error:   × Unexpected keys, expected only 'cmd', 'depends-on', 'description'
    ╭─[/Users/lucascolley/programming/xsf/pixi.toml:74:13]
 73 │ ]
 74 │ build-tests.args = [{ arg = "parallel", default = "2" }]
    ·             ──┬─
    ·               ╰── 'args' was not expected here
 75 │ # just run tests
    ╰────

which can be remedied by specifying a 'dummy' command ":". But this is just a symptom of the wider problem:

xsf on 🎋 task-args [🔨] via △ took 3s 
❯ pixi run build-tests
✨ Pixi task (configure-tests in dev): cmake -DBUILD_TESTS=ON "-S ." "-B build"
-- Arrow version: 19.0.1
-- Found the Arrow shared library: /Users/lucascolley/programming/xsf/./.pixi/envs/dev/lib/libarrow.1900.1.0.dylib
-- Found the Arrow import library: ARROW_IMPORT_LIB-NOTFOUND
-- Found the Arrow static library: 
-- Parquet version: 19.0.1
-- Found the Parquet shared library: /Users/lucascolley/programming/xsf/./.pixi/envs/dev/lib/libparquet.1900.1.0.dylib
-- Found the Parquet import library: PARQUET_IMPORT_LIB-NOTFOUND
-- Found the Parquet static library: 
-- Configuring done (0.8s)
-- Generating done (1.0s)
-- Build files have been written to: /Users/lucascolley/programming/xsf/./build

✨ Pixi task (build-only in dev): cmake --build build "-j{{ parallel }}"
Error:   × The task failed to parse
  ├─▶ Failed to replace argument placeholders. Task: 'cmake --build build "-j{{ parallel }}" '
  ╰─▶ unresolved argument placeholders found

So the enhancement request is to enable arg templating in depends-on, not just cmd.

Copy link
Contributor

Sounds good to me!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement Feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants