Missing file in `inputs` or `outputs` return an error instead of a warning
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_ERRORset toTrue. - Task specific: like for
no-default-feature = truein an environment, we can havemissing_file_error = true
I could see this making sense, any thoughts @ruben-arts?
@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.
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.
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-filesandmax-files
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.
If it's possible do add it in a task like fails-on-missing-inputs/outputs=true it could be great.
Opened #5524 for the general case.