From f172979f1c18de3ec726a1fa18199b8ba85e400b Mon Sep 17 00:00:00 2001 From: "Dr. Ernie Prabhakar" <19791+drernie@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:35:42 -0800 Subject: [PATCH] handle missing quilt config --- .../main/nextflow/quilt/QuiltProduct.groovy | 17 ++++++++------- .../nextflow/quilt/QuiltProductTest.groovy | 21 ++++++++++++------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy index 69087a28..a87c4e58 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy @@ -178,17 +178,18 @@ ${nextflow} Map> 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 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}") + 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 a9d9b856..fd83c415 100644 --- a/plugins/nf-quilt/src/test/nextflow/quilt/QuiltProductTest.groovy +++ b/plugins/nf-quilt/src/test/nextflow/quilt/QuiltProductTest.groovy @@ -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 = [:]) { @@ -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) @@ -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') }) @@ -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' @@ -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'() {