From 2b3bc570a39d3afa5b18efabd5a351dfda802311 Mon Sep 17 00:00:00 2001 From: Cedric Zhuang Date: Tue, 29 Aug 2023 18:12:06 +0800 Subject: [PATCH] sync the float binary. Sync the float binary with the opcenter when the plugin started. --- .../src/main/com/memverge/nextflow/FloatBin.groovy | 12 ++++++------ .../com/memverge/nextflow/FloatGridExecutor.groovy | 9 +++++++++ .../src/main/com/memverge/nextflow/Global.groovy | 4 ++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/plugins/nf-float/src/main/com/memverge/nextflow/FloatBin.groovy b/plugins/nf-float/src/main/com/memverge/nextflow/FloatBin.groovy index 54e16c9..5c71551 100644 --- a/plugins/nf-float/src/main/com/memverge/nextflow/FloatBin.groovy +++ b/plugins/nf-float/src/main/com/memverge/nextflow/FloatBin.groovy @@ -13,11 +13,12 @@ class FloatBin { private static final binName = 'float' static Path get(String opCenterAddr) { - if (!opCenterAddr) { - return Paths.get(binName) - } def ret = getFloatBinPath() if (ret == null) { + if (!opCenterAddr) { + // no where to retrieve the binary + return Paths.get(binName) + } final URL src = getDownloadUrl(opCenterAddr) final Path pluginsDir = Global.getPluginsDir() ret = pluginsDir.resolve(binName) @@ -45,9 +46,8 @@ class FloatBin { private static Path getFloatBinPath() { final sep = Pattern.quote(File.pathSeparator) - def paths = Arrays.asList(System.getenv("PATH").split(sep)) - paths = new ArrayList(paths) - paths.add(Global.getPluginsDir().toString()) + def paths = [Global.getPluginsDir().toString()] + paths.addAll(Arrays.asList(System.getenv("PATH").split(sep))) for (String path : paths) { def floatPath = Paths.get(path).resolve(binName) if (Files.exists(floatPath)) { diff --git a/plugins/nf-float/src/main/com/memverge/nextflow/FloatGridExecutor.groovy b/plugins/nf-float/src/main/com/memverge/nextflow/FloatGridExecutor.groovy index 99e55d9..cbece07 100644 --- a/plugins/nf-float/src/main/com/memverge/nextflow/FloatGridExecutor.groovy +++ b/plugins/nf-float/src/main/com/memverge/nextflow/FloatGridExecutor.groovy @@ -60,6 +60,7 @@ class FloatGridExecutor extends AbstractGridExecutor { protected void register() { super.register() uploadBinDir() + syncFloatBin() } @Override @@ -113,6 +114,14 @@ class FloatGridExecutor extends AbstractGridExecutor { } } + private void syncFloatBin() { + final oc = floatJobs.getOc("") + def cmd = floatConf.getCliPrefix(oc) + cmd << "release" << "sync" + def res = Global.execute(cmd) + log.info "[float] sync the float binary, $res" + } + private static String getMemory(TaskRun task) { final mem = task.config.getMemory() final giga = mem?.toGiga() diff --git a/plugins/nf-float/src/main/com/memverge/nextflow/Global.groovy b/plugins/nf-float/src/main/com/memverge/nextflow/Global.groovy index e8f48b8..5e28e49 100644 --- a/plugins/nf-float/src/main/com/memverge/nextflow/Global.groovy +++ b/plugins/nf-float/src/main/com/memverge/nextflow/Global.groovy @@ -36,6 +36,10 @@ class CmdRes { return exit == 0 } + String toString() { + return "exit code: ${exit}, out: ${out}" + } + int exit String out }