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!

Dev Space

Customize and extend the power of Alteryx with SDKs, APIs, custom tools, and more.
SOLVED

Is there a development harness?

SeanAdams
17 - Castor
17 - Castor

Hey all,

 

So I'm building my first Python SDK tool (a simple tool that allows you to create directories for outputs), and I think I'm doing something wrong 🙂

 

The GUI is working; as is a basic tool that passes info through - but the development process is super painful because I can't figure out how to get a development harness working so that I can run within an IDE to test my code.

 

Desired State:

- Fire up a new project type of "Alteryx Tool Engine"

- This creates proxies for the Alteryx Engine; Incoming Interface; Outgoing Interface etc

- Also allows me to set up test data on inputs; do test driven delivery etc

 

Current State:

- I can't figure out how to do a proxy (harness) for the Alteryx Engine; Incoming Interface etc - so all development is in a python tool (like Jupyter / VS Code / IDLE) but I can't run it to test or get any debug messages

- As a result, I may as well be developing in Notepad

       - Write Code

       - Copy the tools in to the Alteryx folder under ...AppData\roaming\Alteryx\Tools\

       - Run a test Alteryx Canvas

       - get an error (which is difficult to read in the Alteryx GUI)

       - Copy this error into notepad to read it

       - Repeat

 

I feel like I'm missing something fundamental - how do the devs at Alteryx do this and develop new tools in a harness that simulates the Alteryx Engine and all the other critical objects so that you can build and debug right in the IDE?

 

Thanks all

Sean

11 REPLIES 11
tlarsen7572
11 - Bolide
11 - Bolide

Hi Sean,

 

I use PyCharm to do my custom tool development.  As far as I know, there is no harness available to us.

 

Therefore, my approach to developing custom tools has been to build the functionality I need without referencing any of the the SDK classes.  There should be a very clean separation between my code and the Alteryx SDK.  This means I can develop using my normal TDD workflow.  As I develop the tool, I am also inherently developing the entrypoints into the tool's logic (after all, the unit tests have to call something).

 

When I am done with the core logic (i.e. the business logic), I then create the SDK classes.  These classes call into the entrypoints at the appropriate point in the tool's lifecycle.  There is no business logic in the SDK classes; their sole purpose is to integrate the business logic with Alteryx via the business logic's entrypoints.  My 'integration testing' of these classes is to run the custom tool in Alteryx.  By this time I am fairly confident my business logic is working correctly (because of my unit tests), so the errors that occur are almost always because I did something wrong with the SDK.  Only having one failure vector greatly reduces the mental effort needed to debug errors.

 

I do all of my development directly in AppData\roaming\Alteryx\Tools\.  I can write code, alt-tab over to Alteryx, run Alteryx, review any errors, then alt-tab right back to my code.  This saves the step of copying the tools, which is a huge time saver.  If I have a separate repository where I want to permanently persist the code, I will copy the code from AppData\roaming\Alteryx\Tools\ when I am done coding.

 

If you want to see a small example, I have an open-source tool that sorts fields by specifying the order using full field names or regular expressions.  Code is on GitHub.

SeanAdams
17 - Castor
17 - Castor

Thank you @tlarsen7572  - generous and detailed answer.

 

I've done some of the same things that you've mentioned - build and complete the logic in a regular Python environment; and once it's working; only then insert it into a tool - just figured that there may have been a way to do this all in the IDE (like when you build an Android App, you have the ability to simulate phone events like GPS; rotation etc without leaving the IDE)

 

Appreciate your response - will log this as an idea in the community and post the link here for clarity.

 

 

SeanAdams
17 - Castor
17 - Castor

Out of interest - what made you chose PyCharm?    There seems to be a huge array of options in Python dev, and I'm curious to get the view of seasoned folk about why they chose the toolset that they did.

 

For example - on my machine right now I have:

- PyCharm

- IDLE

- VS Code

- Visual Studio 2019

- Anaconda 

       - Which then has Jupyter labs and

       - Jupyter Notebooks

       - and some of the rest above

 

 

I come from a visual Studio background - so I really miss the project folder structure of Visual Studio (with a second project for all the test cases in the same solution) when I work in Jupyter; although the instant execution / terminal type behaviour of Jupyter makes learning-type or exploration-type dev much faster.

 

Curious about what drove your choice!

 

tlarsen7572
11 - Bolide
11 - Bolide

It would certainly be nice to have a harness to complete all integration testing right in the IDE.  Given the dynamic nature of Python, it should be quite feasible to create a mock engine.  It's something I've thought about in passing for myself, but I simply do not understand the engine lifecycle events well enough to be sure I got it right.  If you link in your idea, I'll give it an upvote.

 

As for why I chose PyCharm: I use several other JetBrains products regularly.  When I first started coding many years ago I used Visual Studio for VB.NET and C#.  A few years ago I tried IntelliJ when I created a cross-platform Android/iOS app with Flutter, and fell in love with the product.  Today I use Rider (C#), GoLand (Go), and IntelliJ (Dart/Flutter) regularly.  So PyCharm was familiar and of the usual high quality I expect from JetBrains.  Also, when I code Python, I tend to do it from a general programming perspective.  I am not a data scientist and do not use Python for modelling.  So for me, the TDD approach I use for my development is very well accomodated by PyCharm.

 

Is your background computer science, or did you get into coding through some other channel?

SeanAdams
17 - Castor
17 - Castor

thank you @tlarsen7572  - makes sense.

I come from a CS background (CS and Computational Math) and used to be a professional developer using VB and Delphi and SQL.    

 

Perhaps it's like you say - you continue to work with the tools that you've grown familiar with over time.

 

Appreciate your time in responding - have a good thursday

Sean

cam_w
11 - Bolide

Hi @SeanAdams 

 

Also check out Sydney's article about SnakePlane - https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/Getting-Started-with-SnakePlane-and...

 

It might be the closest thing to what you're referencing. It still runs against the AlteryxEngine, but it might allow us to set up unit tests on the tool. As yet I haven't tried doing this, but I think it's closer to what Alteryx is using to develop tools using Python.

 

Bonus - The tutorial references PyCharm, so you'll get a quick intro to that IDE in the process of reading the article.

 

I've built a few tools using this now, and I have to say that I still use Jupyter for developing the business logic, but eventually move it into the SnakePlane repo as I build the new tools. This way, I can share all my tool changes with anyone on my team through the git repo and they can contribute PRs etc. through their own work in PyCharm.

Ozzie
Alteryx
Alteryx

Hey Sean,

 

I usually use vscode for python and javascript code but when it comes to making tools with python sdk and snakeplane, pycharm has been a must for me simply due to the fact that you can attach already running python processes in pycharm. This however isn't as possible in vscode: https://github.com/Microsoft/vscode-python/issues/1078. With pycharms remote debug session it allows us to debug these tools. (https://www.jetbrains.com/help/pycharm/remote-debugging-with-product.html) Hope this helps. Cheers! 

 

-Ozzie

SeanAdams
17 - Castor
17 - Castor

Submitted the idea here - https://community.alteryx.com/t5/Alteryx-Designer-Ideas/Development-environment-amp-harness-for-Pyth...

 

If we want to expand the use of the SDK, then we really do have to have a full mocking framework to simulate engine events; to allow full test-case assertions; etc.

SeanAdams
17 - Castor
17 - Castor

thanks for pointing this out @cam_w  - gonna redevelop my directory creator using SnakePlane - this does seem to dramatically simplify the process.