Skip to content

Commit

Permalink
fix: add version for kpython + krdkit
Browse files Browse the repository at this point in the history
  • Loading branch information
breakthewall committed Mar 16, 2023
1 parent 4c0feda commit 41f2a20
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 8 deletions.
20 changes: 18 additions & 2 deletions retropath2_wrapper/Args.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
'KNIME_VERSION': '4.6.4',
'RP2_VERSION': 'r20220104',
'ZENODO_VERSION': "NA",
'KNIME_PYTHON_VERSION': '4.5.2.v202203041212',
'KNIME_RDKIT_VERSION': '4.5.0.v202207051536',
'KNIME_FOLDER': __PACKAGE_FOLDER
}
KNIME_ZENODO = {"4.6.4": "7515771", "4.7.0": "7564938"} # Map to Zenodo ID
Expand Down Expand Up @@ -112,15 +114,29 @@ def _add_arguments(parser):
'--kzenodo',
choices=[DEFAULTS['ZENODO_VERSION']] + list(KNIME_ZENODO.keys()),
default=DEFAULTS['ZENODO_VERSION'],
help='install Knime and its dependencies from Zenodo.'
help='Install Knime and its dependencies from Zenodo.'
)

parser.add_argument(
'--rp2_version',
type=str,
default=DEFAULTS['RP2_VERSION'],
choices=['v9', 'r20210127', 'r20220104', "r20220224"],
help=f'version of RetroPath2.0 workflow (default: {DEFAULTS["RP2_VERSION"]}).'
help=f'Version of RetroPath2.0 workflow (default: {DEFAULTS["RP2_VERSION"]}).'
)

parser.add_argument(
'--kpython_version',
type=str,
default=DEFAULTS['KNIME_PYTHON_VERSION'],
help=f'Version of KNIME\'s PYTHON (default: {DEFAULTS["KNIME_PYTHON_VERSION"]}).'
)

parser.add_argument(
'--krdkit_version',
type=str,
default=DEFAULTS['KNIME_RDKIT_VERSION'],
help=f'Version of RDKit KNIME\'s plugin (default: {DEFAULTS["KNIME_RDKIT_VERSION"]}).'
)

# RetroPath2.0 workflow options
Expand Down
16 changes: 14 additions & 2 deletions retropath2_wrapper/RetroPath2.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def retropath2(
outdir: str,
kinstall: str = DEFAULTS['KNIME_FOLDER'],
kexec: str = None, kpkg_install: bool = True, kver: str = DEFAULTS['KNIME_VERSION'],
kpython_ver: str = DEFAULTS['KNIME_PYTHON_VERSION'],
krdkit_ver: str = DEFAULTS['KNIME_RDKIT_VERSION'],
kzenodo_ver: str = DEFAULTS['ZENODO_VERSION'],
knime: Knime = None,
rp2_version: str = DEFAULTS['RP2_VERSION'],
Expand Down Expand Up @@ -71,7 +73,13 @@ def retropath2(

# Create Knime object
if knime is None:
knime = Knime(kexec=kexec, kinstall=kinstall, is_kpkg_install=kpkg_install, kver=kver, kzenodo_ver=kzenodo_ver)
knime = Knime(
kexec=kexec,
kinstall=kinstall,
is_kpkg_install=kpkg_install,
kver=kver,
kzenodo_ver=kzenodo_ver
)
if rp2_version is not None:
knime.workflow = os_path.join(
here, 'workflows', f'RetroPath2.0_{rp2_version}.knwf'
Expand All @@ -97,7 +105,11 @@ def retropath2(
# if kexec is not specified
# and executable not detected in default path
knime.install_exec(logger=logger)
r_code = knime.install_pkgs(logger=logger)
r_code = knime.install_pkgs(
kpython_ver=kpython_ver,
krdkit_ver=krdkit_ver,
logger=logger
)
if r_code > 0:
return r_code, None
elif r_code == RETCODES['OSError']:
Expand Down
2 changes: 2 additions & 0 deletions retropath2_wrapper/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def _cli():
kinstall=args.kinstall,
is_kpkg_install=args.kpkg_install,
kver=args.kver,
kpython_ver=args.kpython_version,
krdkit_ver=args.krdkit_version,
kzenodo_ver=args.kzenodo,
workflow=os_path.join(here, 'workflows', 'RetroPath2.0_%s.knwf' % (args.rp2_version,)),
)
Expand Down
11 changes: 8 additions & 3 deletions retropath2_wrapper/knime.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,12 @@ def install_exec(self, logger: Logger = getLogger(__name__)) -> None:
logger.info(' |--url: ' + self.kurl)
logger.info(' |--install_dir: ' + self.kinstall)

def install_pkgs(self, logger: Logger = getLogger(__name__)) -> int:
def install_pkgs(
self,
kpython_ver: str,
krdkit_ver: str,
logger: Logger = getLogger(__name__)
) -> int:
"""Install KNIME packages needed to execute RetroPath2.0 workflow.
Parameters
Expand Down Expand Up @@ -262,8 +267,8 @@ def install_pkgs(self, logger: Logger = getLogger(__name__)) -> int:
+ 'http://update.knime.com/analytics-platform/'+self.kver[:3]]
args += ["-i", 'org.knime.features.chem.types.feature.group,' \
+ 'org.knime.features.datageneration.feature.group,' \
+ 'org.knime.features.python.feature.group,' \
+ 'org.rdkit.knime.feature.feature.group']
+ f'org.knime.features.python.feature.group/{kpython_ver},' \
+ f'org.rdkit.knime.feature.feature.group/{krdkit_ver}']
args += ['-bundlepool', self.kpkg_install]
args += ['-d', self.kpkg_install]

Expand Down
2 changes: 1 addition & 1 deletion tests/test_knime.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest
from retropath2_wrapper.Args import (
DEFAULTS,KNIME_ZENODO, RETCODES
DEFAULTS, KNIME_ZENODO, RETCODES
)
from retropath2_wrapper.knime import Knime

Expand Down

0 comments on commit 41f2a20

Please sign in to comment.