Hello,
I made a simple Python SDK tool using the "Single Input Single Output Python SDK Example Tool" as template. I wish to read 2 string fields from Text Input Tool in my custom tool. I combine both the fields together and encode them using Python base64 encoder. (PS: Yes, we can do this using Alteryx Designer itself, but this just a trial tool which I made to get an idea of Alteryx's Python SDK capabilities).
I have the following file hierarchy:
Root folder name: KeySecretEncoder
Root folder contains: KeySecretEncoder (Folder) and Config.xml (general config file)
Further inside KeySecretEncoder (Folder): KeySecretEncoder_Engine.py (SDK Python code), KeySecretEncoder_Gui.html (Config GUI interface - 2 drop downs to select the fields from Text Input Tool), KeySecretEncoder_Icon.png (Tool icon image file), KeySecretEncoderConfig.xml (config file)
I have attached the .yxi (zip file containing the above mentioned files).
Upon dragging this .yxi file onto the Designer Canvas, I get "Tool Installer Error: Unable to find configuration file." I do have the configuration file and it is correct to the best of my knowledge. Can someone help me in this regard?
My Python task replica in Jupyter:
import pandas as pd
import hashlib
import hmac
import base64
# sample input to be obtained from the Text Input Tool
keysec = pd.DataFrame(data = {
'Key':['sdfgfcxc', 'czsdxghff', 'zxnvbmoui'],
'Secret':['?45$dfd*632sd!', '&%$@#df56?89', '$@!cxxd556%?']})
print(keysec)
# function to convert string to bytes - utf-8
def conv2bytes(val):
return bytes(val, 'utf-8')
keysec = keysec.applymap(conv2bytes)
print(keysec)
# function to combine the key and secret and encode them in base64 encoding format
def comb64enc(key, secret):
return base64.b64encode(hmac.new(key, secret, hashlib.sha256).digest())
keysec['Signature'] = keysec.apply(lambda row: comb64enc(row.Key, row.Secret), axis=1)
print(keysec)
Solved! Go to Solution.