-
Notifications
You must be signed in to change notification settings - Fork 643
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set AWS container properties from container options (#2471)
This commit adds the support for `containerOptions` directive for AWS Batch jobs This is useful to fine control the container execution properties using the same the option used for the Docker container runtime. Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com> Co-authored-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
- Loading branch information
1 parent
967c1ad
commit ac7f1e7
Showing
15 changed files
with
705 additions
and
68 deletions.
There are no files selected for viewing
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
82 changes: 82 additions & 0 deletions
82
modules/nf-commons/src/main/nextflow/util/CmdLineOptionMap.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,82 @@ | ||
package nextflow.util | ||
|
||
|
||
import com.google.common.hash.Hasher | ||
import groovy.transform.CompileStatic | ||
import groovy.transform.EqualsAndHashCode | ||
import groovy.transform.ToString | ||
|
||
/** | ||
* Holder for parsed command line options. | ||
* | ||
* @author Manuele Simi <manuele.simi@gmail.com> | ||
*/ | ||
@CompileStatic | ||
@ToString(includes = 'options', includeFields = true) | ||
@EqualsAndHashCode(includes = 'options', includeFields = true) | ||
class CmdLineOptionMap implements CacheFunnel { | ||
|
||
final private Map<String, List<String>> options = new LinkedHashMap<String, List<String>>() | ||
final private static CmdLineOptionMap EMPTY = new CmdLineOptionMap() | ||
|
||
protected CmdLineOptionMap addOption(String key, String value) { | ||
if ( !options.containsKey(key) ) | ||
options[key] = new ArrayList<String>(10) | ||
options[key].add(value) | ||
return this | ||
} | ||
|
||
boolean hasMultipleValues(String key) { | ||
options.containsKey(key) ? options[key].size() > 1 : false | ||
} | ||
|
||
boolean hasOptions() { | ||
options.size() | ||
} | ||
|
||
List<String> getValues(String key) { | ||
return options.containsKey(key) ? options[key] : Collections.emptyList() as List<String> | ||
} | ||
|
||
def getFirstValue(String key) { | ||
getFirstValueOrDefault(key, null) | ||
} | ||
|
||
boolean asBoolean() { | ||
return options.size()>0 | ||
} | ||
|
||
boolean exists(String key) { | ||
options.containsKey(key) | ||
} | ||
|
||
def getFirstValueOrDefault(String key, String alternative) { | ||
options.containsKey(key) && options[key].get(0) ? options[key].get(0) : alternative | ||
} | ||
|
||
static CmdLineOptionMap fromMap(final Map map) { | ||
def optionMap = new CmdLineOptionMap() | ||
map.each { | ||
optionMap.addOption(it.key as String, it.value as String) | ||
} | ||
return optionMap | ||
} | ||
|
||
static CmdLineOptionMap emptyOption() { | ||
return EMPTY | ||
} | ||
|
||
@Override | ||
String toString() { | ||
def serialized = [] | ||
options.each { | ||
serialized << "option{${it.key}: ${it.value.each {it}}}" | ||
} | ||
return "[${serialized.join(', ')}]" | ||
} | ||
|
||
@Override | ||
Hasher funnel(Hasher hasher, CacheHelper.HashMode mode) { | ||
return CacheHelper.hasher(hasher, options, mode) | ||
} | ||
} |
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.