Dev Space

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

Tool Settings on Alteryx Server: Differences?

chrisha
11 - Bolide

Hi everyone,

 

my tool with Python SDK backend and HTML GUI frontend now works fine in any Alteryx Designer. When uploading workflows containing the tool to the Alteryx Server, however, I receive error messages related to the validation of the tool settings.

 

In particular, I have a field called KeyfilePath which is defined as

 

        <ayx data-ui-props='{type: "TextBox", widgetId: "KeyFileUI", placeholder: "e.g. \\\\zeus\\data\\privatekey"}'
             data-item-props='{dataName: "KeyfilePath", dataType: "SimpleString"}'></ayx>

 

 

In my Python backend, I get and verify the setting using

 

class AyxPlugin:

    def pi_init(self, str_xml: str):
        setting_tree = Et.fromstring(str_xml)
        self.sftp_settings['key_filepath'] = setting_tree.find('KeyfilePath').text

        if self.sftp_settings['key_filepath']: 
            if not os.path.exists(self.sftp_settings['key_filepath']):
                self.output_message('The keyfile could not be found. Please check file path.')

 

 

As I said, it works fine in any Designer - also when opening the workflow in the Designer on the server. When running the Workflow on the server, however, either through the gallery our through the AlteryxEngineCmd.exe command-line tool, I get errors:

If the KeyfilePath setting is not set, I get an error message that the keyfile could not be found – but this should not be checked anyway.

If the KeyfilePath setting is set, it is not recognized, meaning that at another point in the tool, I receive a message as if the setting is not set.

 

Screenshot 2019-08-05 at 10.53.35.png

 

There seems to be a difference in how tool settings are managed between the GUI and the Command Line / Server Engine. Is there any documentation on how these differences effect custom tools?

 

Happy to share the tool and a test workflow privately.

 

Best Regards

Christopher 

 

PS: Alteryx Designer and Server Version 2019.2.5.62427

1 REPLY 1
chrisha
11 - Bolide

After wondering more and more why a supposedly empty string has a length > 0, I came across this issue: https://community.alteryx.com/t5/Dev-Space/Issue-using-Python-tools-in-Alteryx-Server/td-p/149291

 

Designer and Server differ in how white space from the Configuration XML is preserved or removed. While Designer removes leading and trailing spaces, the Server preserves it. Since the GUI automatically adds new lines and whitespace - even to empty XML tags - in the server the empty setting is not empty.

 

While @RyanSw in above post notes


 the front end UISDK ought to wrap your SimpleString values in CDATA so your whitespace will be preserved like that.

 this is not the case. BTW it would be nice if we could force the GUI SDK to wrap settings in CDATA tags.

 

I wrote a small wrapper method to load settings from the GUI:

    @staticmethod
    def _prep_xmltext(et: xml.etree.ElementTree, key: str) -> str:
        """Wrapper to quickly get settings.
        
        :param et: Element Tree from parsed Xml
        :type et: xml.etree.ElementTree
        :param key: Name of the setting
        :type key: str
        :return: Parsed value for setting
        :rtype: str
        """
        t = et.find(key).text.strip() if et.findtext(key) and (et.find(key).text is not None) else None
        return None if not t or t == "" else t

 

Maybe a future version of the SDK could include something similar and more robust, that catches more awkward Alteryx behaviors.

 

Best

Christopher