pixi icon indicating copy to clipboard operation
pixi copied to clipboard

Missing file in `inputs` or `outputs` return an error instead of a warning

Open RaphaelRibes opened this issue 9 months ago • 7 comments

Problem description

Why?

If you want to assure that your program did its thing correctly it's necessary, warnings can be ignored. I don't want this functionality to be mandatory but possible.

How ?

  • Global config: Having a environment variable like MISSING_FILE_ERROR set to True.
  • Task specific: like for no-default-feature = true in an environment, we can have missing_file_error = true

RaphaelRibes avatar Feb 06 '26 10:02 RaphaelRibes

I could see this making sense, any thoughts @ruben-arts?

tdejager avatar Feb 13 '26 10:02 tdejager

@RaphaelRibes could you provide a more specific use-case where you noticed the need for this?

It does make sense from a top level perspective.

ruben-arts avatar Feb 13 '26 10:02 ruben-arts

In my case, I working with workflow managers for big pipelines. Sometimes, I don't do big pipelines and don't want to go through the trouble of using a workflow manager so I want to use pixi.

However, I need to be sure that files all the files I want to go in are there and all the files that goes out too, or I will have error later or missing data.

For example, I have task1 that creates 5 files and tasks2 that takes a file to treat it. If for some reason task1 only output 4 files, task2 will work but will give me incomplete data. Even if task1 throws a warning, it can be missed because the program will exit with a 0 error code. It means that I have to manually check if I don't have a warning or have all my files, which is painful when you have dozen of files.

This is why having an option to kill the workflow for a missing input or ouput can be usefull for maintaining data continuity.

RaphaelRibes avatar Feb 13 '26 10:02 RaphaelRibes

Agreed, coming from other file-based incremental build tools, the lack of failure on missing inputs/outputs is surprising.

As for warnings-as-errors: hooray! All warnings could be documented with short error codes (e.g. PXT for tasks, PXE for envs, etc). and human-readable slugs, which could be referenced in the CLI/env/config.toml:

# PIXI_FAIL_ON_WARNING="input-missing output-missing"
pixi run --fail-on=PXT001,PXT002 task5

Perhaps the inputs/outputs data model could be expanded to provide more useful feedback:

{
  "InputsOrOutputs": {
    "oneOf": [
      {"type": "string"},
      {"type": "array", "items": {"$ref": "/$defs/InputOrOutput"}},
      {"type": "object", "additionalProperties": "items": {"$ref": "/$defs/InputOrOutput"}}
     ]
  },
  "InputOrOutput": {
    "oneOf": [
       {"type": "string"},
       {"$ref": "/$defs/FatInputOrOutput"}
    ]
  }
}

Where a FatInputOrOutput might be like:

[tasks.task5.inputs.complex]
description = "some required inputs"
globs = ["some-generated-bar-*.txt"]
min-files = 1
max-files = 2
pixi run foo

[XXX] [task5] input "complex" expected 1 to 2 files, found 0
  - some-generated-bar-*.txt matched 0 files

edit: changed to min-files and max-files

bollwyvl avatar Feb 13 '26 14:02 bollwyvl

Thanks for the extended information!

I think a good first step would be to indeed add this --fail-on-missing-files kind of input, probably the CLI with an env var it could use would solve a lot of the problems already.

Contributions are welcome!

ps. I like the --fail-on idea but I feel that that's a lot more work. It would make sense to open a sperate issue for that to not loose that idea and be able to close this when a user can get a failing command on the missing files.

ruben-arts avatar Feb 18 '26 10:02 ruben-arts

If it's possible do add it in a task like fails-on-missing-inputs/outputs=true it could be great.

RaphaelRibes avatar Feb 18 '26 13:02 RaphaelRibes

Opened #5524 for the general case.

bollwyvl avatar Feb 18 '26 13:02 bollwyvl