Saturday, August 26, 2023

How to Develop Alteryx Custom Tool

Post Index  

2023-08-26


How to Develop Alteryx Custom Tool

with the help of Platform SDK

AYX UI SDK, AYX Python SDK v2, AYX Plugin CLI



The platform SDK allows you to develop Alteryx custom tools and plugins.  Alteryx provides a lot of amazing tools but it does not come out of the box for everything.  Just like my previous posts of QVD Input Tool and QVD Output Tool, Alteryx does not come out of the box to have the capability to manipulate QVD files.  In the past, there are Engine and HTML GUI SDKs.  As mentioned in the Alteryx platform SDK help, the outdated technology is limited for extension.  There is a need to use the latest technology that can extend the opportunities for improvement.

For details of Platform SDK, you may refer to the help. This article will focus on the basic to let you understand how to develop a simple Alteryx Custom Tool.




Environment Setup

For basic requirements, please refer to AYX Python SKD v2 help page.

Before you can start the development, there are a few steps required.

1. Install Minicoda3 (download from the site and install).


2. Open Anacoda Prompt (click on the Windows button and search it)


3. Create a virtual environment with the command
    conda create -n [ENV_NAME] python=3.8.5

e.g. conda create -n test_env python=3.8.5

4. Activate the environment.
    conda activate [ENV_NAME]

e.g. conda activate test_env

4. Install the AYX Python SDK.
    pip install ayx-python-sdk


5. Install the AYX Plugin CLI
    pip install ayx-plugin-cli


6. Create (or initialize) the AYX Plugin Workspace
    ayx_plugin_cli sdk-workspace-init

    A few questions to answer to help initialize the configuration files.

    Package Name: [The name of the package]
    Tool Category [Python SDK Examples]: [The category of the tools]
    Description []: Description of the package.
    Author []: Who is the author of the package.
    Company []: The company name.
    Backend Language (python): python

7. Install NodeJS.  It is required to developer UI for the tool.
    conda install -c anaconda nodejs=16.13.1




7. Create the AYX Plugin
    ayx_plugin_cli create-ayx_plugin --use-ui
    * --use-ui must be explicitly input to make sure the UI part is created by the plugin CLI.




    A few questions to answer to help initialize the configuration files.

Tool Name: [The name of the tool]
Tool Type (input, multiple-inputs, multiple-outputs, optional, output, single-input-single-output, multi-connection-input-anchor) [single-   input-single-output]: [the type of the tool]
Description []: [description of the tool]
Tool Version [1.0]: [version of the tool]
DCM Namespace []:  [DCM Namespace to be used]

Once it is done, you will have a folder structure created as below.

Backend Development (Python)

After the initialization of the environment, workspace and tool, there is a backend file created in the path \backend\ayx_plugins.

Open this using an editor or any IDE to start the tool development.  There are four important functions:

def __init__(self, provider: AMPProviderV2) -> None:
This is to initialize the tools.  Usually, to initialize the variable to be used in the backend code.

def on_incoming_connection_complete(self, anchor: namedtuple) -> None:
When there is an incoming anchor complete, this will be called.  Input tool does not required to handle this.

def on_record_batch(self, batch: "Table", anchor: namedtuple) -> None:
This is to handle the record provided in batches.  Input tool does not required to manipulate this.

def on_complete(self) -> None:
Once the batches have been manipulated, this is to free up the resources and also finalize the completion.  All logics happen here for input tool.

For each function, the comment is already in the backend plugin file. 

Frontend Development (Reactjs)

For front-end development, it should locate to the path \ui\TestInputTool\src.  There is a file called index.tsx.  This is the file to be updated.

The content is reactjs.

More UI help can be found in the Alteryx UI help.


Create the YXI and Deploy to Alteryx Designer

Once the frontend, backend, configuration (like icon, description, version, etc) are completed, it can be packaged to YXI file to share and also install into Alteryx Designer.  It is simply running the command:
ayx_plugin_cli designer-install --use-ui
* --use-ui must be specified explicitly if UI component is involved.

It will prompt a question.
Install Type (user, admin) [user]: [user means to install user location that only for single user while admin means to install into admin location that allows all users in the machine to use]

user location: C:\Users\[user]\AppData\Roaming\Alteryx\Tools
admin location: C:\ProgramData\Alteryx\Tools


Test in Designer

Open up the Alteryx designer, the tool palette contains a new category named "Test Tools" and the Test Input Tool can be selected.  Once this executed, there is a sample result.



This concludes how to develop an Alteryx Custom Tool.  For details about python code, reactjs, etc, leave me message if further discussion is needed.


Thank you for reading.  I hope it help you.  Just leave a message if you have any discussion/share want to make.



No comments:

Post a Comment