slac-lcls / ami

Other
6 stars 3 forks source link

Graph warnings #89

Open syamajala opened 1 month ago

syamajala commented 1 month ago

I wonder if we should have our own exception that users can use to raise warnings?

Currently when the graph throws an exception everything stops and the box border becomes red. There might be cases where instead what we want to do is catch a specific exception, make the border of the box yellow, and just continue doing what we can?

One such case I could see that being useful is the Pvput box which currently throws a TimeoutError if it cant do a put. We probably want to just raise a warning in that case and continue processing the rest of the graph instead of stopping completely?

syamajala commented 1 month ago

This has been merged. See: https://github.com/slac-lcls/ami/blob/master/ami/flowchart/library/Export.py#L172-L175 for an example of how to use it.

syamajala commented 2 weeks ago

This is not the right way to do graph warnings. The issue is once you hit the first warning exception you will not finish executing the other parts of the graph that could have been executed: https://github.com/slac-lcls/ami/blob/master/ami/worker.py#L228-L237

I think we should be doing this in the networkfox layer instead, at the level of the individual node execution: https://github.com/slac-lcls/networkfox/blob/master/networkfox/functional.py#L25-L30

That should allow you to continue executing the rest of the graph with valid branches.

syamajala commented 2 weeks ago

I did not realize python has a built in way to do this: https://docs.python.org/3/library/warnings.html

I need to read up on it.