We are in the final days to enter our Data and Analytics - "What's your why?" raffle with SparkED!

Reply with your "why" in text/video format to our forum post by January 28 to be entered! 

Engine Works

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

Fellow Alteryx Python SDK wizards, are you ready for a new spell in your spell book? This short tutorial will cover the very basics of using the Pdb module to debug your latest and greatest Python SDK tools!





Step 1: Make your Python SDK tool following this helpful post from @SydneyF's online grimoire:






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!






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



4 and 5.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.










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





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





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.





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





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.






Step 7: Change your directory to the debug_workflows directory





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”





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.





From here we can start casting our debugging spells!




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





  • 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:





  • q for quit: I want to quit the debugger:



This concludes the tutorial, but if you're thirsty for another mug of Pdb butter beer, check out this post by @JPKa .


Happy debugging Alteryx Python SDK wizards!