Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Python tool logging error

Navigator
6 - Meteoroid

Hi all,

 

Facing an issue with the Python tool if anyone could help please. Running Alteryx Designer admin version 2020.3.5.30242

 

On first opening the workflow and trying to run I get the following error:

 

Error: Python (2): --- Logging error ---
Traceback (most recent call last):
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\nbformat\validator.py", line 258, in validate
return validator.validate(nbjson)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\jsonschema\validators.py", line 348, in validate
raise error
jsonschema.exceptions.ValidationError: {'cell_type': 'code', 'execution_count': None, 'metadata': {}, 'outputs': [], 'source': None} is not valid under any of the given schemas

Failed validating 'oneOf' in schema['properties']['cells']['items']:
{'oneOf': [{'$ref': '#/definitions/raw_cell'},
{'$ref': '#/definitions/markdown_cell'},
{'$ref': '#/definitions/code_cell'}],
'type': 'object'}

On instance['cells'][2]['source']:
{'cell_type': 'code',
'execution_count': None,
'metadata': {},
'outputs': [],
'source': None}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\nbconvert\exporters\exporter.py", line 318, in _preprocess
nbformat.validate(nbc, relax_add_props=True)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\nbformat\validator.py", line 260, in validate
raise better_validation_error(e, version, version_minor)
nbformat.validator.NotebookValidationError: None is not valid under any of the given schemas

Failed validating 'oneOf' in code_cell['properties']['source']:

On instance['cells'][2]['source']:
None

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\logging\__init__.py", line 994, in emit
msg = self.format(record)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\logging\__init__.py", line 840, in format
return fmt.format(record)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\traitlets\config\application.py", line 117, in format
return super(LevelFormatter, self).format(record)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\logging\__init__.py", line 577, in format
record.message = record.getMessage()
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\logging\__init__.py", line 338, in getMessage
msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Program Files\Alteryx\bin\Miniconda3\envs\JupyterTool_vEnv\Scripts\jupyter-nbconvert.EXE\__main__.py", line 7, in <module>
sys.exit(main())
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\jupyter_core\application.py", line 266, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
app.start()
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\nbconvert\nbconvertapp.py", line 338, in start
self.convert_notebooks()
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\nbconvert\nbconvertapp.py", line 508, in convert_notebooks
self.convert_single_notebook(notebook_filename)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\nbconvert\nbconvertapp.py", line 479, in convert_single_notebook
output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\nbconvert\nbconvertapp.py", line 408, in export_single_notebook
output, resources = self.exporter.from_filename(notebook_filename, resources=resources)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\nbconvert\exporters\exporter.py", line 179, in from_filename
return self.from_file(f, resources=resources, **kw)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\nbconvert\exporters\exporter.py", line 197, 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\envs\jupytertool_venv\lib\site-packages\nbconvert\exporters\notebook.py", line 32, in from_notebook_node
nb_copy, resources = super(NotebookExporter, self).from_notebook_node(nb, resources, **kw)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\nbconvert\exporters\exporter.py", line 139, in from_notebook_node
nb_copy, resources = self._preprocess(nb_copy, resources)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\nbconvert\exporters\exporter.py", line 321, in _preprocess
preprocessor)
Message: 'Notebook is invalid after preprocessor {}'
Arguments: (<nbconvert.preprocessors.tagremove.TagRemovePreprocessor object at 0x00000205F8C61198>,)
Traceback (most recent call last):
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\nbformat\validator.py", line 258, in validate
return validator.validate(nbjson)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\jsonschema\validators.py", line 348, in validate
raise error
jsonschema.exceptions.ValidationError: {'cell_type': 'code', 'execution_count': None, 'metadata': {}, 'outputs': [], 'source': None} is not valid under any of the given schemas

Failed validating 'oneOf' in schema['properties']['cells']['items']:
{'oneOf': [{'$ref': '#/definitions/raw_cell'},
{'$ref': '#/definitions/markdown_cell'},
{'$ref': '#/definitions/code_cell'}],
'type': 'object'}

On instance['cells'][2]['source']:
{'cell_type': 'code',
'execution_count': None,
'metadata': {},
'outputs': [],
'source': None}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Program Files\Alteryx\bin\Miniconda3\envs\JupyterTool_vEnv\Scripts\jupyter-nbconvert.EXE\__main__.py", line 7, in <module>
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\jupyter_core\application.py", line 266, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
app.start()
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\nbconvert\nbconvertapp.py", line 338, in start
self.convert_notebooks()
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\nbconvert\nbconvertapp.py", line 508, in convert_notebooks
self.convert_single_notebook(notebook_filename)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\nbconvert\nbconvertapp.py", line 479, in convert_single_notebook
output, resources = self.export_single_notebook(notebook_filename, resources, input_buffer=input_buffer)
File "c:\program files\alteryx\bin\miniconda3\envs\jupytertool_venv\lib\site-packages\nbconvert\nbconvertapp.py", line 408, in export_single_notebook

 

 

I then click on the Python tool and see the following:

 

Navigator_0-1607939117881.png

 

If I click OK and manually run the jupyter workbook, then the run completes successfully and the entire Alteryx workflow can be run afterwards.

I can of course run it manually this way but I was hoping to schedule the workflow.

 

Would anyone be able to help please?

 

Thanks

Anton

 

 

 

7 REPLIES 7
atcodedog05
22 - Nova
22 - Nova

Hi @Navigator 

 

This line of code is the issue.

 

jsonschema.exceptions.ValidationError: {'cell_type': 'code', 'execution_count': None, 'metadata': {}, 'outputs': [], 'source': None}

 

This is creating all other issues.

 

 

Navigator
6 - Meteoroid

Thanks @atcodedog05 

 

I'm not sure what that line means as it's not a line in my code.

 

The code is below if it helps:

 

from ayx import Alteryx
import pandas as pd
import requests
from bs4 import BeautifulSoup

 

url = "XXX"
page = requests.get(url)

soup = BeautifulSoup(page.text, 'html.parser')
table1 = soup.find('table', id=YYY")
table2 = soup.find('table', id="ZZZ")

tbl1 = pd.read_html(table1.prettify(), header = 0, flavor='bs4')[0]
tbl1 = tbl1.iloc[1:].reset_index(drop = True)

tbl2 = pd.read_html(table2.prettify(), header = 0, flavor='bs4')[0]
tbl2 = tbl2.iloc[[1], [0,1,2]].reset_index(drop = True)

upd = soup.findAll('div', attrs={"class":"weekly-table"})
for x in upd:
upd = x.find('p').text
upd = upd.split(':')
upd = pd.DataFrame(upd, columns = ['Last updated'])
upd = upd.iloc[1:].reset_index(drop = True)
upd['Last updated'] = upd['Last updated'].str.strip()
upd['Last updated'] = pd.to_datetime(upd['Last updated'])


Alteryx.write(tbl1,1)
Alteryx.write(tbl2,2)
Alteryx.write(upd,3)

atcodedog05
22 - Nova
22 - Nova

Hi @Navigator 

 

This error could be due to split function it throws error on None so you need replace None with null before split.

 

before this line replace None with ""

upd = upd.split(':')

Navigator
6 - Meteoroid

Hi @atcodedog05 ,

 

Thank you for your suggestion.

I've been playing with it and i'm not sure i can replace null there as it's a string so it either returns data or returns null in which case the workflow fails.

 

I guess the question is more why it returns null on just running the alteryx workflow and returns data if i physically run the jupyter workbook from within the python tool. Feels like some service or similar not starting unless i run from within the python tool manually first?

atcodedog05
22 - Nova
22 - Nova

Hi @Navigator 

 

Truth being said its always a best practice to run the code on embedded jupyter, check for expected output and then run the workflow.😅

Navigator
6 - Meteoroid

The python tool was switched from Interactive to Production and it solved the problem. Just in case anybody else has this issue.

dcates
6 - Meteoroid

Changing to production worked. Thanks!

Labels