How to reset a (too complex) NodeModel automatically when loading a workflow

#1

Hi,

I have a sink-NodeModel (with an attached NodeView) which is too complex to be made persistent using the load/saveInternals-mechanism. Currently, when saving an executed instance of this node and reloading the workflow, the node is still in the “executed” state, but the view-instantiation to fails.

Thus I would like my node to become reset automatically when a previously saved workflow is being loaded. This reset should affect only my node and not the complete workflow (so no “-reset”).

Is there any API or property to be set to cause the state of my node to change to “configured” when the workflow is loaded? Maybe some exception that I could throw in order to indicate that my node could not be restored even if it has been in “executed”-state when the workflow had been saved.

So far the only partial solution which came into my mind was to set a warning-message which indicates the user to reset the node.

Best, Watzlaw

0 Likes

#2

Hi Watzlaw, Automagically resetting the node upon load is not possible. Your “workaround” with a reasonable warning message sounds like the best solution to me (this message would also appear in a status bar in the node view). Alternatively you could consider implementing the BufferedDataTableHolder interface in your NodeModel. The framework will then call a setInternalTables method during load and you could fill your internal data structures. However, you should only do this if you don’t do a heavy computation (like iterating the table) as this could significantly slow down the load process… Hope this helps, Bernd

1 Like

#3

I faced to the same problem too. Wanted to know the reason behind it. By the way, my node is a customized PortObject, not depends on DataTable in KNIME.

Kefang

0 Likes

#4

Hi,

my problem focused only on one part of this topic.
After reloading the workflow, the executed node can’t show NodeView correctly. The NodeView is generated from the OutputPortObject
I tracked back the problem,

  1. it reported the exception of object instantiation in NodeModel. Go further,
  2. NodeModel didn’t assign value to the reference in NodeModel for OutputPortObject after reloading the workflow. However, the OutputPortObject was serialized successfully.

One possible solution, I think, is to have access to OutputPortObject in NodeModel after reloading, but I couldn’t find the codes how to do it.
PS: the OutputPortObject is customized, if it helps.

Regards
Kefang

0 Likes

#5

I needed something like this as well recently (with Se Nodes workflows it often makes sense to reset the “Start WebDriver” node when loading a workflow, as the associated browser instance is not running anyways … a Selenium Nodes design peculiarity).

What I did:

In the loadValidatedSettingsFrom I called the WorkflowManager's resetAndConfigureNode function.

Haven’t done excessive testing. Dirty? Maybe. But seems to do the trick so far.

– Philipp

4 Likes

#6

Hi @qqilihq,
if the method WorkflowManager 's resetAndConfigureNode is used, it sets the node state to idle. In another respect, it’s not necessary anymore to reload the workflow and serialize the output object.
Is this right of my understanding?

Regards
Kefang

0 Likes

#7

Hi Kefang,

I’ve just double checked this (deserialization is not so much of importance in my case, as it’s cheap). As far as I can tell, the deserialize methods don’t get called, so this looks like it should work for you.

Best,
Philipp

PS: One thing to consider – workflows loaded this way will be in “dirty” status.

0 Likes