Say I have folder 'x' in which lives 'workflow.yxmd'. Can anyone Python-conversant help me with a snippet of code which could possibly trigger this workflow to run?
Clarification - the .py would be initiated external to Alteryx, not from within it. ALSO let me clarify I would be trying to run the Alteryx workflow within designer / desktop app (the workflow lives on the local machine), NOT from the gallery/server.
So basically I look to be able to have the Python program:
a) Do some stuff
b) Kick off Alteryx workflow 'workflow.yxmd' in folder 'x'
c) [optional] do other stuff after kicking off the workflow
Ideally, in a perfect world, I'd love to have the flexibility for c) above to either 1) execute as soon as it kicks off the Alteryx workflow, or 2) kick off the workflow AND WAIT for the Alteryx workflow to complete before c) executes [is this possible?]
I am a just-beyond-beginner Python user, able to create simple things, but haven't figured this out yet if it's possible, and would welcome some help.
Solved! Go to Solution.
@Storm It would be something along these lines.
import subprocess
filename = "my_workflow.yxmd"
args = "C:\Program Files\Alteryx\bin\AlteryxEngineCmd.exe" + filename
subprocess.call(args, stdout=FNULL, stderr=FNULL, shell=False)
Note: you need a Alteryx Automation license to take advantage of the AlteryxEngineCmd.exe.
Hope this helps.
DiganP:
Thanks for your help and quick reply. When I run this I get this error:
in <module>
subprocess.call(args, stdout=FNULL, stderr=FNULL, shell=False)
NameError: name 'FNULL' is not defined
Any help? Sorry for my ignorance - as I said, still a Python neophyte.
@Storm I just updated the python code, I tested it as well and works! Please try it and let me know.
Return code = 0, means it ran without errors.
import subprocess
filename = "C:\\Users\\dparikh\\Downloads\\Join Workflow final.yxmd"
subprocess.run(["C:\\Program Files\\Alteryx\\bin\\AlteryxEngineCmd.exe ", filename])
@DiganP :
I am getting much closer with your help.
I ran that Python code (adjusted for my pathing obviously) with no error; but it didn't appear to actually run the workflow.
I am guessing I don't have the Alteryx Automation license you refer to; so I attempted instead to sub 'AlteryxGUI.exe' for 'AlteryxEngineCmd.exe'. This OPENED the workflow, which is a good thing, but it didn't run it. Is there any way to do so?
@Storm Not without the automation license. AlteryxGUI.exe just opens the workflow, its like when you click on Alteryx Designer.
Just an idea, but you could set the python scripts to run before and after the Alteryx workflow using events
@JReid yes its possible but only if you have the Alteryx Automation or Server license.
Ok thank you for your assistance here guys! It is appreciated.
@Storm Can you mark the python code as a solution, so people can search it for later use 🙂