Dev Space

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

19.1 Python SDK Updates

BlytheE
Alteryx Alumni (Retired)

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.



2 REPLIES 2
cam_w
11 - Bolide

@BlytheE 

 

I'm having trouble installing a YXI with multiple tools packaged together. All have the ToolFamily="Alight" in the EngineSetttings element (first position before EngineDll):

 

<?xml version="1.0"?>
<AlteryxJavaScriptPlugin>
  <EngineSettings ToolFamily="Alight" EngineDll="Python" EngineDllEntryPoint="main.py" SDKVersion="10.1" />
...

 

And the Config.xml is written as follows. Did I include the ToolFamily correctly in this file?

 

<?xml version="1.0"?>
<AlteryxJavaScriptPlugin>
  <Properties>
    <MetaInfo>
      <Name>Alight Tools</Name>
      <RootToolName>Alight Tools</RootToolName>
      <Description>Set of tools for ...</Description>
      <CategoryName>Alight</CategoryName>
      <ToolFamily>Alight</ToolFamily>
      <ToolVersion>0.0.1</ToolVersion>
      <Author>Cameron Willis</Author>
      <Company>Company</Company>
      <Copyright>2019</Copyright>
      <SearchTags>python, sdk, alight, python sdk</SearchTags>
      <Icon>AlightIcon.png</Icon>
    </MetaInfo>
  </Properties>
</AlteryxJavaScriptPlugin>

 

As of the moment, I'm still getting the following error message when I install in Designer 2019.2:

 

“The installation failed. ToolFamily must match for all tools included a yxi file.”

 

Cameron

cam_w
11 - Bolide

For others with similar questions about ToolFamily --

 

I found that the EngineSettings tag needs to be included in the Config.xml file which previously was not needed. For example, below is the Config.xml file from the ML Tools Installer:

 

<?xml version="1.0" encoding="utf-8"?>
<AlteryxJavaScriptPlugin>
	<EngineSettings EngineDll="Python" ToolFamily="MachineLearningTools" SDKVersion="10.1"></EngineSettings>
	<Properties>
		<MetaInfo>
			<Name>ml_tools</Name>
			<RootToolName>ml_tools</RootToolName>
			<Description>Python Machine Learning Tools</Description>
			<CategoryName>ML Tools</CategoryName>
			<ToolVersion>0.0.0.153726</ToolVersion>
			<Author>Alteryx, Inc.</Author>
			<Company>Alteryx, Inc.</Company>
			<Copyright>2019</Copyright>
			<SearchTags>scikit-learn, python, predictive, machine, learning</SearchTags>
			<Icon>icon.png</Icon>
		</MetaInfo>
	</Properties>
</AlteryxJavaScriptPlugin>