Skip to content

Commit 83a4a6b

Browse files
committed
[*] Fix a bug with inline configuration of executables.
[*] Add tests for new features.
1 parent 151bd87 commit 83a4a6b

File tree

11 files changed

+89
-5
lines changed

11 files changed

+89
-5
lines changed

.github/workflows/nextflow-plugin.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ jobs:
2222
uses: actions/setup-python@v5
2323
with:
2424
python-version: '3.10'
25+
- uses: conda-incubator/setup-miniconda@v2
26+
with:
27+
miniconda-version: latest
2528
- name: Install Nextflow
2629
run: |
2730
wget -qO- https://get.nextflow.io | bash
@@ -46,5 +49,18 @@ jobs:
4649
cp -r build/plugins/nf-python-${{ env.PLUGIN_VERSION }} ~/.nextflow/plugins/
4750
- name: Run Nextflow workflow test
4851
run: |
49-
cd test
52+
source $CONDA/etc/profile.d/conda.sh
53+
54+
pushd test/test-datatypes
5055
nextflow run test_flow.nf -plugins "nf-python@${{ env.PLUGIN_VERSION }}"
56+
popd
57+
58+
pushd test/test-conda
59+
nextflow run test_conda_config.nf -plugins "nf-python@${{ env.PLUGIN_VERSION }}" -config conda.config
60+
nextflow run test_conda_inline.nf -plugins "nf-python@${{ env.PLUGIN_VERSION }}"
61+
popd
62+
63+
pushd test/test-executable
64+
nextflow run test_executable_config.nf -plugins "nf-python@${{ env.PLUGIN_VERSION }}" -config executable.config
65+
nextflow run test_executable_inline.nf -plugins "nf-python@${{ env.PLUGIN_VERSION }}"
66+
popd

plugins/nf-python/src/main/nextflow/python/PythonExtension.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ from nf_python import nf
130130

131131
executable = this.executable
132132
if (args.containsKey('_executable') || args.containsKey('_conda_env')) {
133-
executable = getExecutableFromConfigVals(args._executable, args._conda_env)
133+
executable = getExecutableFromConfigVals(args._executable ?: '', args._conda_env ?: '')
134134
}
135135

136136
File infile = File.createTempFile('nfpy_in', '.json')

test/nextflow.config

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/test-conda/conda.config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
id 'nf-python'
3+
}
4+
5+
nf_python {
6+
conda_env='six'
7+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env nextflow
2+
3+
nextflow.enable.dsl = 2
4+
5+
include { pyFunction } from 'plugin/nf-python'
6+
7+
workflow {
8+
assert pyFunction('''
9+
import six
10+
print("Package 'six' available!")
11+
nf.output(True)
12+
''') == [true]
13+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env nextflow
2+
3+
nextflow.enable.dsl = 2
4+
5+
include { pyFunction } from 'plugin/nf-python'
6+
7+
workflow {
8+
assert pyFunction('''
9+
import six
10+
print("Package 'six' available!")
11+
nf.output(True)
12+
''', _conda_env: 'six') == [true]
13+
14+
}
File renamed without changes.
File renamed without changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
id 'nf-python'
3+
}
4+
5+
nf_python {
6+
executable='doesntexist'
7+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env nextflow
2+
3+
nextflow.enable.dsl = 2
4+
5+
include { pyFunction } from 'plugin/nf-python'
6+
7+
workflow {
8+
try {
9+
pyFunction('test')
10+
assert false, "Should always throw"
11+
} catch (java.lang.reflect.InvocationTargetException e) {
12+
def cause = e.getCause()
13+
assert cause.message.startsWith('Cannot run program "doesntexist"')
14+
}
15+
}

0 commit comments

Comments
 (0)