Skip to content

Commit

Permalink
pass path-input integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
drernie committed Jan 27, 2024
1 parent b6c8387 commit 19a588c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 41 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

## [0.7.7] 2024-01-24

- Properly implement and test getFilename()
- Pre-install package if "&path" present
- Add `path-input` integration test
- Add and pass `path-input` integration test
- Add unit test for "&path=" Quilt+ URIs

## [0.7.6] 2024-01-10 UNOFFICIAL
Expand Down
4 changes: 1 addition & 3 deletions main.path.nf
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ process CHECK_INPUT {
"""
ls -l
echo $input
if [ "$input" != "README.md" ]; then
cp -f $input README.md
fi
cp -f $input ../../tmp
"""
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import java.nio.file.LinkOption
import java.nio.file.NoSuchFileException
import java.nio.file.OpenOption
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.StandardOpenOption
import java.nio.file.attribute.BasicFileAttributeView
import java.nio.file.attribute.BasicFileAttributes
Expand All @@ -48,7 +47,6 @@ import groovy.util.logging.Slf4j
import nextflow.Global
import nextflow.Session
import nextflow.quilt.jep.QuiltParser
import nextflow.quilt.jep.QuiltPackage
import nextflow.file.FileSystemTransferAware
import nextflow.file.CopyOptions
import nextflow.file.FileHelper
Expand Down Expand Up @@ -101,28 +99,22 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr
*/

boolean canUpload(Path source, Path target) {
log.debug "QuiltFileSystemProvider.canUpload: ${source} -> ${target}"
// log.debug "QuiltFileSystemProvider.canUpload: ${source} -> ${target}"
return FileSystems.getDefault().equals(source.getFileSystem()) && target instanceof QuiltPath
}

boolean canDownload(Path source, Path target) {
log.debug "QuiltFileSystemProvider.canDownload: ${source} -> ${target}"
// log.debug "QuiltFileSystemProvider.canDownload: ${source} -> ${target}"
return source instanceof QuiltPath && FileSystems.getDefault().equals(target.getFileSystem())
}

void download(Path remoteFile, Path localDestination, CopyOption... options) throws IOException {
log.debug "QuiltFileSystemProvider.download: ${remoteFile} -> ${localDestination}"
// log.debug "QuiltFileSystemProvider.download: ${remoteFile} -> ${localDestination}"
QuiltPath qPath = asQuiltPath(remoteFile)
Path cachedFile = qPath.localPath()
log.debug "download.cachedFile: ${cachedFile} [${qPath}]"

QuiltPackage pkg = qPath.pkg()
String pathName = pkg.parsed.getPath()

Path localRoot = localDestination.getParent().getParent().getParent().getParent()
Path finalDestination = Paths.get(localRoot.toUriString(), 'tmp', pathName)
log.debug "download.finalDestination: ${finalDestination} [${localRoot}]"
FileHelper.deletePath(finalDestination) // FIXME: be more intelligent about this
if (!Files.exists(cachedFile)) {
throw new NoSuchFileException(remoteFile.toString())
}

final CopyOptions opts = CopyOptions.parse(options)
// delete target if it exists and REPLACE_EXISTING is specified
Expand All @@ -133,15 +125,11 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr
throw new FileAlreadyExistsException(localDestination.toString())
}

log.info "download.Files.copy -> ${localDestination}"
Files.copy(cachedFile, localDestination, options)
// log.info "download.Files.copy -> ${finalDestination}"
// Files.copy(localDestination, finalDestination, options)
log.info 'download.Files copied'
}

void upload(Path localFile, Path remoteDestination, CopyOption... options) throws IOException {
log.debug "QuiltFileSystemProvider.upload: ${localFile} -> ${remoteDestination}"
// log.debug "QuiltFileSystemProvider.upload: ${localFile} -> ${remoteDestination}"
final CopyOptions opts = CopyOptions.parse(options)
// delete target if it exists and REPLACE_EXISTING is specified
if (opts.replaceExisting()) {
Expand Down Expand Up @@ -303,7 +291,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr
@Override
QuiltPath getPath(URI uri) {
QuiltParser parsed = QuiltParser.forURI(uri)
log.debug("QuiltFileSystemProvider.getPath`[${uri}]")
// log.debug("QuiltFileSystemProvider.getPath`[${uri}]")
final fs = getFileSystem(parsed.quiltIDS(), true)
return new QuiltPath(fs, parsed)
}
Expand Down Expand Up @@ -334,7 +322,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr
@Override
SeekableByteChannel newByteChannel(
Path path, Set<? extends OpenOption> options, FileAttribute<?>... attrs) throws IOException {
//log.debug("Creating `newByteChannel`: ${path} <- ${options}")
// log.debug("Creating `newByteChannel`: ${path} <- ${options}")
final modeWrite = options.contains(WRITE) || options.contains(APPEND)

final QuiltPath qPath = asQuiltPath(path)
Expand All @@ -348,7 +336,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr
attributesCache = [:] // reset cache
notifyFilePublish(qPath)
}
//log.debug("\tOpening channel to: $installedPath")
// log.debug("\tOpening channel to: $installedPath")
FileChannel channel = FileChannel.open(installedPath, options)
return channel
}
Expand All @@ -374,10 +362,10 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr
@Override
DirectoryStream<Path> newDirectoryStream(Path obj, DirectoryStream.Filter<? super Path> filter) throws IOException {
final qPath = asQuiltPath(obj)
//final dirPath = qPath.localPath()
//Files.newDirectoryStream(dirPath, filter)
// final dirPath = qPath.localPath()
// Files.newDirectoryStream(dirPath, filter)

//log.debug("QuiltFileSystemProvider.newDirectoryStream[${qPath.file_key()}]: ${qPath}")
// log.debug("QuiltFileSystemProvider.newDirectoryStream[${qPath.file_key()}]: ${qPath}")

return new DirectoryStream<Path>() {

Expand All @@ -396,7 +384,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr
@Override
void createDirectory(Path dir, FileAttribute<?>... attrs) throws IOException {
final path = asQuiltPath(dir).localPath()
//log.debug("Calling createDirectory[${path}]: ${dir} ")
// log.debug("Calling createDirectory[${path}]: ${dir} ")
Files.createDirectories(path)
}
/* groovylint-enable BuilderMethodWithSideEffects */
Expand All @@ -411,7 +399,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr

@Override
void copy(Path from, Path to, CopyOption... options) throws IOException {
//log.debug("Attempting `copy`: ${from} -> ${to}")
// log.debug("Attempting `copy`: ${from} -> ${to}")
assert provider(from) == provider(to)
if (from == to) {
return // nothing to do -- just return
Expand Down Expand Up @@ -447,7 +435,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr

@Override
void checkAccess(Path path, AccessMode... modes) throws IOException {
//log.debug("Calling `checkAccess`: ${path}")
// log.debug("Calling `checkAccess`: ${path}")
checkRoot(path)
QuiltPath qPath = asQuiltPath(path)
readAttributes(qPath, QuiltFileAttributes)
Expand All @@ -458,7 +446,7 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr

@Override
def <V extends FileAttributeView> V getFileAttributeView(Path path, Class<V> type, LinkOption... options) {
//log.debug("Calling `getFileAttributeView`: ${path}")
// log.debug("Calling `getFileAttributeView`: ${path}")
checkRoot(path)
if (type == BasicFileAttributeView || type == QuiltFileAttributesView) {
QuiltPath qPath = asQuiltPath(path)
Expand All @@ -471,7 +459,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 @@ -484,15 +472,15 @@ class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTr
attributesCache[path] = result
return result
}
//log.debug("readAttributes: File ${qPath.localPath()} not found")
// log.debug("readAttributes: File ${qPath.localPath()} not found")
throw new NoSuchFileException(qPath.toUriString())
}
throw new UnsupportedOperationException("Not a valid Quilt Storage file attribute type: $type")
}
}

@Override
Map<String, Object> readAttributes(Path path, String attributes, LinkOption... options) throws IOException {
//log.debug 'Map<String, Object> QuiltFileSystemProvider.readAttributes()'
// log.debug 'Map<String, Object> QuiltFileSystemProvider.readAttributes()'
throw new UnsupportedOperationException("Operation Map 'readAttributes' is not supported by QuiltFileSystem")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,8 @@ final class QuiltPath implements Path, Comparable {

@Override
String toString() {
println("toString.parsed[isFileName=$isFileName]: $parsed")
String filename = paths.size() > 0 ? paths[-1] : ''
println("toString:filename: ${filename}")
if (isFileName) {
return filename
return paths.size() > 0 ? paths[-1] : ''
}
return parsed.toString()
}
Expand Down

0 comments on commit 19a588c

Please sign in to comment.