From 4de2b84de17ddf6d63c38f7370d9297f1b95b164 Mon Sep 17 00:00:00 2001 From: "Dr. Ernie Prabhakar" <19791+drernie@users.noreply.github.com> Date: Thu, 5 Dec 2024 21:23:08 -0800 Subject: [PATCH] groovy4 fixes --- .vscode/settings.json | 4 ++-- .../nextflow/quilt/QuiltObserverFactory.groovy | 2 +- .../src/main/nextflow/quilt/QuiltPathify.groovy | 14 +++++++------- .../src/main/nextflow/quilt/QuiltProduct.groovy | 16 ++++++++-------- .../src/main/nextflow/quilt/jep/QuiltID.groovy | 6 +++--- .../main/nextflow/quilt/jep/QuiltPackage.groovy | 16 +++++++--------- .../main/nextflow/quilt/jep/QuiltParser.groovy | 2 +- .../nextflow/quilt/nio/QuiltFileSystem.groovy | 4 ++-- .../quilt/nio/QuiltFileSystemProvider.groovy | 2 +- .../src/main/nextflow/quilt/nio/QuiltPath.groovy | 6 +++--- 10 files changed, 35 insertions(+), 37 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 75441df0..9031f20e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,4 @@ { - "java.compile.nullAnalysis.mode": "disabled", - "java.configuration.updateBuildConfiguration": "disabled" + "java.compile.nullAnalysis.mode": "enabled", + "java.configuration.updateBuildConfiguration": "enabled" } diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltObserverFactory.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltObserverFactory.groovy index 92db5024..165020da 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltObserverFactory.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltObserverFactory.groovy @@ -33,7 +33,7 @@ class QuiltObserverFactory implements TraceObserverFactory { @Override Collection create(Session session) { //log.debug("`create` ${this}") - Collection quiltObservers = new ArrayList<>() + Collection quiltObservers = new ArrayList() quiltObservers.add(new QuiltObserver()) return quiltObservers as Collection diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltPathify.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltPathify.groovy index 6523e71c..8924a0cf 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltPathify.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltPathify.groovy @@ -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") } } @@ -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 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 @@ -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 @@ -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 diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy index 5240bbe1..7be0a75d 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy @@ -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}") } @@ -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") } } @@ -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()") } } @@ -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, diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltID.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltID.groovy index 19c867fb..57b1f523 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltID.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltID.groovy @@ -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)) { 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 17894f50..1a65cc77 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy @@ -78,12 +78,12 @@ class QuiltPackage { List 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() } @@ -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 } @@ -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 pathsToDelete = listDirectory(rootPath) @@ -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 } @@ -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) @@ -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) diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltParser.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltParser.groovy index b0ee2e81..157309cb 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltParser.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltParser.groovy @@ -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) diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystem.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystem.groovy index 98587d88..96030a55 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystem.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystem.groovy @@ -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 } diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystemProvider.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystemProvider.groovy index 8c4d664c..bf8b9d0a 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystemProvider.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltFileSystemProvider.groovy @@ -63,7 +63,7 @@ import nextflow.file.FileHelper @CompileStatic class QuiltFileSystemProvider extends FileSystemProvider implements FileSystemTransferAware { - private final Map myEnv = new HashMap<>(System.getenv()) + private final Map myEnv = new HashMap(System.getenv()) private final Map fileSystems = [:] private Map attributesCache = [:] diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy index 7fc10658..c3d0450a 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/nio/QuiltPath.groovy @@ -55,11 +55,11 @@ final class QuiltPath implements Path, Comparable { } 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') @@ -67,7 +67,7 @@ final class QuiltPath implements Path, Comparable { List parts = matches[0] as List println("\tfindQuiltPath.parts: $parts") base = parts[1] - log.info("\tfindQuiltPath: trimmed to $base") + println("\tfindQuiltPath: trimmed to $base") } return base }