Skip to content

Commit

Permalink
Merge pull request #9 from nextflow-io/8-update-plugin-to-nextflow-22…
Browse files Browse the repository at this point in the history
….08.0-edge

feature: upgrade nextflow version to 22.08
  • Loading branch information
pditommaso authored Aug 30, 2022
2 parents 8bbf450 + 5f59131 commit 70242ab
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 18 deletions.
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,8 @@ 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.PluginExtensionPoint
import nextflow.sql.config.SqlConfig
import nextflow.sql.config.SqlDataSource
import nextflow.util.CheckHelper
Expand All @@ -40,8 +39,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 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
2 changes: 1 addition & 1 deletion plugins/nf-sqldb/src/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ 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-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 70242ab

Please sign in to comment.