-
-
Notifications
You must be signed in to change notification settings - Fork 59
Description
🚀 Feature request
Permits to specify standard input with Path_fr
Motivation
Sometimes, I would like to be able to create a full pipeline of commands which communicate through the standard input and output. But I would also like that run each command with input file instead of standard input. (same for output)
Pitch
jsonargparse don't permits it today with Path_fr. (or I didn't find the feature?)
For instance, if I put "-" (common practice for specifying standard input) with the corresponding option, it will answer that the file does not exist.
Here an example of code:
parser = ArgumentParser()
parser.add_argument(
"--input-file",
dest="input_file",
type=Path_fr,
default="-",
help="Path of input file (standard input if - specified)",
)
The command I run:
python -m my_command --input-file -
And the error I receive:
Not of type Path_fr: File does not exist: /folderA/folderB/-
But, in this situation, I would like that the program does not check the existence of the file as I would like to read the standard input.
It could be great to have the same feature for the output also.
Alternatives
I tested also to use the FileType of argparse as a type, but jsonargparse does not accept it.
from argparse import FileType
parser.add_argument(
"--input-file",
dest="input_file",
type=FileType("r"),
default="-",
help="Path of input file (standard input if - specified)",
)
Error:
error: Validation failed: Parser key "input_file": expected str, bytes or os.PathLike object, not _io.TextIOWrapper