Skip to content

Commit

Permalink
Upgrade nextflow version to 22.08.1-edge
Browse files Browse the repository at this point in the history
Closes #8

Signed-off-by: Jorge Aguilera <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
jorgeaguileraseqera authored and pditommaso committed Aug 30, 2022
1 parent 8bbf450 commit 8778cfa
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 21 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ This repository only holds plugin artefacts. Source code is available at this [l

## Get started

Make sure to have Nextflow `22.05.0-edge` or later. Add the following snippet to your `nextflow.config` file.
Make sure to have Nextflow `22.08.1-edge` or later. Add the following snippet to your `nextflow.config` file.

```
plugins {
id 'nf-sqldb@0.4.1'
id 'nf-sqldb@0.5.0'
}
```

Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
NF-SQLDB CHANGE-LOG
===================
0.5.0 - 30 Aug 2022
- Bump nextflow required version to 22.08.1-edge

0.4.1 - 25 May 2022
- Fix AWS Athena driver dependency

Expand Down
10 changes: 8 additions & 2 deletions plugins/nf-sqldb/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ sourceSets {
test.resources.srcDirs = []
}

ext{
nextflowVersion = '22.08.1-edge'
}

dependencies {
compileOnly 'io.nextflow:nextflow:22.04.0'
compileOnly "io.nextflow:nextflow:$nextflowVersion"
compileOnly 'org.slf4j:slf4j-api:1.7.10'
compileOnly 'org.pf4j:pf4j:3.4.1'

Expand All @@ -69,7 +72,7 @@ dependencies {
api 'org.duckdb:duckdb_jdbc:0.3.0'
api files('src/dist/lib/AthenaJDBC42_2.0.25.1001.jar')

testImplementation 'io.nextflow:nextflow:22.06.0-edge'
testImplementation "io.nextflow:nextflow:$nextflowVersion"
testImplementation "org.codehaus.groovy:groovy:3.0.10"
testImplementation "org.codehaus.groovy:groovy-nio:3.0.10"
testImplementation ("org.codehaus.groovy:groovy-test:3.0.10") { exclude group: 'org.codehaus.groovy' }
Expand All @@ -78,6 +81,9 @@ dependencies {
testImplementation ("org.spockframework:spock-core:2.1-groovy-3.0") { exclude group: 'org.codehaus.groovy'; exclude group: 'net.bytebuddy' }
testImplementation ('org.spockframework:spock-junit4:2.1-groovy-3.0') { exclude group: 'org.codehaus.groovy'; exclude group: 'net.bytebuddy' }
testImplementation ('com.google.jimfs:jimfs:1.1')

testImplementation(testFixtures("io.nextflow:nextflow:$nextflowVersion"))
testImplementation(testFixtures("io.nextflow:nf-commons:$nextflowVersion"))
}

test {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ import nextflow.Channel
import nextflow.NF
import nextflow.Session
import nextflow.extension.CH
import nextflow.extension.ChannelExtensionPoint
import nextflow.extension.DataflowHelper
import nextflow.plugin.Scoped
import nextflow.plugin.extension.Factory
import nextflow.plugin.extension.Operator
import nextflow.plugin.extension.PluginExtensionPoint
import nextflow.sql.config.SqlConfig
import nextflow.sql.config.SqlDataSource
import nextflow.util.CheckHelper
Expand All @@ -40,8 +41,7 @@ import nextflow.util.CheckHelper
*/
@Slf4j
@CompileStatic
@Scoped('sql')
class ChannelSqlExtension extends ChannelExtensionPoint {
class ChannelSqlExtension extends PluginExtensionPoint {

private static final Map QUERY_PARAMS = [
db: CharSequence,
Expand All @@ -68,10 +68,12 @@ class ChannelSqlExtension extends ChannelExtensionPoint {
this.config = new SqlConfig((Map) session.config.navigate('sql.db'))
}

@Factory
DataflowWriteChannel fromQuery(String query) {
fromQuery(Collections.emptyMap(), query)
}

@Factory
DataflowWriteChannel fromQuery(Map opts, String query) {
CheckHelper.checkParams('fromQuery', opts, QUERY_PARAMS)
return queryToChannel(query, opts)
Expand Down Expand Up @@ -109,6 +111,7 @@ class ChannelSqlExtension extends ChannelExtensionPoint {
return dataSource
}

@Operator
DataflowWriteChannel sqlInsert( DataflowReadChannel source, Map opts=null ) {
CheckHelper.checkParams('sqlInsert', opts, INSERT_PARAMS)
final dataSource = dataSourceFromOpts(opts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class InsertHandler implements Closeable {
final metaData = conn.getMetaData()
final resultSet = metaData.getColumns(null, null, tableName, null);

final result = []
final result = [] as List<String>
while (resultSet.next()){
result.add( resultSet.getString("COLUMN_NAME") )
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/nf-sqldb/src/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Manifest-Version: 1.0
Plugin-Class: nextflow.sql.SqlPlugin
Plugin-Id: nf-sqldb
Plugin-Provider: Seqera Labs
Plugin-Version: 0.4.1
Plugin-Requires: >=21.08.0-edge
Plugin-Version: 0.5.0
Plugin-Requires: >=22.08.1-edge
50 changes: 40 additions & 10 deletions plugins/nf-sqldb/src/test/nextflow/sql/SqlDslTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,54 @@ package nextflow.sql

import groovy.sql.Sql
import nextflow.Channel
import nextflow.extension.ChannelExtensionProvider
import nextflow.plugin.Plugins
import nextflow.plugin.TestPluginDescriptorFinder
import nextflow.plugin.TestPluginManager
import nextflow.plugin.extension.PluginExtensionProvider
import org.pf4j.PluginDescriptorFinder
import spock.lang.Shared
import spock.lang.Timeout
import test.BaseSpec
import test.Dsl2Spec
import test.MockScriptRunner

import java.nio.file.Path

/**
*
* @author Paolo Di Tommaso <[email protected]>
*/
@Timeout(10)
class SqlDslTest extends BaseSpec {

def setup () {
new ChannelExtensionProvider()
.install()
.loadPluginExtensionMethods(new ChannelSqlExtension(), ['fromQuery':'fromQuery', sqlInsert:'sqlInsert'])
class SqlDslTest extends Dsl2Spec {

@Shared String pluginsMode

def setup() {
// reset previous instances
PluginExtensionProvider.reset()
// this need to be set *before* the plugin manager class is created
pluginsMode = System.getProperty('pf4j.mode')
System.setProperty('pf4j.mode', 'dev')
// the plugin root should
def root = Path.of('.').toAbsolutePath().normalize()
def manager = new TestPluginManager(root){
@Override
protected PluginDescriptorFinder createPluginDescriptorFinder() {
return new TestPluginDescriptorFinder(){
@Override
protected Path getManifestPath(Path pluginPath) {
return pluginPath.resolve('build/resources/main/META-INF/MANIFEST.MF')
}
}
}
}
Plugins.init(root, 'dev', manager)
}

def cleanup() {
ChannelExtensionProvider.reset()
Plugins.stop()
PluginExtensionProvider.reset()
pluginsMode ? System.setProperty('pf4j.mode',pluginsMode) : System.clearProperty('pf4j.mode')
}

def 'should perform a query and create a channel' () {
given:
def JDBC_URL = 'jdbc:h2:mem:test_' + Random.newInstance().nextInt(1_000_000)
Expand All @@ -55,6 +81,7 @@ class SqlDslTest extends BaseSpec {

when:
def SCRIPT = '''
include { fromQuery; sqlInsert } from 'plugin/nf-sqldb'
def table = 'FOO'
def sql = "select * from $table"
channel.fromQuery(sql, db: "test")
Expand All @@ -80,6 +107,7 @@ class SqlDslTest extends BaseSpec {

when:
def SCRIPT = '''
include { fromQuery; sqlInsert } from 'plugin/nf-sqldb'
channel
.of(100,200,300)
.sqlInsert(into:"FOO", columns:'id', db:"ds1")
Expand Down Expand Up @@ -110,6 +138,7 @@ class SqlDslTest extends BaseSpec {

when:
def SCRIPT = '''
include { fromQuery; sqlInsert } from 'plugin/nf-sqldb'
channel
.of(100,200,300,400,500)
.sqlInsert(into:'FOO', columns:'id', db:'ds1', batchSize: 2)
Expand Down Expand Up @@ -145,6 +174,7 @@ class SqlDslTest extends BaseSpec {

when:
def SCRIPT = '''
include { fromQuery; sqlInsert } from 'plugin/nf-sqldb'
def table = 'FOO'
def sql = "select * from $table"
channel.fromQuery(sql, db: "test", emitColumns:true)
Expand Down

0 comments on commit 8778cfa

Please sign in to comment.