Hi, I’m currently trying to figure out the best way to combine command line tools (argparse, jsonargparse, …) with param.
Goal
A simple format to provide parameter definitions for scripts, preferably from within the script. For example as shown by the dataclass below.
Note that some of the scripts are really short (<50 lines of code), so I’m looking for something that can be very lightweight in the way of providing parameter information (so not jsonschema).
It then needs to be easy to provide a command line interface and a panel interface (using param) from that definition. Furthermore, that definition (not the instantiated with the parameters) needs to be serializable. Dataclasses seem ideal as they can be used with jsonargparse and are very lightweight, but they seem non trivial to convert to param and non trivial to serialize (the dataclass definition).
@dataclass
class Args:
folder: Path = Path(".")
"""Folder on which the program searches for the txt files"""
bin_size: int | Literal["auto"] = "auto"
"""Size of the bins"""
bin_agg: Literal["max", "mean", "median", "min"] = "max"
glob_pattern: str = "**/*.txt"
out_folder: Path | Literal["__input_folder_path__"] = "__input_folder_path__"
show: bool = False
overwrite: Literal["ask_user", "yes", "no"] = "ask_user"
files: List[Tuple[Path, Path]] = field(default_factory=lambda: [("f1", "f2")])
Any ideas ?