Stop Python tool to Run
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi All,
Is there way to stop Python Tool from running if incoming data [#1] is blank ?
Regards,
Mukesh Y
- Labels:
- Dynamic Processing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
"blank" meaning zero records?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
yes no record.
I will give more details, so there is Filter tool before python tool which decide the record flow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
