-
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.
Signed-off-by: Paolo Di Tommaso <[email protected]>
- Loading branch information
1 parent
a90fd56
commit fbe5d5c
Showing
7 changed files
with
389 additions
and
23 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
modules/nextflow/src/main/groovy/nextflow/config/scope/nextflow/DefaultOpts.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,39 @@ | ||
/* | ||
* Copyright 2013-2024, 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.config.scope.nextflow | ||
|
||
import groovy.transform.CompileStatic | ||
import groovy.transform.EqualsAndHashCode | ||
import groovy.transform.ToString | ||
|
||
/** | ||
* Model nextflow default options | ||
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
*/ | ||
@ToString(includePackage = false, includeNames = true) | ||
@EqualsAndHashCode | ||
@CompileStatic | ||
class DefaultOpts { | ||
|
||
final PublishDirOpts publishDir | ||
|
||
DefaultOpts(Map opts) { | ||
publishDir = new PublishDirOpts( opts.publishDir as Map ?: Map.of()) | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
modules/nextflow/src/main/groovy/nextflow/config/scope/nextflow/NextflowOpts.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,40 @@ | ||
/* | ||
* Copyright 2013-2024, 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.config.scope.nextflow | ||
|
||
import groovy.transform.CompileStatic | ||
import groovy.transform.EqualsAndHashCode | ||
import groovy.transform.ToString | ||
|
||
/** | ||
* Model nextflow options | ||
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
*/ | ||
@ToString(includePackage = false, includeNames = true) | ||
@EqualsAndHashCode | ||
@CompileStatic | ||
class NextflowOpts { | ||
|
||
final DefaultOpts defaults | ||
|
||
NextflowOpts(Map<String,Object> opts) { | ||
defaults = new DefaultOpts(opts.defaults as Map<String,Object> ?: Map.<String,Object>of()) | ||
} | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
modules/nextflow/src/main/groovy/nextflow/config/scope/nextflow/PublishDirOpts.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,62 @@ | ||
/* | ||
* Copyright 2013-2024, 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.config.scope.nextflow | ||
|
||
import groovy.transform.CompileStatic | ||
import groovy.transform.EqualsAndHashCode | ||
import groovy.transform.ToString | ||
|
||
/** | ||
* Model publishDir options | ||
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
*/ | ||
@ToString(includePackage = false, includeNames = true) | ||
@EqualsAndHashCode | ||
@CompileStatic | ||
class PublishDirOpts { | ||
|
||
static final public PublishDirOpts EMPTY = new PublishDirOpts(Map.of()) | ||
|
||
|
||
final String mode | ||
final Boolean enabled | ||
final Boolean failOnError | ||
final String pattern | ||
final Object contentType | ||
final Boolean overwrite | ||
final String storageClass | ||
final Map<String,String> tags | ||
|
||
PublishDirOpts(Map opts) { | ||
mode = opts.mode | ||
enabled = asBool(opts.enabled) | ||
failOnError = asBool(opts.failOnError) | ||
overwrite = asBool(opts.overwrite) | ||
pattern = opts.pattern | ||
contentType = opts.contentType | ||
storageClass = opts.storageClass | ||
tags = opts.tags as Map<String,String> | ||
} | ||
|
||
private Boolean asBool(Object value) { | ||
if( value==null ) | ||
return null | ||
return Boolean.valueOf(value as String) | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
modules/nextflow/src/test/groovy/nextflow/config/scope/nextflow/DefaultOptsTest.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,41 @@ | ||
/* | ||
* Copyright 2013-2024, 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.config.scope.nextflow | ||
|
||
import spock.lang.Specification | ||
|
||
/** | ||
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
*/ | ||
class DefaultOptsTest extends Specification { | ||
|
||
def 'should validate equals and hashcode' () { | ||
given: | ||
def o1 = new DefaultOpts([publishDir: [mode:'foo']]) | ||
def o2 = new DefaultOpts([publishDir: [mode:'foo']]) | ||
def o3 = new DefaultOpts([publishDir: [mode:'bar']]) | ||
|
||
expect: | ||
o1 == o2 | ||
o1 != o3 | ||
and: | ||
o1.hashCode() == o2.hashCode() | ||
o1.hashCode() != o3.hashCode() | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
modules/nextflow/src/test/groovy/nextflow/config/scope/nextflow/NextflowOptsTest.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,80 @@ | ||
/* | ||
* Copyright 2013-2024, 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.config.scope.nextflow | ||
|
||
import spock.lang.Specification | ||
|
||
/** | ||
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
*/ | ||
class NextflowOptsTest extends Specification { | ||
|
||
def 'should validate equals and hashcode' () { | ||
given: | ||
def o1 = new NextflowOpts([defaults: [publishDir: [mode:'foo']]]) | ||
def o2 = new NextflowOpts([defaults: [publishDir: [mode:'foo']]]) | ||
def o3 = new NextflowOpts([defaults: [publishDir: [mode:'bar']]]) | ||
|
||
expect: | ||
o1 == o2 | ||
o1 != o3 | ||
and: | ||
o1.hashCode() == o2.hashCode() | ||
o1.hashCode() != o3.hashCode() | ||
} | ||
|
||
def 'should create empty nextflow opts' () { | ||
when: | ||
def nextflow = new NextflowOpts([:]) | ||
then: | ||
!nextflow.defaults.publishDir.enabled | ||
!nextflow.defaults.publishDir.mode | ||
!nextflow.defaults.publishDir.failOnError | ||
!nextflow.defaults.publishDir.contentType | ||
!nextflow.defaults.publishDir.overwrite | ||
!nextflow.defaults.publishDir.contentType | ||
!nextflow.defaults.publishDir.storageClass | ||
!nextflow.defaults.publishDir.tags | ||
} | ||
|
||
def 'should create nextflow publishdir opts' () { | ||
when: | ||
def nextflow = new NextflowOpts([ | ||
defaults: [ | ||
publishDir: [ | ||
mode:'foo', | ||
enabled: 'true', | ||
failOnError: 'true', | ||
contentType: 'some-content', | ||
overwrite: 'true', | ||
storageClass: 'some-storage', | ||
tags: ['this':'one', 'that': 'two'] | ||
] | ||
]]) | ||
then: | ||
nextflow.defaults.publishDir.mode == 'foo' | ||
nextflow.defaults.publishDir.enabled | ||
nextflow.defaults.publishDir.failOnError | ||
nextflow.defaults.publishDir.contentType == 'some-content' | ||
nextflow.defaults.publishDir.overwrite | ||
nextflow.defaults.publishDir.storageClass == 'some-storage' | ||
nextflow.defaults.publishDir.tags == ['this':'one', 'that': 'two'] | ||
} | ||
|
||
} |
Oops, something went wrong.