node-red-contrib-tf-model icon indicating copy to clipboard operation
node-red-contrib-tf-model copied to clipboard

Accept properties on incoming msg

Open LTangaF opened this issue 4 years ago • 1 comments

I'm relatively new to Node-Red, but there seems to be standard practice of being able to set the configuration via incoming msg properties.

I have a need to set the modelURL programmatically. I'll look into how to make this modification myself and submit it back as a PR if I can.

LTangaF avatar Sep 29 '20 15:09 LTangaF

@yhwang My intent to add this has opened a few more issues/questions for me.

  1. In order for this to work, the required behavior of the modelURL property has to be removed. You've already got protection in the code at runtime for badly formed URLs, which would cover the scenario where it isn't set.
  2. I'm using this node after a split node, which reveals that setting values during the instantiation (constructor) for the node has some interesting side-effects around model loading. For example: I protectively put in to not use msg.modelURL if it was set explicitly in the property, but if part 1 from a split sets that instance variable, the effect is that the part 2 msg.modelURL will be ignored. Furthermore, the loaded model is re-used, potentially inappropriately. I think the solution is to just load the UI properties into a config object and don't preload the model, or at least reload the model when config.modelURL is empty and msg.modelURL is set. I don't know the full ramifications of all that might have to change, so wanted to bring it up with you.

This actually slows me down a fair amount from what I was actually working on, so I'll probably pivot to use tf-function for now and come back to this after you've had time to respond and I've got a little more time to work on it.

LTangaF avatar Oct 01 '20 12:10 LTangaF