Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

210 dot path #211

Merged
merged 6 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
cache: gradle

- name: Setup Gradle
uses: gradle/gradle-build-action@v3
uses: gradle/actions/setup-gradle@v3

- name: Run Gradle Tests
run: make test
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [0.7.15] 2024-06-17

- use null bucket for relative paths (e.g., nf-schema)

## [0.7.14] 2024-06-14

- improve package name debugging
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ From the command-line, do, e.g.:
```bash
# export NXF_VER=23.04.3
export LOG4J_DEBUG=true # for verbose logging
export NXF_PLUGINS_TEST_REPOSITORY=https://github.com/quiltdata/nf-quilt/releases/download/0.7.14/nf-quilt-0.7.14-meta.json
nextflow run main.nf -plugins [email protected].14
export NXF_PLUGINS_TEST_REPOSITORY=https://github.com/quiltdata/nf-quilt/releases/download/0.7.15/nf-quilt-0.7.15-meta.json
nextflow run main.nf -plugins [email protected].15
```

For Tower, you can use the "Pre-run script" to set the environment variables.
Expand Down
13 changes: 13 additions & 0 deletions plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ class QuiltPackage {
return parsed.options[QuiltParser.P_FORCE]
}

boolean isNull() {
return parsed.hasNullBucket()
}

boolean isInstalled() {
return installed
}
Expand All @@ -179,6 +183,10 @@ class QuiltPackage {
}

Path install() {
if (isNull()) {
log.debug('null bucket: no need to install')
return null
}
Path dest = packageDest()

try {
Expand Down Expand Up @@ -229,6 +237,11 @@ class QuiltPackage {
}
// https://docs.quiltdata.com/v/version-5.0.x/examples/gitlike#install-a-package
Manifest push(String msg = 'update', Map meta = [:]) {
if (isNull()) {
log.debug('null bucket: no need to push')
return null
}

S3PhysicalKey registryPath = new S3PhysicalKey(bucket, '', null)
Registry registry = new Registry(registryPath)
Namespace namespace = registry.getNamespace(packageName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class QuiltParser {
static final String SEP = '/'
static final String PREFIX = SCHEME + '://'
static final int MIN_SIZE = 2
static final String NULL_BUCKET = 'nf-quilt-dev-null'

static final String P_CAT = 'catalog'
static final String P_DEST = 'dest'
Expand Down Expand Up @@ -58,6 +59,10 @@ class QuiltParser {
return QuiltParser.forUriString(PREFIX + path)
}

static QuiltParser forNullBucket() {
return new QuiltParser(NULL_BUCKET, 'dev/null', '')
}

static QuiltParser forUriString(String uriString) {
URI uri = new URI(uriString)
return QuiltParser.forURI(uri)
Expand Down Expand Up @@ -268,6 +273,10 @@ class QuiltParser {
return paths.size() > 0
}

boolean hasNullBucket() {
return NULL_BUCKET == getBucket()
}

String getOptions(String key) {
return options?.get(key)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr
@Override
def <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... options)
throws IOException {
// log.debug '<A>BasicFileAttributes QuiltFileSystemProvider.readAttributes()'
log.debug '<A>BasicFileAttributes QuiltFileSystemProvider.readAttributes()'
def attr = attributesCache.get(path)
if (attr) {
return attr
Expand All @@ -486,8 +486,11 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr
attributesCache[path] = result
return result
}
// log.debug("readAttributes: File ${qPath.localPath()} not found")
throw new NoSuchFileException(qPath.toUriString())
log.debug("readAttributes: File ${qPath.localPath()} not found")
if (!qPath.isNull()) {
throw new NoSuchFileException(qPath.toUriString())
}
log.warn("readAttributes: Ignore ${qPath} for null bucket")
}
throw new UnsupportedOperationException("Not a valid Quilt Storage file attribute type: $type")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ final class QuiltPath implements Path, Comparable {
}

QuiltPackage pkg() {
return isAbsolute() ? QuiltPackage.forParsed(parsed) : null
QuiltParser source = isAbsolute() ? parsed : QuiltParser.forNullBucket()
return QuiltPackage.forParsed(source)
}

String file_key() {
Expand Down Expand Up @@ -104,6 +105,10 @@ final class QuiltPath implements Path, Comparable {
return !parsed.hasPath()
}

boolean isNull() {
return parsed.hasNullBucket()
}

QuiltPath getJustPackage() {
if (isJustPackage()) { return this }
QuiltParser packageParsed = QuiltParser.forBarePath(parsed.toPackageString())
Expand Down
2 changes: 1 addition & 1 deletion plugins/nf-quilt/src/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Plugin-Class: nextflow.quilt.QuiltPlugin
Plugin-Id: nf-quilt
Plugin-Version: 0.7.14
Plugin-Version: 0.7.15
Plugin-Provider: Quilt Data
Plugin-Requires: >=22.10.6

Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ class QuiltPackageTest extends QuiltSpecification {
Files.readAttributes(qroot, BasicFileAttributes)
}

void 'should not raise error on null bucket'() {
given:
def qpath = factory.parseUri('quilt+s3://./')
def pkg = qpath.pkg()
expect:
pkg.isNull()
!pkg.install()
!pkg.isInstalled()
Files.exists(qpath.localPath())
Files.readAttributes(qpath, BasicFileAttributes)
}

@IgnoreIf({ System.getProperty('os.name').contains('indows') })
void 'should successfully install files and get attributes'() {
expect:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,12 @@ class QuiltPathTest extends QuiltSpecification {
fullPath.toUriString().contains('?')
}

void 'should return a special-case null bucket on invalid paths'() {
when:
QuiltPath path = QuiltPathFactory.parse('quilt+s3://./')
then:
path.toString() == '.'
path.pkg() != null
}

}
Loading