Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Launch Alteryx workflow from within Python script?

Storm
9 - Comet

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.

15 REPLIES 15
DiganP
Alteryx Alumni (Retired)

@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.  

Digan
Alteryx
Storm
9 - Comet

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.

DiganP
Alteryx Alumni (Retired)

@Storm I just updated the python code, I tested it as well and works! Please try it and let me know. 

DiganP_1-1578509334855.png

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])
Digan
Alteryx
Storm
9 - Comet

@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?

DiganP
Alteryx Alumni (Retired)

@Storm Not without the automation license. AlteryxGUI.exe just opens the workflow, its like when you click on Alteryx Designer. 

Digan
Alteryx
JReid
9 - Comet

Just an idea, but you could set the python scripts to run before and after the Alteryx workflow using events 

JReid_0-1578510435385.png

 

JReid_1-1578510473198.png

DiganP
Alteryx Alumni (Retired)

@JReid yes its possible but only if you have the Alteryx Automation or Server license. 

Digan
Alteryx
Storm
9 - Comet

Ok thank you for your assistance here guys!  It is appreciated.

DiganP
Alteryx Alumni (Retired)

@Storm Can you mark the python code as a solution, so people can search it for later use 🙂

Digan
Alteryx
Labels