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!
https://www.demilked.com/magazine/wp-content/uploads/2016/01/colorful-spell-harry-potter-magic-books-gabriel-picolo-kun-2.jpg
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!
https://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.
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...
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=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.
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!
https://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:
- 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!