Hi All,
Is there way to stop Python Tool from running if incoming data [#1] is blank ?
Regards,
Mukesh Y
"blank" meaning zero records?
yes no record.
I will give more details, so there is Filter tool before python tool which decide the record flow.
So, you do get an error if no records get passed to the Python Tool. One way I found to avoid the error is to use,
from ayx import Alteryx
import sys
try:
df = Alteryx.read('#1')
except:
sys.exit(0)
This will prevent any later code from running.
If you have tools connected downstream of the Python Tool then you get a "There is no valid metadata outgoing..." error. If this happens it might be more appropriate to use,
from ayx import Alteryx
import pandas as pd
try:
df = Alteryx.read('#1')
except:
md = Alteryx.readMetadata('#1')
df = pd.DataFrame(md).iloc[:0]
Alteryx.write(df,1)
It's difficult to say without more details on what the Python Tool is doing. But the first option will definitely stop the Python Tool from running (at least in part) as requested.
Note that I'm going off the assumption that the Python Tool will be in "Production" mode. The workflow is attached.