Skip to content

Commit 35d42a8

Browse files
author
Alan Christie
committed
- Supports multiple extensions per type
1 parent 231be3e commit 35d42a8

File tree

4 files changed

+30
-20
lines changed

4 files changed

+30
-20
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ dist
1010
work
1111
.nextflow
1212
.nextflow.log*
13-
/tmp
13+
**/tmp
1414
**/*.egg-info
1515
**/.DS_Store

src/groovy/MediaChecker.groovy

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,26 @@ class MediaChecker {
5555
def opDescriptors = serviceDescriptor.serviceConfig.outputDescriptors
5656
opDescriptors.each { desc ->
5757

58-
// Expected extension...
59-
// (use the media type to lookup it up)
60-
// And construct full path to the expected file...
61-
String opExt = mediaTypesLookup.media_type[desc.mediaType]
62-
String opName = desc.name + opExt
63-
String opPath = path.toString() + File.separator + opName
64-
if (!new File(opPath).exists()) {
65-
Log.err("The pipeline's 'outputDescriptor'" +
66-
" expected '$opName' but the file wasn't found")
67-
retVal = false
58+
// There must be a matching media type in our txt/lookup file.
59+
def typeExtList = mediaTypesLookup.media_types[desc.mediaType]
60+
if (typeExtList == null || typeExtList.size() == 0) {
61+
Log.err("Pipeline service descriptor output mediaType" +
62+
" '$desc.mediaType' is not listed in '$mediaTypesFile'")
63+
} else {
64+
// What are the expected file extensions for this media type?
65+
// It's a list of 1 or more entries.
66+
typeExtList.each { extension ->
67+
68+
String opName = desc.name + extension
69+
Log.info('Media check', opName)
70+
String opPath = path.toString() + File.separator + opName
71+
if (!new File(opPath).exists()) {
72+
Log.err("The pipeline's 'outputDescriptor'" +
73+
" expected '$opName' but the file wasn't found")
74+
retVal = false
75+
}
76+
77+
}
6878
}
6979

7080
}

src/groovy/MediaTypes.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
//
55
// Read by MediaChecker.groovy
66

7-
media_type = [
7+
media_types = [
88

99
// Please keep the keys in alphabetical order...
1010

11-
'application/x-squonk-dataset-molecule+json': '.data.gz',
12-
'application/x-squonk-dataset-basic+json': '.data.gz',
11+
'application/x-squonk-dataset-molecule+json': ['.data.gz', '.metadata'],
12+
'application/x-squonk-dataset-basic+json': ['.data.gz', '.metadata'],
1313

14-
'image/gif': '.gif',
15-
'image/jpeg': '.jpg',
16-
'image/png': '.png',
14+
'image/gif': ['.gif'],
15+
'image/jpeg': ['.jpg'],
16+
'image/png': ['.png'],
1717

1818
]

src/groovy/Tester.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class Tester {
130130
filesUsed += 1
131131

132132
Log.separate()
133-
Log.info('File', currentTestFilename)
133+
Log.info('Test file', currentTestFilename)
134134
// Collect the files we find...
135135
if (!observedFiles.contains(currentTestFilename)) {
136136
observedFiles.add(currentTestFilename)
@@ -635,8 +635,8 @@ class Tester {
635635
File testOutputPath = new File(test_pout)
636636
testOutputPath.mkdir()
637637

638-
Log.info('Input', test_pin)
639-
Log.info('Output', test_pout)
638+
Log.info('Input path', test_pin)
639+
Log.info('Output path', test_pout)
640640

641641
// Redirect the '-o' option, if there is a '-o' in the command
642642
def oOption = pipelineCommand =~ /$outputRegex/

0 commit comments

Comments
 (0)