Skip to content

Commit

Permalink
skip null config
Browse files Browse the repository at this point in the history
  • Loading branch information
drernie committed Nov 5, 2024
1 parent 0ceff17 commit 1bf0225
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
21 changes: 13 additions & 8 deletions plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,25 @@ ${nextflow}
}

boolean addSessionMeta() {
println("addSessionMeta: ${session}")
if (shouldSkip(KEY_META)) {
return false
}

Map<String, Map<String,Object>> cf = session.config
println("addSessionMeta.cf: ${cf}")
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}")

if (cf == null) {
log.error("addSessionMeta: no config found", pkg.meta)
return false
}
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
17 changes: 17 additions & 0 deletions plugins/nf-quilt/src/test/nextflow/quilt/QuiltProductTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ class QuiltProductTest extends QuiltSpecification {
return makeProductFromUrl(subURL, success)
}

QuiltProduct makeConfigProduct(Map config = null) {
QuiltPath path = QuiltPathFactory.parse(testURI)
QuiltPathify pathify = new QuiltPathify(path)
Session session = GroovyMock(Session)
session.config >> config
QuiltProduct product = new QuiltProduct(pathify, session)

}

QuiltProduct makeWriteProduct(Map meta = [:]) {
String subURL = writeableURI('quilt_product_test') // + '&workflow=universal'
if (meta) {
Expand Down Expand Up @@ -109,6 +118,7 @@ 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 @@ -117,6 +127,13 @@ class QuiltProductTest extends QuiltSpecification {
!makeProduct('?readme=now').shouldSkip()
}

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

@IgnoreIf({ System.getProperty('os.name').toLowerCase().contains('windows') })
void 'does not create README if readme=SKIP'() {
given:
Expand Down

0 comments on commit 1bf0225

Please sign in to comment.