-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When the plugin starts, it checks if float cli is available in path. If not, try to download it from the op-center. The binary is kept in the plugin's directory.
- Loading branch information
Showing
9 changed files
with
180 additions
and
46 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
plugins/nf-float/src/main/com/memverge/nextflow/FloatBin.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.memverge.nextflow | ||
|
||
import groovy.util.logging.Slf4j | ||
import org.apache.commons.lang.SystemUtils | ||
|
||
import java.nio.file.Files | ||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
import java.util.regex.Pattern | ||
|
||
@Slf4j | ||
class FloatBin { | ||
private static final binName = 'float' | ||
|
||
static Path get(String opCenterAddr) { | ||
if (!opCenterAddr) { | ||
return Paths.get(binName) | ||
} | ||
def ret = getFloatBinPath() | ||
if (ret == null) { | ||
final URL src = getDownloadUrl(opCenterAddr) | ||
final Path pluginsDir = Global.getPluginsDir() | ||
ret = pluginsDir.resolve(binName) | ||
try { | ||
Global.download(src, ret) | ||
ret.setExecutable(true) | ||
} catch (Exception ex) { | ||
log.warn("download ${binName} failed: ${ex.message}") | ||
return Paths.get(binName) | ||
} | ||
} | ||
return ret | ||
} | ||
|
||
private static URL getDownloadUrl(String opCenter) { | ||
if (SystemUtils.IS_OS_WINDOWS) { | ||
return new URL("https://${opCenter}/float.windows_amd64") | ||
} else if (SystemUtils.IS_OS_LINUX) { | ||
return new URL("https://${opCenter}/float") | ||
} else if (SystemUtils.IS_OS_MAC) { | ||
return new URL("https://${opCenter}/float.darwin_amd64") | ||
} | ||
throw new UnsupportedOperationException("OS not supported") | ||
} | ||
|
||
private static Path getFloatBinPath() { | ||
final sep = Pattern.quote(File.pathSeparator) | ||
def paths = Arrays.asList(System.getenv("PATH").split(sep)) | ||
paths = new ArrayList<String>(paths) | ||
paths.add(Global.getPluginsDir().toString()) | ||
for (String path : paths) { | ||
def floatPath = Paths.get(path).resolve(binName) | ||
if (Files.exists(floatPath)) { | ||
return floatPath | ||
} | ||
} | ||
log.info "${binName} binary not found" | ||
return null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,8 @@ import nextflow.exception.AbortOperationException | |
import nextflow.io.BucketParser | ||
import org.apache.commons.lang.StringUtils | ||
|
||
import java.nio.file.Path | ||
|
||
/** | ||
* @author Cedric Zhuang <[email protected]> | ||
*/ | ||
|
@@ -53,6 +55,8 @@ class FloatConf { | |
String extraOptions | ||
String commonExtra | ||
|
||
Path floatBin | ||
|
||
float timeFactor = 1 | ||
|
||
/** | ||
|
@@ -196,8 +200,9 @@ class FloatConf { | |
if (StringUtils.length(address) == 0) { | ||
address = addresses[0] | ||
} | ||
def bin = FloatBin.get(address) | ||
List<String> ret = [ | ||
"float", | ||
bin.toString(), | ||
"-a", | ||
address, | ||
"-u", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.