pixi icon indicating copy to clipboard operation
pixi copied to clipboard

feat(tasks): allow `outputs` from pure `depends-on` tasks

Open RaphaelRibes opened this issue 9 months ago • 12 comments

Checks

  • [x] I have checked that this issue has not already been reported.

  • [x] I have confirmed this bug exists on the latest version of pixi, using pixi --version.

Reproducible example

Commands I ran and their output:

[ribesr@io-login-01 fastqc_vs_falco]$ pixi run get_all_deciles
Error:   × Unexpected keys, expected only 'cmd', 'depends-on', 'description', 'args'
    ╭─[/scratch/users/ribesr/fastqc_vs_falco/pixi.toml:25:1]
 24 │ [tasks.get_all_deciles]
 25 │ outputs = ["outputs/deciles1.tsv", "outputs/deciles2.tsv", "outputs/deciles3.tsv"]
    · ───┬───
    ·    ╰── 'outputs' was not expected here
 26 │ depends-on = [
    ╰────

pixi.toml/pyproject.toml file that reproduces my issue:

[tasks._mkdir_outputs]
cmd = "mkdir -p outputs"
outputs = ["outputs"]

[tasks.get_deciles]
args = ["folder"]
depends-on = [ "_mkdir_outputs" ]
cmd = "python scripts/getdeciles.py -f {{ folder }}"

[tasks.get_all_deciles]
depends-on = [
    { task = "get_deciles", args = ["1"] },
    { task = "get_deciles", args = ["2"] },
    { task = "get_deciles", args = ["3"] },
]
outputs = ["outputs/deciles1.tsv", "outputs/deciles2.tsv", "outputs/deciles3.tsv"]

pixi info output:

[ribesr@io-login-01 fastqc_vs_falco]$ pixi info
System
------------
       Pixi version: 0.63.2
        TLS backend: rustls
           Platform: linux-64
   Virtual packages: __unix=0=0
                   : __linux=5.14.0=0
                   : __glibc=2.34=0
                   : __archspec=1=zen4
          Cache dir: /home/ribesr/.cache/rattler/cache
       Auth storage: /home/ribesr/.rattler/credentials.json
   Config locations: No config files found

Global
------------
            Bin dir: /home/ribesr/.pixi/bin
    Environment dir: /home/ribesr/.pixi/envs
       Manifest dir: /home/ribesr/.pixi/manifests/pixi-global.toml

Other files (e.g. script files, source files, etc.): You can replace cmd = "python scripts/getdeciles.py -f {{ folder }}" in get_deciles by cmd = "echo "Hello world !" > {{ folder }}" to test it more easily.

Issue description

I first thought it was because I didn't have the field inputs but _mkdir_outputs works without it...

Expected behavior

It is supposed to just run, you can put the outputs field in a task but here it tells me that I can only put cmd, depends-on, description, args

RaphaelRibes avatar Feb 06 '26 11:02 RaphaelRibes

Hi @RaphaelRibes , Can I be assigned this issue to work on.

Thanks

Joiejoie1 avatar Feb 06 '26 15:02 Joiejoie1

Hi @RaphaelRibes , Can I be assigned this issue to work on.

Thanks

Yes, no problem.

RaphaelRibes avatar Feb 06 '26 15:02 RaphaelRibes

Hi @RaphaelRibes , Can I be assigned this issue to work on. Thanks

Yes, no problem.

Thanks @RaphaelRibes

Joiejoie1 avatar Feb 06 '26 16:02 Joiejoie1

would this work for you @RaphaelRibes ?

[tasks._mkdir_outputs]
cmd = "mkdir -p outputs"
outputs = ["outputs"]

[tasks.get_deciles]
args = ["folder"]
depends-on = [ "_mkdir_outputs" ]
cmd = "python scripts/getdeciles.py -f {{ folder }}"
outputs = ["outputs/deciles{{ folder }}.tsv"]

[tasks.get_all_deciles]
depends-on = [
    { task = "get_deciles", args = ["1"] },
    { task = "get_deciles", args = ["2"] },
    { task = "get_deciles", args = ["3"] },
]

Not sure if templating is impossible within the outputs field, if so this would be an enhancement request.

The core of the error here is that outputs expects to have a cmd field present.

lucascolley avatar Feb 07 '26 12:02 lucascolley

would this work for you @RaphaelRibes ?

[tasks._mkdir_outputs] cmd = "mkdir -p outputs" outputs = ["outputs"]

[tasks.get_deciles] args = ["folder"] depends-on = [ "_mkdir_outputs" ] cmd = "python scripts/getdeciles.py -f {{ folder }}" outputs = ["outputs/deciles{{ folder }}.tsv"]

[tasks.get_all_deciles] depends-on = [ { task = "get_deciles", args = ["1"] }, { task = "get_deciles", args = ["2"] }, { task = "get_deciles", args = ["3"] }, ] Not sure if templating is impossible within the outputs field, if so this would be an enhancement request.

The core of the error here is that outputs expects to have a cmd field present.

Hi @lucascolley , thanks for the above, I asked to be assigned to this issue and I am working on it.

Joiejoie1 avatar Feb 07 '26 22:02 Joiejoie1

Hi @Joiejoie1, speaking as a Pixi maintainer, please understand that we do not assign issues to new contributors such that they are 'claimed' and others are blocked from working on those issues.

What exactly are you working on? Feel free to brainstorm ideas in the open.

lucascolley avatar Feb 07 '26 23:02 lucascolley

would this work for you @RaphaelRibes ?

[tasks._mkdir_outputs]
cmd = "mkdir -p outputs"
outputs = ["outputs"]

[tasks.get_deciles]
args = ["folder"]
depends-on = [ "_mkdir_outputs" ]
cmd = "python scripts/getdeciles.py -f {{ folder }}"
outputs = ["outputs/deciles{{ folder }}.tsv"]

[tasks.get_all_deciles]
depends-on = [
    { task = "get_deciles", args = ["1"] },
    { task = "get_deciles", args = ["2"] },
    { task = "get_deciles", args = ["3"] },
]

Not sure if templating is impossible within the outputs field, if so this would be an enhancement request.

The core of the error here is that outputs expects to have a cmd field present.

Hello ! Thank you for taking your time checking this. This is the solution I implemented because it's just better logics. However, even if it's garbage code, the exemple in the issue should work.

So my problem is solved but not the one on pixi side.

RaphaelRibes avatar Feb 08 '26 07:02 RaphaelRibes

So my problem is solved but not the one on pixi side.

I edited the title appropriately

lucascolley avatar Feb 08 '26 13:02 lucascolley

@Joiejoie1 Have you been able to make progress on this?

baszalmstra avatar Feb 13 '26 10:02 baszalmstra

@Joiejoie1 Have you been able to make progress on this?

Hi @baszalmstra , thanks for checking , I have been working on this issue, however, I thought you guys were performing some maintainers work on it . I'll create a PR for it. Thanks

Joiejoie1 avatar Feb 13 '26 14:02 Joiejoie1

I will reopen this really quickly, I found the issue. A task with a cmd field cannot have neither inputs or outputs.

Example, this will not work:

[tasks.dedup-both]
depends-on = [
    { task = "dedup", args = ["data/final_simulated_R1.fastq","data/dedup_R1.fastq"] },
    { task = "dedup", args = ["data/final_simulated_R2.fastq","data/dedup_R2.fastq"] }
]
inputs = ["data/final_simulated_R1.fastq", "data/final_simulated_R2.fastq"]
outputs = ["data/dedup_R1.fastq", "data/dedup_R2.fastq"]
Error:   × Unexpected keys, expected only 'cmd', 'depends-on', 'description', 'args'
    ╭─[/home/raphael/Desktop/TMP/fdedup/pixi.toml:33:1]
 32 │ ]
 33 │ inputs = ["data/final_simulated_R1.fastq", "data/final_simulated_R2.fastq"]
    · ───┬──
    ·    ╰── 'inputs' was not expected here
 34 │ outputs = ["data/dedup_R1.fastq", "data/dedup_R2.fastq"]
    · ───┬───
    ·    ╰── 'outputs' was not expected here
 35 │ 
    ╰────

Where this will:

[tasks.dedup-both]
cmd = "echo ''"
depends-on = [
    { task = "dedup", args = ["data/final_simulated_R1.fastq","data/dedup_R1.fastq"] },
    { task = "dedup", args = ["data/final_simulated_R2.fastq","data/dedup_R2.fastq"] }
]
inputs = ["data/final_simulated_R1.fastq", "data/final_simulated_R2.fastq"]
outputs = ["data/dedup_R1.fastq", "data/dedup_R2.fastq"]

RaphaelRibes avatar Feb 24 '26 09:02 RaphaelRibes

would this work for you @RaphaelRibes ?

[tasks._mkdir_outputs]
cmd = "mkdir -p outputs"
outputs = ["outputs"]

[tasks.get_deciles]
args = ["folder"]
depends-on = [ "_mkdir_outputs" ]
cmd = "python scripts/getdeciles.py -f {{ folder }}"
outputs = ["outputs/deciles{{ folder }}.tsv"]

[tasks.get_all_deciles]
depends-on = [
    { task = "get_deciles", args = ["1"] },
    { task = "get_deciles", args = ["2"] },
    { task = "get_deciles", args = ["3"] },
]

Not sure if templating is impossible within the outputs field, if so this would be an enhancement request.

The core of the error here is that outputs expects to have a cmd field present.

Yeah that's what I meant up here

lucascolley avatar Feb 24 '26 09:02 lucascolley