Skip to content

Commit

Permalink
WIP: Use quiltcore to install packages
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaryaz committed Jul 20, 2023
1 parent 6c8efb4 commit 083e826
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
8 changes: 8 additions & 0 deletions plugins/nf-quilt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ ext{
}

dependencies {
// quiltcore
implementation files('/home/dima/src/quiltcore-java/lib/build/libs/lib.jar')

// quiltcore dependencies - why is this necessary???
implementation 'software.amazon.nio.s3:aws-java-nio-spi-for-s3:1.2.3'
implementation 'software.amazon.awssdk:s3:2.20.102'
implementation 'software.amazon.awssdk:s3-transfer-manager:2.20.102'

// This dependency is exported to consumers, that is to say found on their compile classpath.
compileOnly "io.nextflow:nextflow:$nextflowVersion"
compileOnly 'org.slf4j:slf4j-api:2.0.7'
Expand Down
46 changes: 37 additions & 9 deletions plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ import java.nio.file.attribute.BasicFileAttributes
import java.util.stream.Collectors
import java.time.LocalDate

import nextflow.file.FileHelper
import nextflow.plugin.CustomPluginManager
import nextflow.plugin.Plugins

import com.quiltdata.quiltcore.Registry
import com.quiltdata.quiltcore.Namespace
import com.quiltdata.quiltcore.Manifest

@Slf4j
@CompileStatic
class QuiltPackage {
Expand All @@ -45,6 +53,17 @@ class QuiltPackage {
private boolean installed
private String cmd = 'N/A'

// static {
// Path path = Paths.get("nf-plugins")
// Files.createDirectories(path)
// Path root = path.toAbsolutePath().normalize()

// CustomPluginManager manager = new CustomPluginManager(root)
// manager.loadPlugins()

// Plugins.init(root, "prod", manager)
// }

static String today() {
LocalDate date = LocalDate.now()
return date.toString()
Expand Down Expand Up @@ -86,7 +105,7 @@ class QuiltPackage {
log.debug("Installing `${pkg}` for.pkgKey $pkgKey")
pkg.install()
}
catch (Exception e) {
catch (IOException e) {
log.warn("Package `${parsed.toUriString()}` does not yet exist")
}
return pkg
Expand Down Expand Up @@ -247,17 +266,26 @@ class QuiltPackage {
}
}

// usage: quilt3 install [-h] [--registry REGISTRY] [--top-hash TOP_HASH]
// [--dest DEST] [--dest-registry DEST_REGISTRY] [--path PATH] name
Path install() {
int exitCode = call('install', packageName, key_registry(), key_hash(), key_dest())
if (exitCode != 0) {
log.error("`install.fail.exitCode` ${exitCode}: ${packageName}")
return null
}
log.info("installing $packageName ...")
// Path registryPath = Path.of(new URI("s3://${bucket}")) // tries to use s3fs!
Path registryPath = FileHelper.asPath("s3://${bucket}")
log.info("registryPath: $registryPath")
Registry registry = new Registry(registryPath)
Namespace namespace = registry.getNamespace(packageName)
String resolvedHash = (hash == 'latest' || hash == null || hash == 'null') ? namespace.getHash('latest') : hash
log.info("hash: $hash -> $resolvedHash")
Manifest manifest = namespace.getManifest(resolvedHash)
Path dest = packageDest()
log.info("dest: $dest")

manifest.install(dest)
log.info("done")

installed = true
recursiveDeleteOnExit()
return packageDest()

return dest
}

// https://stackoverflow.com/questions/15022219
Expand Down

0 comments on commit 083e826

Please sign in to comment.