Skip to content

Commit

Permalink
groovy4 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
drernie committed Dec 6, 2024
1 parent a2d0ccd commit 4de2b84
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"java.compile.nullAnalysis.mode": "disabled",
"java.configuration.updateBuildConfiguration": "disabled"
"java.compile.nullAnalysis.mode": "enabled",
"java.configuration.updateBuildConfiguration": "enabled"
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class QuiltObserverFactory implements TraceObserverFactory {
@Override
Collection<TraceObserver> create(Session session) {
//log.debug("`create` ${this}")
Collection<QuiltObserver> quiltObservers = new ArrayList<>()
Collection<QuiltObserver> quiltObservers = new ArrayList<QuiltObserver>()
quiltObservers.add(new QuiltObserver())

return quiltObservers as Collection<TraceObserver>
Expand Down
14 changes: 7 additions & 7 deletions plugins/nf-quilt/src/main/nextflow/quilt/QuiltPathify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class QuiltPathify {
Files.copy(source, dest)
}
catch (Exception e) {
log.error("writeString: cannot write `$source` to `$dest` in `${destRoot}`\n$e")
println("writeString: cannot write `$source` to `$dest` in `${destRoot}`\n$e")
}
}

Expand All @@ -73,12 +73,12 @@ class QuiltPathify {
* - path: inputs/a_folder/THING_TWO.md
*/
static String uriFromS3File(String s3path) {
log.debug("uriFromS3File: $s3path")
println("uriFromS3File: $s3path")
String[] partsArray = s3path.split('/')
List<String> parts = new ArrayList(partsArray.toList())
// parts.eachWithIndex { p, i -> println("uriFromS3File.parts[$i]: $p") }
if (parts.size() < 2) {
log.error("uriFromS3File: invalid path: $s3path")
println("uriFromS3File: invalid path: $s3path")
return ''
}
parts.remove(0) // remove leading slash
Expand All @@ -90,7 +90,7 @@ class QuiltPathify {
String folder = parts.join('/')
String sub_path = folder.length() > 0 ? folder + '/' + file : file

log.debug("uriFromS3File: $bucket/$prefix/$suffix/$sub_path")
// println("uriFromS3File: $bucket/$prefix/$suffix/$sub_path")
String base = "quilt+s3://${bucket}#package=${prefix}%2f${suffix}"
String uri = base + '&path=' + sub_path
return uri
Expand All @@ -101,11 +101,11 @@ class QuiltPathify {
println("QuiltPathify: $path")
if (path in QuiltPath) {
this.path = (QuiltPath) path
println("\tQuiltPathify.QuiltPath: $this.path")
println("\tQuiltPathify.QuiltPath: ${this}.path")
this.uri = this.path.toUriString()
println("\t\tQuiltPathify.QuiltPath.uri: $this.uri")
println("\t\tQuiltPathify.QuiltPath.uri: ${this}.uri")
this.pkg = this.path.pkg()
println("\t\tQuiltPathify.QuiltPath.pkg: $this.pkg")
println("\t\tQuiltPathify.QuiltPath.pkg: ${this}.pkg")
} else if (!findQuiltPath(path.getFileName().toString())) {
makeQuiltPath(path.toString())
this.isOverlay = true
Expand Down
16 changes: 8 additions & 8 deletions plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ ${nextflow}
]

static void printMap(Map map, String title) {
log.info("\n\n\n# $title ${map.keySet()}")
println("\n\n\n# $title ${map.keySet()}")
map.each {
key, value -> log.info("\n## ${key}: ${value}")
}
Expand All @@ -115,7 +115,7 @@ ${nextflow}
Files.write(path, text.bytes)
}
catch (Exception e) {
log.error("writeString: cannot write `$text` to `$path` for `${pkg}`\n$e")
println("writeString: cannot write `$text` to `$path` for `${pkg}`\n$e")
}
}

Expand All @@ -126,7 +126,7 @@ ${nextflow}
Files.copy(source, dest)
}
catch (Exception e) {
log.error("writeString: cannot write `$source` to `$dest` in `${destRoot}`\n$e.message()")
println("writeString: cannot write `$source` to `$dest` in `${destRoot}`\n$e.message()")
}
}

Expand Down Expand Up @@ -325,11 +325,11 @@ ${nextflow}
return null
}
String raw_readme = flags.getProperty(KEY_README)
String nf = metadata['workflow']?['nextflow']
String nextflow = nf?.replace(', ', '```\n - **')\
?.replace('nextflow.NextflowMeta(', ' - **')\
?.replace(')', '```')
?.replace(':', '**: ```')
String nf = metadata['workflow']?.get('nextflow')
String nextflow = nf != null ? nf.replace(', ', '```\n - **')
.replace('nextflow.NextflowMeta(', ' - **')
.replace(')', '```')
.replace(':', '**: ```') : null
Map params = getTemplateArgs()
params += [
msg: msg,
Expand Down
6 changes: 3 additions & 3 deletions plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltID.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ class QuiltID {

static QuiltID fetch(String bucket, String packageName) {
if (!bucket) {
log.error("null == QuiltID.fetch($bucket, $packageName)")
println("null == QuiltID.fetch($bucket, $packageName)")
return null
}
String pkgName = packageName
if (!packageName || packageName.size() < QuiltParser.MIN_SIZE) {
pkgName = DEFAULT_PACKAGE.join(QuiltParser.SEP)
log.warn("QuiltID.fetch: setting missing package to $pkgName")
println("QuiltID.fetch: setting missing package to $pkgName")
}
String[] split = pkgName.split(QuiltParser.SEP)
if (split.size() < QuiltParser.MIN_SIZE || split[1].size() < QuiltParser.MIN_SIZE) {
split += DEFAULT_PACKAGE[1] as String
log.warn("QuiltID.fetch: setting missing suffix to $split[1]")
println("QuiltID.fetch: setting missing suffix to $split[1]")
}
String key = "${bucket}/${split[0]}/${split[1]}"
if (!QIDS.containsKey(key)) {
Expand Down
16 changes: 7 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 @@ -78,12 +78,12 @@ class QuiltPackage {
List<String> entries = dict.collect { key, value ->
String prefix = JsonOutput.toJson(key)
String suffix = "toJson.error: ${value}"
log.debug("QuiltPackage.toJson: ${prefix} [${suffix.length()}]")
println("QuiltPackage.toJson: ${prefix} [${suffix.length()}]")
try {
suffix = JsonOutput.toJson(value)
}
catch (Exception e) {
log.error(suffix, e)
println("$suffix:\n$e")
}
return "${prefix}:${suffix}".toString()
}
Expand All @@ -102,7 +102,7 @@ class QuiltPackage {
}

String pkgKey = parsed.toPackageString(true) // ignore metadata for Key
log.info("QuiltPackage.forParsed[${pkgKey}]")
println("QuiltPackage.forParsed[${pkgKey}]")
def pkg = PKGS.get(pkgKey)
if (pkg) { return pkg }

Expand All @@ -120,7 +120,7 @@ class QuiltPackage {
if (!Files.exists(rootPath)) { return false }
}
catch (SecurityException e) {
log.warn("Cannnot verify whether `$rootPath` exists: $e")
println("Cannnot verify whether `$rootPath` exists: $e")
}
try {
final List<Path> pathsToDelete = listDirectory(rootPath)
Expand All @@ -129,7 +129,7 @@ class QuiltPackage {
}
}
catch (NoSuchFileException e) {
log.debug "deleteDirectory: ignore non-existent files\n$e"
println "deleteDirectory: ignore non-existent files\n$e"
}
return true
}
Expand Down Expand Up @@ -233,9 +233,7 @@ class QuiltPackage {
S3PhysicalKey registryPath = new S3PhysicalKey(bucket, '', null)
Registry registry = new Registry(registryPath)
Namespace namespace = registry.getNamespace(packageName)
String resolvedHash = (hash == 'latest' || hash == null || hash == 'null')
? namespace.getHash('latest')
: hash
String resolvedHash = (hash == 'latest' || hash == null || hash == 'null') ? namespace.getHash('latest') : hash
log.debug("hash: $hash -> $resolvedHash")
Manifest manifest = namespace.getManifest(resolvedHash)

Expand Down Expand Up @@ -294,7 +292,7 @@ class QuiltPackage {

Manifest.Builder builder = Manifest.builder()

Files.walk(packageDest()).filter(f -> Files.isRegularFile(f)).forEach(f -> {
Files.walk(packageDest()).filter({ f -> Files.isRegularFile(f) }).forEach({ f ->
log.debug("push: ${f} -> ${packageDest()}")
String logicalKey = packageDest().relativize(f)
LocalPhysicalKey physicalKey = new LocalPhysicalKey(f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class QuiltParser {
}

static QuiltParser forURI(URI uri) {
log.debug("forURI[${uri.scheme}] for ${uri}")
println("forURI[${uri.scheme}] for ${uri}")
if (uri.scheme != SCHEME) {
String msg = "Scheme[${uri}] URI:${uri.scheme}] != SCHEME:${SCHEME}"
throw new IllegalArgumentException(msg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ final class QuiltFileSystem extends FileSystem implements Closeable {
}

static QuiltFileAttributes readAttributes(QuiltPath path) {
log.debug("QuiltFileAttributes QuiltFileSystem.readAttributes($path)")
//println("QuiltFileAttributes QuiltFileSystem.readAttributes($path)")
Path installedPath = path.localPath()
try {
BasicFileAttributes attrs = Files.readAttributes(installedPath, BasicFileAttributes)
return new QuiltFileAttributes(path, path.toString(), attrs)
}
catch (NoSuchFileException e) {
log.debug("No attributes yet for: ${installedPath}\n$e")
println("No attributes yet for: ${installedPath}\n$e")
}
return null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import nextflow.file.FileHelper
@CompileStatic
class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTransferAware {

private final Map<String,String> myEnv = new HashMap<>(System.getenv())
private final Map<String,String> myEnv = new HashMap<String,String>(System.getenv())
private final Map<String,QuiltFileSystem> fileSystems = [:]
private Map<Path,BasicFileAttributes> attributesCache = [:]

Expand Down
6 changes: 3 additions & 3 deletions plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ final class QuiltPath implements Path, Comparable <Path> {
}
String base = filename
if (n_package > 1) {
log.info("\tfindQuiltPath: multiple '#package' in $base")
println("\tfindQuiltPath: multiple '#package' in $base")
println('\t\tTO MATCH')
Matcher matches = (filename =~ /^([^#]+#package=.*)?(?:(?!%2f).)*#package=/)
if (!matches) {
log.error("findQuiltPath: no match found for $filename")
println("findQuiltPath: no match found for $filename")
return null
}
println('\t\tDID MATCH')
println("\tfindQuiltPath.matches: $matches")
List<String> parts = matches[0] as List<String>
println("\tfindQuiltPath.parts: $parts")
base = parts[1]
log.info("\tfindQuiltPath: trimmed to $base")
println("\tfindQuiltPath: trimmed to $base")
}
return base
}
Expand Down

0 comments on commit 4de2b84

Please sign in to comment.