biocore / pyqi

Tools for developing and testing command line interfaces in Python.
Other
9 stars 13 forks source link

Add native support for output directories in optparse #250

Open josenavas opened 10 years ago

josenavas commented 10 years ago

Currently, if a command has multiple outcomes and all of them should be stored in a single output directory there is not an elegant way of doing this: the directory is passed using the option_value parameter of the output handler and the actual file name can be extracted from the result_key parameter, so the final output path is constructed joining these two parameters. However, this implies that each of the output handlers that are going to write on such directory such check the existence of the directory and create it if it does not exist.

This check can be removed by creating the output directory when the optparse framework checks for the existence of such directory during CLI parameter parsing and checking.

On the other hand, this also means that we should have two versions of each of the output handlers that write files: one that expects the file name in option_value and another one that expects a directory in option_value, creates the path with the result_key parameter and simply calls the first output handler.

Examples of these issues and how they are addresses are implemented in the QIIME-Scaling project.

I think we should make this process easier, since this is a functionality that is widely used.

josenavas commented 10 years ago

In some e-mail discussion about this topic have came up that the current API for the output handlers really isn't as flexible as we'd like. Can we start here a discussion about re-designing the output handlers API so it becomes more flexible? What do you think?

If so, we should start ASAP, since more projects are using pyqi...