-
Notifications
You must be signed in to change notification settings - Fork 620
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add disk resource with type option for google batch (#3861)
Signed-off-by: Ben Sherman <[email protected]> Signed-off-by: Paolo Di Tommaso <[email protected]> Signed-off-by: Jordi Deu-Pons <[email protected]> Co-authored-by: Jordi Deu-Pons <[email protected]> Co-authored-by: Paolo Di Tommaso <[email protected]>
- Loading branch information
1 parent
d3788f9
commit 166b363
Showing
12 changed files
with
443 additions
and
103 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
60 changes: 60 additions & 0 deletions
60
modules/nextflow/src/main/groovy/nextflow/executor/res/DiskResource.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 @@ | ||
/* | ||
* Copyright 2013-2023, Seqera Labs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package nextflow.executor.res | ||
|
||
import groovy.transform.CompileStatic | ||
import groovy.transform.EqualsAndHashCode | ||
import groovy.transform.ToString | ||
import nextflow.util.MemoryUnit | ||
|
||
/** | ||
* Models disk resource request | ||
* | ||
* @author Ben Sherman <[email protected]> | ||
*/ | ||
@ToString(includeNames = true, includePackage = false) | ||
@CompileStatic | ||
@EqualsAndHashCode | ||
class DiskResource { | ||
|
||
final MemoryUnit request | ||
final String type | ||
|
||
DiskResource( value ) { | ||
this(request: value) | ||
} | ||
|
||
DiskResource( Map opts ) { | ||
this.request = toMemoryUnit(opts.request) | ||
|
||
if( opts.type ) | ||
this.type = opts.type as String | ||
} | ||
|
||
private static MemoryUnit toMemoryUnit( value ) { | ||
if( value instanceof MemoryUnit ) | ||
return (MemoryUnit)value | ||
|
||
try { | ||
return new MemoryUnit(value.toString().trim()) | ||
} | ||
catch( Exception e ) { | ||
throw new IllegalArgumentException("Not a valid disk value: $value") | ||
} | ||
} | ||
|
||
} |
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
46 changes: 46 additions & 0 deletions
46
modules/nextflow/src/test/groovy/nextflow/executor/res/DiskResourceTest.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,46 @@ | ||
/* | ||
* Copyright 2013-2023, Seqera Labs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package nextflow.executor.res | ||
|
||
import nextflow.util.MemoryUnit | ||
import spock.lang.Specification | ||
|
||
/** | ||
* | ||
* @author Ben Sherman <[email protected]> | ||
*/ | ||
class DiskResourceTest extends Specification { | ||
|
||
static final _100_GB = MemoryUnit.of('100GB') | ||
static final _375_GB = MemoryUnit.of('375GB') | ||
|
||
def 'should create a disk resource' () { | ||
|
||
when: | ||
def disk = new DiskResource(VALUE) | ||
then: | ||
disk.request == REQ | ||
disk.type == TYPE | ||
|
||
where: | ||
VALUE | REQ | TYPE | ||
_100_GB | _100_GB | null | ||
[request: _100_GB] | _100_GB | null | ||
[request: _375_GB, type: 'local-ssd'] | _375_GB | 'local-ssd' | ||
} | ||
|
||
} |
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.