Skip to content

Commit

Permalink
handle missing quilt config
Browse files Browse the repository at this point in the history
  • Loading branch information
drernie committed Nov 5, 2024
1 parent 1bf0225 commit f172979
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
17 changes: 9 additions & 8 deletions plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,18 @@ ${nextflow}
Map<String, Map<String,Object>> cf = session.config
println("addSessionMeta.cf: ${cf}")
if (cf == null) {
log.error("addSessionMeta: no config found", pkg.meta)
log.error('addSessionMeta: no config found', pkg.meta)
return false
}
Map<String, Object> qf = cf.navigate('quilt') as Map<String, Object> ?: [:]
qf['package_id'] = pkg.toString()
qf['uri'] = path.toUriString()
println("addSessionMeta.qf: ${qf}")
Map<String, Object> cmeta = qf.navigate('meta') as Map<String, Object>
qf.remove('meta')
println("addSessionMeta.cmeta: ${cmeta}")

try {
Map qf = cf.navigate('quilt') as Map<String, Object>
qf['package_id'] = pkg.toString()
qf['uri'] = path.toUriString()
println("addSessionMeta.qf: ${qf}")
Map<String, Object> cmeta = qf.navigate('meta') as Map<String, Object>
qf.remove('meta')
println("addSessionMeta.cmeta: ${cmeta}")
Map smeta = getMetadata(cf)
// println("addSessionMeta.smeta: ${smeta}")
smeta['quilt'] = qf
Expand Down
21 changes: 13 additions & 8 deletions plugins/nf-quilt/src/test/nextflow/quilt/QuiltProductTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class QuiltProductTest extends QuiltSpecification {
Session session = GroovyMock(Session)
session.config >> config
QuiltProduct product = new QuiltProduct(pathify, session)

return product
}

QuiltProduct makeWriteProduct(Map meta = [:]) {
Expand Down Expand Up @@ -118,7 +118,6 @@ class QuiltProductTest extends QuiltSpecification {
void 'shouldSkip is true if key=SKIP'() {
given:
QuiltProduct product = makeProduct('readme=SKIP')
Session
expect:
!product.shouldSkip(QuiltProduct.KEY_SKIP)
!product.shouldSkip(QuiltProduct.KEY_META)
Expand All @@ -128,10 +127,16 @@ class QuiltProductTest extends QuiltSpecification {
}

void 'addSessionMeta is false if no config'() {
given:
QuiltProduct product = makeConfigProduct()
expect:
product.addSessionMeta() == false
when:
QuiltProduct no_config = makeConfigProduct()
then:
no_config.addSessionMeta() == false

when:
QuiltProduct no_quilt = makeConfigProduct([quilt: null])

then:
no_quilt.addSessionMeta() == false
}

@IgnoreIf({ System.getProperty('os.name').toLowerCase().contains('windows') })
Expand All @@ -154,7 +159,7 @@ class QuiltProductTest extends QuiltSpecification {

then:
!defaultREADME.shouldSkip(QuiltProduct.KEY_README)
files.size() == 1
files.size() > 0

when:
String readme_text = 'hasREADME'
Expand All @@ -164,7 +169,7 @@ class QuiltProductTest extends QuiltSpecification {
then:
text == readme_text
!hasREADME.shouldSkip(QuiltProduct.KEY_README)
files.size() == 1
files.size() > 0
}

void 'setupSummarize empty if no files are present'() {
Expand Down

0 comments on commit f172979

Please sign in to comment.