LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  How to clock processing conditional on a previous node error

    Employee
    Posted 07-24-2015 04:20

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: sdb

    I have developed a Python node to fetch email messages.
    There are several library calls in the Python code that could error - e.g user gave invalid login credentials. If that happens I raise an exception, and I get the classic log and red X.
    Is there a straightforward way that I can clock from an errored node? I.e. if the node errors for whatever reason I can trigger another bit of graph conditional on the error to perform key steps?

    I have looked at setting a return code in Python, but return codes only seem to be sent if the node completes execution without error???
    Is there a way to set up a general error handler that can provide the red X but still send out a clock?

    Simon


  • 2.  RE: How to clock processing conditional on a previous node error

    Employee
    Posted 07-24-2015 11:02

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: stonysmith

    I'm not sure you can affect the clock in a manner to cause one stream to run and another stream to not run.

    What might be better is to provide a 2nd output pin from your node .. you can then use MetaCheck to condition other streams. On this second pin, write out a single record if your logic passes, don't write a record if your logic fails.

    Then:
    with one Metacheck you set MinRecords=1 and SuccessAction="OutputandClock" to enable stream A to run,
    with another Metacheck, you'd set MinRecords=1 and TerminusAction="OutputandClock" enable stream B to run.

    This way, if your python node produces a (second pin) record, then stream A runs, else stream B runs.

    =======
    There MIGHT be a way to accomplish this with the "Switch" node.. I am unsure as to whether (how) it could be crafted.


  • 3.  RE: How to clock processing conditional on a previous node error

    Employee
    Posted 07-24-2015 12:28

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ryeh

    In your particular case, would the following work - 'try' the log-in process and catch/log any exceptions in the 'except' clause. That way, the node still executes with the green check-mark, right?


  • 4.  RE: How to clock processing conditional on a previous node error

    Employee
    Posted 07-25-2015 02:39

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Tim Meagher

    Another different approach to this general sort of problem - wanting to execute one path in case of failure and another in case of success - is to setup an execution plan in logistics manager with dependent run definitions.
    One run definition could be set to execute if the previous run definition succeeds.
    The other can be set to execute if the previous run definition fails.

    Not sure if this approach would work in your case or be what you are looking for, but it is an option for this general sort of problem.


  • 5.  RE: How to clock processing conditional on a previous node error

    Employee
    Posted 07-27-2015 03:14

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: sdb

    Thanks Stony, Ryeh and Tim.

    I did think of these workarounds - and I think they would all work, but I was hoping for something slightly different, particularly as the library I am using has multiple calls, and wrapping try/except around each makes it very hard to read, although I do use the technique when testing a status. Also multiple outputs is not that pretty as people do not readily understand what each is for - even with documentation.

    Tim's suggestion is a good one for graphs destined for automation - of which this is one - but I wanted to get into some fundamentals for desktop users too.

    I was hoping to create a global exception handling: perhaps my knowledge is limited re the brain.node exception handling system as to whether this is possible. As much as I understand is that "raise..." will terminate the node with no output, no clock and a red X. Switches and MetaChecks will not get triggered, even where their input is homed to a data output on another node.

    So is there a way to get a red X by other means, but still at least clock? If so a simple Metacheck would allow/disallow normal data processing when there is at least 1 record output, and a Switch can be used to propagate alternate data that an error handler can spot and deal with.

    The best I have achieved so far is to manipulate the return code (0, 201 or 203) to the circumstance, and have to do a premature "return" from initialise, prevent pump running if my global terminate flag is set, and similarly test in finalise whether there should be any cleanup according to how far initialise got.

    It's ugly, complicated, and crying out for better global exception handling.

    Any other ideas?

    Grateful for your suggestions.

    Thanks again!



    I already introduced try/except constructs in the Python code


  • 6.  RE: How to clock processing conditional on a previous node error

    Employee
    Posted 07-29-2015 03:42

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: sdb

    I have got a bit further with this.

    It appears that a return code of -1 will set the Red X with no clock or output. There does not seem to be any other return code value for a red X with a clock say.

    However, the real problem is that raising an exception in a Python node does not honour any other return code than -1. Why not???

    And why can't we have a special node that is clocked if a previous node errors?

    Surely both of these can be achieved?