From 01b268e2379c731b9b93a3a37396971dc8b706bd Mon Sep 17 00:00:00 2001 From: Ernest Prabhakar Date: Fri, 8 Sep 2023 16:50:14 -0700 Subject: [PATCH] fail relativeChildren --- .../nextflow/quilt/jep/QuiltPackage.groovy | 15 ++++++-------- .../quilt/jep/QuiltPackageTest.groovy | 20 +++++++++++++++++++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy index 34e10406..54bd7874 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy @@ -161,15 +161,13 @@ class QuiltPackage { */ List relativeChildren(String subpath) { - Manifest manifest = packageManifest() - // get names of entries - List children = manifest.getEntries().keySet().collect { String key -> - if (key.startsWith(subpath)) { - return key - } - return null + Set keys = packageManifest().getEntries().keySet() + println("relativeChildren[${subpath}]: ${keys}") + Collection children = keys.findResults { String key -> + key.startsWith(subpath) ? key : null } - return children + println("relativeChildren.children: ${children}") + return children as List } void reset() { @@ -240,7 +238,6 @@ class QuiltPackage { Namespace namespace = packageNamespace() Manifest.Builder builder = Manifest.builder() Files.walk(packageDest()).filter(f -> Files.isRegularFile(f)).forEach(f -> { - println(f) String logicalKey = packageDest().relativize(f) LocalPhysicalKey physicalKey = new LocalPhysicalKey(f) long size = Files.size(f) diff --git a/plugins/nf-quilt/src/test/nextflow/quilt/jep/QuiltPackageTest.groovy b/plugins/nf-quilt/src/test/nextflow/quilt/jep/QuiltPackageTest.groovy index 263f715d..f56472e9 100644 --- a/plugins/nf-quilt/src/test/nextflow/quilt/jep/QuiltPackageTest.groovy +++ b/plugins/nf-quilt/src/test/nextflow/quilt/jep/QuiltPackageTest.groovy @@ -22,6 +22,7 @@ import nextflow.quilt.nio.QuiltPath import spock.lang.Ignore import spock.lang.IgnoreIf +import spock.lang.Unroll import java.nio.file.Files import java.nio.file.Path import java.nio.file.Paths @@ -63,6 +64,25 @@ class QuiltPackageTest extends QuiltSpecification { pkg == pkg2 } + @Unroll + void 'should find relativeChildren of complete folders'() { + given: + Path path = Paths.get(new URI(PACKAGE_URL)) + when: + QuiltPackage pkg = path.pkg() + then: + pkg.relativeChildren(subpath).size() == expected_size + + where: + subpath | expected_size + '' | 8 + '.ipynb_checkpoints' | 1 + '/.ipynb_checkpoints' | 1 + '.ipynb' | 1 + '/.ipynb' | 0 + + } + void 'should distinguish Packages with same name in different Buckets '() { given: def url2 = TEST_URL.replace('quilt-', 'quilted-')