community
cancel
Showing results for 
Search instead for 
Did you mean: 

Dev Space

Customize & extend the power of Alteryx. SDKs, APIs, custom tools, and more!

19.1 Python SDK Updates

Highlighted
Alteryx
Alteryx

With 19.1, we've added some new features to our Python SDK!

 

Feature Breakdown:

  • An XML string attribute for ToolFamily was added for the ToolNameConfig.xml and the outer config.xml of a YXI. Python SDK tools can now be grouped together to share dependencies and a single python virtual environment. This allows for a common site-packages path that is shared between all Python SDK tools that are of the same ToolFamily.

 

  • Messaging function DebugMessageOut. This function displays messages in the console or Results window if the flag EnableDebugMessages is set to True on the workflow for tools utilizing the Python SDK (more details on implementation are below).


FYI - ToolFamily is only applicable to tools built with the Python SDK. Previous versions of custom tools that do not include ToolFamily in the config XML files will continue working in Alteryx 19.1.

Examples:

The purpose of ToolFamily is to consolidate virtual environments. This will save you space and allow you to logically group tools together, like connectors or machine learning tools, that share common Python packages. An example of using ToolFamily in the ToolNameConfig.xml file is below. If you have multiple Python SDK tools that you would like to share the same virtual environment (venv), specify a ToolFamily value that will be consistent across the tools. The venv will be installed in the same directory as the tools and it will be named ToolFamily_venv. For the example below, it will be a new folder named multitool_venv.


<?xml version="1.0"?>
<AlteryxJavaScriptPlugin>
<EngineSettings EngineDll="Python" ToolFamily ="multitool" EngineDllEntryPoint="Python - Single Input OutputEngine.py" SDKVersion="10.1" />
<GuiSettings Html="Python - Single Input OutputGui.html" Icon="Python - Single Input OutputIcon.png" Help="https://help.alteryx.com/developer/current/index.htm#Python/Examples.htm" SDKVersion="10.1">
<InputConnections>
<Connection Name="Input" AllowMultiple="False" Optional="False" Type="Connection" Label=""/>
</InputConnections>
<OutputConnections>
<Connection Name="Output" AllowMultiple="False" Optional="False" Type="Connection" Label=""/>
</OutputConnections>
</GuiSettings>
<Properties>
<MetaInfo>
<Name>Python - Single Input Output</Name>
<Description>Description for this tool.</Description>
<ToolVersion>1.0</ToolVersion>
<CategoryName>Laboratory</CategoryName>
<SearchTags>python, sdk, select, sample, top, records, python sdk</SearchTags>
<Author>Alteryx</Author>
<Company>Alteryx, Inc.</Company>
<Copyright>2017</Copyright>
</MetaInfo>
</Properties>
</AlteryxJavaScriptPlugin>

If you wish to package tools within the same ToolFamily in a single YXI, make sure the ToolFamily value in the outer Config.xml matches the ToolFamily within.

But what about the requirements.txt file, you may be asking? Can you get by with just one per ToolFamily? Technically, yes, but it is still good practice to include a requirements.txt for each tool. Your future self might thank you if you have to break the family up!

The DebugMessageOut method is a great way to add debug messages to your code and not have to worry about deleting or commenting them out once your tool is in production.

How to use it:

self.alteryx_engine.debug_message_out(self.n_tool_id,Sdk.EngineMessageType.info,"This is my python debugger")

In order to enable that message to appear in the Results window or console, the EnableDebugMessages constant must be set to True. In Alteryx, under the workflow tab of the Workflow-Configuration window, click the plus sign and type 'EnableDebugMessages' for the Name and set the value to True. If that constant is not defined for a workflow, that value is set to False by default.

EnableDebugMessages.PNG

 

Troubleshooting Guide for ToolFamily:

  • YXI Error: “The installation failed. ToolFamily is not allowed to be empty or white space.”
    • What does this mean? If ToolFamily is included in the ToolNameConfig.xml file, the value must not be empty or include spaces.
  • YXI Error: “The installation failed. ToolFamily must match for all tools included a yxi file.”
    • What does this mean? The ToolFamily value must be consistent between the ToolNameConfig.xml file and the outer config.xml file in a YXI installer.
  • Problem: if a Python SDK tool in a ToolFamily produces an error and is removed from the canvas, the error may persist even if the tool is no longer in the workflow
    • Try working in a new, blank workflow
  • Error in Designer: Designer x64: The Designer x64 reported: InboundNamedPipe GetOverlappedResult: The pipe has been ended.
    • What does this mean? Tools in the same ToolFamily must be installed as admin or non-admin, no mix and match.
  • Problem: Alteryx is throwing an error that it can't load a library
    • What does this mean? If you installed multiple tools via a single YXI and any one of them failed, the virtual environment will not be set up properly, so even tools that were “successfully installed” will not work.