common-workflow-language / cwltool

Common Workflow Language reference implementation
https://cwltool.readthedocs.io/
Apache License 2.0
332 stars 230 forks source link

accept globs using the CLI interface for inputs that are File[] or Directory #448

Open mr-c opened 7 years ago

mr-c commented 7 years ago

inspired by https://www.biostars.org/p/260090/

tobyhodges commented 5 years ago

This is related to https://github.com/common-workflow-language/common-workflow-language/issues/817. Are you planning to implement this?

[edit: fix cross-repo issue reference]

mr-c commented 2 years ago

This is related to common-workflow-language/common-workflow-language#817.

I think that question was about constructing the command line;

This issue is about the cwltool specific ability to construct the input object from extra command line options passed to cwltool instead of a path to a JSON/YAML file describing the inputs

Using https://github.com/common-workflow-language/common-workflow-language/issues/817#issuecomment-999397414 as an example (presume the CWL description is saved as 817.cwl:

For a generic cwl-runner one would have to invoke that file as cwl-runner 817.cwl inputs.yaml

where inputs.yaml looks like

my_files:
  - class: File
      path: file1.abc
  - class: File
      path: file2.abc

With cwltool one can run cwltool 817.cwl --my_files file1.abc --my_files file2.abc today

With this proposal, one could run cwltool 817.cwl --my_files *.abc and let the shell expand *.abc so that the whole command becomes cwltool 817.cwl --my_files file1.abc file2.abc and both files get added to the my_files array (not just the one that would be added in the current cwltool implementation)

Are you planning to implement this?

I think it is a good idea as it would improve usability for quickly testing a CWL description from the command line. However I am not personally planning on implementing this. Contributions to do so are very welcome and I would provide assistance.

To implement this, look at https://github.com/common-workflow-language/cwltool/blob/f02df5a3004f78499df2b45bf473d1e607355ed4/cwltool/argparser.py#L859

The trick is allowing multiple values for --my_files due to the shell expanding *.abc to file1.abc file2.abc while preserving the ability to specify --my_files multiple times.