From 1bf0225be31e5d42a97b7b3fa48a3c8e5f78c9ee Mon Sep 17 00:00:00 2001 From: "Dr. Ernie Prabhakar" <19791+drernie@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:22:33 -0800 Subject: [PATCH] skip null config --- .../main/nextflow/quilt/QuiltProduct.groovy | 21 ++++++++++++------- .../nextflow/quilt/QuiltProductTest.groovy | 17 +++++++++++++++ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy index d5e3cf6f..69087a28 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy @@ -170,20 +170,25 @@ ${nextflow} } boolean addSessionMeta() { + println("addSessionMeta: ${session}") if (shouldSkip(KEY_META)) { return false } + Map> cf = session.config println("addSessionMeta.cf: ${cf}") - Map qf = cf.navigate('quilt') as Map - qf['package_id'] = pkg.toString() - qf['uri'] = path.toUriString() - println("addSessionMeta.qf: ${qf}") - Map cmeta = qf.navigate('meta') as Map - 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 + qf['package_id'] = pkg.toString() + qf['uri'] = path.toUriString() + println("addSessionMeta.qf: ${qf}") + Map cmeta = qf.navigate('meta') as Map + qf.remove('meta') + println("addSessionMeta.cmeta: ${cmeta}") Map smeta = getMetadata(cf) // println("addSessionMeta.smeta: ${smeta}") smeta['quilt'] = qf diff --git a/plugins/nf-quilt/src/test/nextflow/quilt/QuiltProductTest.groovy b/plugins/nf-quilt/src/test/nextflow/quilt/QuiltProductTest.groovy index c92c9af0..a9d9b856 100644 --- a/plugins/nf-quilt/src/test/nextflow/quilt/QuiltProductTest.groovy +++ b/plugins/nf-quilt/src/test/nextflow/quilt/QuiltProductTest.groovy @@ -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) { @@ -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) @@ -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: