You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The spec doesn't say anything about using directories as inputs/outputs. Quite a bit of tools use directories, so we'll need to support that.
A workaround that has been used is to just treat them as files and ignore all properties except for path. However, it doesn't take much to support them completely:
Add a Directory/Dir/DIR/Folder type.
Define size in this context to refer to sum of all file sizes inside the directory.
Define (hopefully reuse) a checksum schema for directories (e.g. find -exec sha | sha).
Remove secondaryFiles and loadContent in this context.
- id: '#genomeDir'type:
- File
- stringdescription: | string: path to the directory where genome files are stored (if runMode!=generateGenome) or will be generated (if runMode==generateGenome)inputBinding:
position: 1prefix: '--genomeDir'
so when I use it as the type File I provide path to a directory, job file:
Define size in this context to refer to sum of all file sizes inside the directory.
Form the provided example, and other similar cases (tools that are creating genome indices in a directory), I think to provide the list of output files better then to list the whole directory. It is usual to use one directory for indices, you will have files from other tools also.
Define (hopefully reuse) a checksum schema for directories (e.g. find -exec sha | sha).
To provide SHA/size for the secondaryFiles might be reasonable.
Remove secondaryFiles and loadContent in this context.
I think to keep loadContext is also good :) to see actually the list of files in the directory :)
This would create a directory structure assembled from the files specified in the source fields.
As a convenience for the user, we could allow specifying a Directory with a source field in the input object and construct the directory object from the source listing.
We could add a requirement that specifies a Directory object as the initial contents of the designated output directory:
The idea needs to be developed a bit more, but I think this could provide a more general solution for tools that need to read and write in the same directory.
I should mention that I don't think this obsoletes secondaryFiles, it is turning out to be very useful to use secondaryFiles to represent dependencies of a file. However the interaction between directory objects and file objects that include secondaryFiles will need to be worked out.
Goal: to be able to describe, create, and capture file hierachies, in order
to support tasks where the flat structure implied by the current File concept
is inadequate.
class: CommandLineTool# Obsoletes CreateFileRequirement, describe initial contents of output directory.initialWorkDir:
class: Directorylisting:
- {# "foo" file shows up in directoryclass: Filepath: /foo}# When used in "initialWorkDir", can also return file or list of file from# expression.
- ${ return [{// "bar" file shows up in directoryclass: "File",path: "/bar"}, {// "baz" file shows up in directoryclass: "File",path: "/baz"}]; }# Reuse FileDef from CreateFileRequirement to describe files where you need# custom name or content.
- fileName: quuxfileContent:
class: Filepath: /baz# specify it should be a writable copy, by default files may be symlinks# or read-only.writable: true
- {# secondaryFiles also get added to the directory.class: Filepath: /foo2secondaryFiles:
- class: Filepath: /foo2.index}# If you need to rename secondaryFiles of the primary file, use an an# expression based on a pattern is hard to generalize.
- fileName: zingfileContent: $(inputs.baz.secondaryFiles[0])# Subdirectory object recursively includes a Directory object.
- subdirName: example_subdirsubdirContent: {class: Directorylisting:
- ...}
In the above example, this will be presented to the tool as a directory listing
with the following files and directories:
foo bar baz quux foo2 foo2.index zing example_subdir/
Directory objects can be input or output of tools. Directories are added by
path to the command line. The runtime is responsible for staging files so
they show up in a directory tree with the correct structure.
Command line will then be something like tool --input-dir /tmp/working123
where "working123" has the contents described by the directory object.
Capturing Directories for output doesn't change much, if at all:
outputs:
- id: exampleOutputtype: Directory# Collect all txt files, including subdirectories# depends on issue #134 (add ** syntax for matching across subdirectories)inputBinding:
glob: **.txt
I think forcing you to explicitly write all of the files located in the directory, if that's what the comments above are implying makes it very unreasonable for situations involving annotation cache files. For example, look at the Variant Effect Predictor or Annovar or SNPeff. Writing out every single file for those would be a daunting task. Not sure if anyone has any thoughts on this.
Edit: just looked at my VEP cache, it has 21,383 files in it 😞
I see bcltofastq has already been mentioned - these work on sequencing output directories and can contain even more files than the VEP caches (>100,000). Another example is the Isaac aligner:
The Directory object needs to model the contents of the directory to ensure that the correct files are staged inside the container and/or transferred to the compute node. However, as @ntijanic says, on the user interface side we can allow users to only provide just directory path and have the implementation scan the file system directory.
@tetron: does this mean that the docker command itself would stage every file individually? Will that work for directories with hundreds of thousands of files?
@psaffrey-illumina It's an implementation detail because different CWL implementations will handle files and directories in different ways. I expect in most cases that directory contents will be staged separately (if necessary) and then the whole directory will be bind mounted into the container.
@mr-c: I would be willing to have a go at implementing this, but I've never worked on the spec before so I would need a bit of guidance. Should I just be able to copy the entry for files and modify it?
Activity
portah commentedon Nov 30, 2015
cwtool allows to specify directory as type File:
so when I use it as the type File I provide path to a directory, job file:
{ "readFilesIn": [{"class": "File", "path": "../test-files/SRR1031972.fastq"}], "genomeDir": {"class": "File", "path": "../test-files/dm3/"}, "outFileNamePrefix":"./test-files/SRR1031972.", "outSAMunmapped1": "Within", "runThreadN": 4 }It is a bit controversial what I did in output, perhaps there a more beautiful solution:
portah commentedon Nov 30, 2015
Form the provided example, and other similar cases (tools that are creating genome indices in a directory), I think to provide the list of output files better then to list the whole directory. It is usual to use one directory for indices, you will have files from other tools also.
To provide SHA/size for the secondaryFiles might be reasonable.
I think to keep loadContext is also good :) to see actually the list of files in the directory :)
mr-c commentedon Feb 16, 2016
@ntijanic sounds like this request isn't needed? Or am I reading the comments here wrong?
mr-c commentedon Mar 10, 2016
+1 for a proper directory input type that would automatically make the contents available to the tool
tetron commentedon Mar 10, 2016
@portah "cwtool allows to specify directory as type File" that's a bug that's been recently fixed.
@ntijanic
What do you think of this?
This would create a directory structure assembled from the files specified in the
sourcefields.As a convenience for the user, we could allow specifying a Directory with a
sourcefield in the input object and construct the directory object from the source listing.We could add a requirement that specifies a Directory object as the initial contents of the designated output directory:
This would obsolete
CreateFileRequirement.The idea needs to be developed a bit more, but I think this could provide a more general solution for tools that need to read and write in the same directory.
tetron commentedon Mar 10, 2016
I should mention that I don't think this obsoletes
secondaryFiles, it is turning out to be very useful to use secondaryFiles to represent dependencies of a file. However the interaction between directory objects and file objects that include secondaryFiles will need to be worked out.tetron commentedon Mar 25, 2016
Goal: to be able to describe, create, and capture file hierachies, in order
to support tasks where the flat structure implied by the current File concept
is inadequate.
In the above example, this will be presented to the tool as a directory listing
with the following files and directories:
Directory objects can be input or output of tools. Directories are added by
path to the command line. The runtime is responsible for staging files so
they show up in a directory tree with the correct structure.
Command line will then be something like
tool --input-dir /tmp/working123where "working123" has the contents described by the directory object.
Capturing Directories for output doesn't change much, if at all:
mr-c commentedon Apr 15, 2016
@tetron This looks great to me. @ntijanic Shall we go ahead and add this to draft-4 or should we wait until after the 1.0 release?
kmhernan commentedon Apr 15, 2016
I think forcing you to explicitly write all of the files located in the directory, if that's what the comments above are implying makes it very unreasonable for situations involving annotation cache files. For example, look at the Variant Effect Predictor or Annovar or SNPeff. Writing out every single file for those would be a daunting task. Not sure if anyone has any thoughts on this.
Edit: just looked at my VEP cache, it has 21,383 files in it 😞
psaffrey-illumina commentedon Apr 20, 2016
+1 for directory support.
I see bcltofastq has already been mentioned - these work on sequencing output directories and can contain even more files than the VEP caches (>100,000). Another example is the Isaac aligner:
https://github.com/Illumina/isaac2
which produces index files with a central XML file referring to them. Directory support is probably the easiest way to accommodate this.
tetron commentedon Apr 20, 2016
The Directory object needs to model the contents of the directory to ensure that the correct files are staged inside the container and/or transferred to the compute node. However, as @ntijanic says, on the user interface side we can allow users to only provide just directory path and have the implementation scan the file system directory.
mr-c commentedon Apr 20, 2016
Sounds like we have broad agreement. Who is volunteering to implement this in the reference implementation so we can validate it?
psaffrey-illumina commentedon Apr 20, 2016
@tetron: does this mean that the docker command itself would stage every file individually? Will that work for directories with hundreds of thousands of files?
tetron commentedon Apr 20, 2016
@psaffrey-illumina It's an implementation detail because different CWL implementations will handle files and directories in different ways. I expect in most cases that directory contents will be staged separately (if necessary) and then the whole directory will be bind mounted into the container.
psaffrey-illumina commentedon Apr 21, 2016
@mr-c: I would be willing to have a go at implementing this, but I've never worked on the spec before so I would need a bit of guidance. Should I just be able to copy the entry for files and modify it?
mr-c commentedon Apr 21, 2016
@psaffrey-illumina let's do it together, as basically @tetron has done all the implementation up to this point.
I've rebased the draft-4 branch on the latest code: https://github.com/common-workflow-language/common-workflow-language/tree/draft-4
And I'm updating cwltool to recognize
draft-4.dev1as a valid version of CWL in https://github.com/common-workflow-language/cwltool/tree/draft-4mr-c commentedon Jul 7, 2016
Done!