Engine Works

Under the hood of Alteryx: tips, tricks and how-tos.
Alteryx
Alteryx

colorful-spell-harry-potter-magic-books-gabriel-picolo-kun-2

 

 

 

Step 1: Make your Python SDK tool following this helpful post from SydneyFs online grimoire

C3PO_1-1585354178768.png

 

 

 

While we are sure you are all at the top of your wizarding class, we know our tool just won’t run perfectly the first time around...let’s see how using Pdb can help!

 

 

https://i.imgflip.com/22jjt9.jpghttps://i.imgflip.com/22jjt9.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step 2: Create a workflow using your new tool, making sure to configure it with the settings you would like to test

 

C3PO_3-1585354178676.pngC3PO_4-1585354178680.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step 3: Save your workflow to the debug_workflows folder (snakeplane > pilot > debug_workflows) with the same name as your tool (YourToolsName.yxmd); if a debug_workflows folder does not exist create one

 

C3PO_5-1585354178685.pngC3PO_6-1585354178690.png

 

 

Before we continue, let’s learn a little bit about the Pdb code/commands we are going to use in our next steps:

For a full list of Pdp commands, click here

C3PO_19-1585355137494.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Pro-tip: If you just hit enter, Pdp will run the last command you entered in the terminal

 

 

OK, let’s move on to the next step in our debugging tutorial quest....

https://www.google.com/url?sa=i&url=https%3A%2F%2Fv1.escapistmagazine.com%2Fforums%2Fread%2F7.182143-Airship-Travel-Returns-in-Final-Fantasy-Versus-XIII&psig=AOvVaw02Tl3xz1jVceaM610BizXV&ust=1585068802840000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCJDijsuHsegCFQAAAAAdAAAAABADhttps://www.google.com/url?sa=i&url=https%3A%2F%2Fv1.escapistmagazine.com%2Fforums%2Fread%2F7.182143-Airship-Travel-Returns-in-Final-Fantasy-Versus-XIII&psig=AOvVaw02Tl3xz1jVceaM610BizXV&ust=1585068802840000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCJDijsuHsegCFQAAAAAdAAAAABAD

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step 4: Open your main.py script in your favorite editor and insert import pdb; pdb.set_trace() where you would like to start debugging your code and click save

 

C3PO_8-1585354178701.pngC3PO_9-1585354178832.png

 

 

Step 5: If you haven’t done so already, activate and freeze your environment

C3PO_10-1585354178709.png

 

 

Step 6: Next you will need to build your tool with the following command: inv build <your_tool_name>

  • Note, every time you make changes to your main.py script you will need to rebuild your tool

C3PO_11-1585354178828.png

 

 

Step 7: Change your directory to the debug_workflows directory

C3PO_12-1585354178718.png

 

 

 

 

 

 

 

 

 

 

Step 8: Run the workflow you created in the debug_workflows folder from the command line using the following command "C:\Program Files\Alteryx\bin\AlteryxEngineCmd.exe” <yourworkflow.yxmd>

C3PO_13-1585354178720.png

 

 

Your script will run up until the spot where you placed import pdb; pdb.set_trace(). You will know you are in the Python debugger when you see (Pdb) on the current line of your terminal

break_pdb.PNG

 

 

OK, from here we can start casting our debugging spells!

https://filmschoolrejects.com/wp-content/uploads/2017/04/0TuqhgxbLYZHj9lBs.jpghttps://filmschoolrejects.com/wp-content/uploads/2017/04/0TuqhgxbLYZHj9lBs.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • h for help: I want to see the documentation for the p command or a listing of all the documented commands

    • h.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • p to print; pp to print-pretty: I want to see the value of an expression (e.g., a variable) in it’s current context

    • C3PO_17-1585354178821.png

 

 

  • q for quit: I want to quit the debugger

    • q.PNG

This concludes the tutorial, but if your thirsty for another mug of Pdb butter beer,check out this post by JPKa. Happy debugging Alteryx Python SDK wizards!

Comments
11 - Bolide

A helpful article @C3PO ! However, it appears the Pesky Pixies have attacked the HTML in this article. Can Hermione fix it? 🙂