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

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.

Problems with Python Tool

I'm having two problems with the Python tool:

 

  1. Alteryx.read(Alteryx.getIncomingConnectionNames()[0]) works intermittently, with no changes in the Python script or Alteryx workflow. Running multiple times normally gives the error AttributeError: 'list' object has no attribute 'is_unique' but occasionally allows me to view the data fine. I have only one input into the tool, which is feeding a single column of V_Strings (I have tried Strings and V_WStrings with the same outcome)
  2. When the data is correctly loaded, while working in the Jupyter notebook, the first issue reoccurs with no warning, seemingly having dropped the cache.

 

When running the workflow, the tool flags:

 

Error: Python (173): [NbConvertApp] Converting notebook C:\Users\SEBAST~1.ARR\AppData\Local\Temp\5c83da68-0f3b-4589-9152-1975cd469061\173\workbook.ipynb to html
[NbConvertApp] Executing notebook with kernel: python3
[NbConvertApp] ERROR | Error while converting 'C:\Users\SEBAST~1.ARR\AppData\Local\Temp\5c83da68-0f3b-4589-9152-1975cd469061\173\workbook.ipynb'
Traceback (most recent call last):
  File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\nbconvert\nbconvertapp.py", line 393, in export_single_notebook
    output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
  File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\nbconvert\exporters\exporter.py", line 174, in from_filename
    return self.from_file(f, resources=resources, **kw)
  File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\nbconvert\exporters\exporter.py", line 192, in from_file
    return self.from_notebook_node(nbformat.read(file_stream, as_version=4), resources=resources, **kw)
  File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\nbconvert\exporters\html.py", line 85, in from_notebook_node
    return super(HTMLExporter, self).from_notebook_node(nb, resources, **kw)
  File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\nbconvert\exporters\templateexporter.py", line 280, in from_notebook_node
    nb_copy, resources = super(TemplateExporter, self).from_notebook_node(nb, resources, **kw)
  File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\nbconvert\exporters\exporter.py", line 134, in from_notebook_node
    nb_copy, resources = self._preprocess(nb_copy, resources)
  File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\nbconvert\exporters\exporter.py", line 311, in _preprocess
    nbc, resc = preprocessor(nbc, resc)
  File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\nbconvert\preprocessors\base.py", line 47, in __call__
    return self.preprocess(nb, resources)
  File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\nbconvert\preprocessors\execute.py", line 262, in preprocess
    nb, resources = super(ExecutePreprocessor, self).preprocess(nb, resources)
  File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\nbconvert\preprocessors\base.py", line 69, in preprocess
    nb.cells[index], resources = self.preprocess_cell(cell, resources, index)
  File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\nbconvert\preprocessors\execute.py", line 286, in preprocess_cell
    raise CellExecutionError.from_cell_and_msg(cell, out)
nbconvert.preprocessors.execute.CellExecutionError: An error occurred while executing the following cell:
------------------
Alteryx.read(Alteryx.getIncomingConnectionNames()[0])
------------------

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-0bf8d58a2a02> in <module>()
----> 1 Alteryx.read(Alteryx.getIncomingConnectionNames()[0])

c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\ayx\export.py in read(incoming_connection_name)
     15     When running the workflow in Alteryx, this function will convert incoming data streams to pandas dataframes when executing the code written in the Python tool. When called from the Jupyter notebook interactively, it will read in a copy of the incoming data that was cached on the previous run of the Alteryx workflow.
     16     '''
---> 17     return __CachedData__().read(incoming_connection_name)
     18
     19 def write(pandas_df, outgoing_connection_number):

c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\ayx\CachedData.py in read(self, incoming_connection_name)
    287                 try:
    288                     # get the data from the sql db (if only one table exists, no need to specify the table name)
--> 289                     data = db.getData()
    290                     # print success message
    291                     print(''.join(['SUCCESS: ', msg_action]))

c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\ayx\CachedData.py in getData(self, table)
    134         # if no table specified, check to see if there is only table and use that
    135         if table is None:
--> 136             table = self.getSingularTable()
    137
    138         # now that the table name has been retrieved, get the data as pandas df

c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\ayx\CachedData.py in getSingularTable(self)
    111     # if one table exists, return its name, otherwise throw error
    112     def getSingularTable(self):
--> 113         tables = self.getTableNames()
    114         table_count = len(tables)
    115         # if no tables exist throw error

c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\ayx\CachedData.py in getTableNames(self)
     97         return pd.read_sql_query(
     98             "select name from sqlite_master where type='table'",
---> 99             self.connection
    100             )['name'].tolist()
    101

c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\pandas\io\sql.py in read_sql_query(sql, con, index_col, coerce_float, params, parse_dates, chunksize)
    312     return pandas_sql.read_query(
    313         sql, index_col=index_col, params=params, coerce_float=coerce_float,
--> 314         parse_dates=parse_dates, chunksize=chunksize)
    315
    316

c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\pandas\io\sql.py in read_query(self, sql, index_col, coerce_float, params, parse_dates, chunksize)
   1425             frame = _wrap_result(data, columns, index_col=index_col,
   1426                                  coerce_float=coerce_float,
-> 1427                                  parse_dates=parse_dates)
   1428             return frame
   1429

c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\pandas\io\sql.py in _wrap_result(data, columns, index_col, coerce_float, parse_dates)
    139                                    coerce_float=coerce_float)
    140
--> 141     _parse_date_columns(frame, parse_dates)
    142
    143     if index_col is not None:

c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\pandas\io\sql.py in _parse_date_columns(data_frame, parse_dates)
    125     # we could in theory do a 'nice' conversion from a FixedOffset tz
    126     # GH11216
--> 127     for col_name, df_col in data_frame.iteritems():
    128         if is_datetime64tz_dtype(df_col):
    129             data_frame[col_name] = _handle_date_column(df_col)

c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\pandas\core\frame.py in iteritems(self)
    721
    722         """
--> 723         if self.columns.is_unique and hasattr(self, '_item_cache'):
    724             for k in self.columns:
    725                 yield k, self._get_item_cache(k)

AttributeError: 'list' object has no attribute 'is_unique'
AttributeError: 'list' object has no attribute 'is_unique'


Moderator
Moderator

Hi @SebastianFSA,

 

So I have run a couple of tests with Alteryx Designer 2018.3 non admin -which seems to be your version too- but I have not been able to reproduce your issue. Could you please share your workflow with me if possible ?

 

Kind regards,

 

Paul Noirel

Sr Customer Support Engineer, Alteryx

Meteor

I have the same issue. It appears this is an internal setting with the execute.py package whereby it has a very small timeout threshold of 30 seconds. How can we adjust this threshold?

 

Error: Python (17): [NbConvertApp] Converting notebook C:\ProgramData\Alteryx\Engine\a1ed0ce5-5267-4e7b-9782-544d5ba1cf2b\17\workbook.ipynb to html
[NbConvertApp] Executing notebook with kernel: python3
[NbConvertApp] ERROR | Timeout waiting for execute reply (30s).
Traceback (most recent call last):
File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\nbconvert\preprocessors\execute.py", line 324, in _wait_for_reply
msg = self.kc.shell_channel.get_msg(timeout=timeout)
File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\jupyter_client\blocking\channels.py", line 57, in get_msg
raise Empty
queue.Empty

Moderator
Moderator

Hi @ecastruita,

 

You are correct: by default Jupyter -what is used as an interface for Python tool- uses a timeout of 30 seconds per cell execution.

 

You have a couple of options to change this behaviour:

 

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Python-Tool-Timeouts-When-Running-Work...

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Python-Tool-Timeout-waiting-for-execut...

 

Could you please me know if this works for you ?

 

Kind regards,

 

Paul Noirel

Sr Customer Support Engineer, Alteryx

Meteor

Thank you, the solution to change line 68 in the "execute.py" file to -1 from 30 worked. I reinstalled the server after having done this and the change persisted.

Labels