Help with Smiles type mismatch after Case Switch in Python/KNIME workflow

Hi all,
I’m running into a really weird problem when trying to use a Python Script node in my KNIME workflow. Everything works fine if I connect the node before a Case Switch End node, but as soon as I move it after that node, I get a type mismatch error from the Python kernel.

It seems like something about the data types changing after the Case Switch is confusing the kernel. As you can see below, the error mentions can’t cast to Smiles type. Any ideas what might be causing this behavior between KNIME and the Python kernel?

Hoping someone has seen this before and can point me in the right direction.

2024-03-05 15:37:39,633 : ERROR : KNIME-Worker-47 :  : PythonSourceCodePanel : Python Script : 3:1240:0:1304 : An exception occured while running the Python kernel. See log for details.
org.knime.python2.kernel.PythonIOException: An exception occured while running the Python kernel. See log for details.
	at org.knime.python3.scripting.Python3KernelBackend.putDataTable(Python3KernelBackend.java:461)
	at org.knime.python3.scripting.Python3KernelBackend.putDataTable(Python3KernelBackend.java:441)
	at org.knime.python2.kernel.PythonKernel.putDataTable(PythonKernel.java:284)
	at org.knime.python2.kernel.PythonKernelManager$PutDataRunnable.run(PythonKernelManager.java:494)
	at org.knime.core.util.ThreadUtils$RunnableWithContextImpl.runWithContext(ThreadUtils.java:367)
	at org.knime.core.util.ThreadUtils$RunnableWithContext.run(ThreadUtils.java:221)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at org.knime.core.util.ThreadPool$MyFuture.run(ThreadPool.java:123)
	at org.knime.core.util.ThreadPool$Worker.run(ThreadPool.java:246)
Caused by: java.lang.ClassCastException: class org.knime.chem.types.AbstractStringBasedValueFactory$AbstractCellReadValue cannot be cast to class org.knime.chem.types.SmilesValue (org.knime.chem.types.AbstractStringBasedValueFactory$AbstractCellReadValue and org.knime.chem.types.SmilesValue are in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @1507bc3)
	at org.knime.chem.types.SmilesCellValueFactory.getValueAsString(SmilesCellValueFactory.java:1)
	at org.knime.chem.types.AbstractStringBasedValueFactory$AbstractCellWriteValue.setValue(AbstractStringBasedValueFactory.java:82)
	at org.knime.core.data.columnar.table.virtual.WriteAccessRowWrite.setFrom(WriteAccessRowWrite.java:120)
	at org.knime.core.data.columnar.table.virtual.WriteAccessRowWrite.setFrom(WriteAccessRowWrite.java:1)
	at org.knime.python3.arrow.PythonArrowDataSourceFactory.copyTable(PythonArrowDataSourceFactory.java:196)
	at org.knime.python3.arrow.PythonArrowDataSourceFactory.copyTableToArrowStore(PythonArrowDataSourceFactory.java:180)
	at org.knime.python3.arrow.PythonArrowDataSourceFactory.extractStoreCopyTableIfNecessary(PythonArrowDataSourceFactory.java:171)
	at org.knime.python3.arrow.PythonArrowDataSourceFactory.createSource(PythonArrowDataSourceFactory.java:121)
	at org.knime.python3.scripting.Python3KernelBackend$PutDataTableTask.call(Python3KernelBackend.java:754)
	at org.knime.python3.scripting.Python3KernelBackend$PutDataTableTask.call(Python3KernelBackend.java:1)
	at org.knime.core.util.ThreadUtils$CallableWithContextImpl.callWithContext(ThreadUtils.java:383)
	at org.knime.core.util.ThreadUtils$CallableWithContext.call(ThreadUtils.java:269)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.