great_expectations icon indicating copy to clipboard operation
great_expectations copied to clipboard

renderer crashes when try to render checkpoint result

Open uglypod opened this issue 2 years ago • 10 comments

Describe the bug When i add expect_column_values_to_match_like_pattern expectation to my suite, everything going fine, until build_data_docs after checkpoint run

To Reproduce Steps to reproduce the behavior:

  1. Add expect_column_values_to_match_like_pattern to suite
  2. Run checkpoint
  3. Rebuild data_docs

Expected behavior

Environment (please complete the following information):

  • Operating System: Windows 11
  • Great Expectations Version: 0.15.5

Additional context

An unexpected Exception occurred during data docs rendering.  Because of this error, certain parts of data docs will not be rendered properly and/or may not appear altogether.  Please use the trace, included in this message, to diagnose and repair the underlying issue.  Detailed information follows:
        TypeError: "unsupported operand type(s) for +=: 'NoneType' and 'list'".  Traceback: "Traceback (most recent call last):
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\content_block.py", line 99, in _render_list
    result = content_block_fn(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\validation_results_table_content_block.py", line 195, in row_generator_fn
    expectation_string_cell += unexpected_statement
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'list'
".
c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\validation_results_table_content_block.py:223: DeprecationWarning: V2 API style custom rendering is deprecated as of v0.13.28 and is not fully supported anymore; As it will be removed in v0.16, please transition to V3 API and associated rendering style
  warnings.warn(
An unexpected Exception occurred during data docs rendering.  Because of this error, certain parts of data docs will not be rendered properly and/or may not appear altogether.  Please use the trace, included in this message, to diagnose and repair the underlying issue.  Detailed information follows:
                AttributeError: "'NoneType' object has no attribute 'expectation_type'".  Traceback: "Traceback (most recent call last):
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\content_block.py", line 99, in _render_list
    result = content_block_fn(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\validation_results_table_content_block.py", line 195, in row_generator_fn
    expectation_string_cell += unexpected_statement
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'list'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\site_builder.py", line 464, in build
    rendered_content = self.renderer_class.render(resource)
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\page_renderer.py", line 124, in render
    sections = self._collect_rendered_document_content_sections(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\page_renderer.py", line 265, in _collect_rendered_document_content_sections
    sections += [
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\page_renderer.py", line 266, in <listcomp>
    self._column_section_renderer.render(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\column_section_renderer.py", line 485, in render
    remaining_evrs, content_block = self._render_table(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\column_section_renderer.py", line 473, in _render_table
    new_block = self._table_renderer.render(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\content_block.py", line 63, in render
    result = render_fn(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\content_block.py", line 124, in _render_list
    result = content_block_fn(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\validation_results_table_content_block.py", line 114, in row_generator_fn
    expectation_string_cell = expectation_string_fn(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\validation_results_table_content_block.py", line 236, in expectation_string_fn_with_legacy_translation
    return legacy_expectation_string_fn(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\expectation_string.py", line 25, in _missing_content_block_fn
    "expectation_type": configuration.expectation_type,
AttributeError: 'NoneType' object has no attribute 'expectation_type'
".
An unexpected Exception occurred during data docs rendering.  Because of this error, certain parts of data docs will not be rendered properly and/or may not appear altogether.  Please use the trace, included in this message, to diagnose and repair the underlying issue.  Detailed information follows:
        TypeError: "unsupported operand type(s) for +=: 'NoneType' and 'list'".  Traceback: "Traceback (most recent call last):
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\content_block.py", line 99, in _render_list
    result = content_block_fn(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\validation_results_table_content_block.py", line 195, in row_generator_fn
    expectation_string_cell += unexpected_statement
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'list'
".
An unexpected Exception occurred during data docs rendering.  Because of this error, certain parts of data docs will not be rendered properly and/or may not appear altogether.  Please use the trace, included in this message, to diagnose and repair the underlying issue.  Detailed information follows:
                AttributeError: "'NoneType' object has no attribute 'expectation_type'".  Traceback: "Traceback (most recent call last):
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\content_block.py", line 99, in _render_list
    result = content_block_fn(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\validation_results_table_content_block.py", line 195, in row_generator_fn
    expectation_string_cell += unexpected_statement
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'list'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\site_builder.py", line 464, in build
    rendered_content = self.renderer_class.render(resource)
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\page_renderer.py", line 124, in render
    sections = self._collect_rendered_document_content_sections(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\page_renderer.py", line 265, in _collect_rendered_document_content_sections
    sections += [
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\page_renderer.py", line 266, in <listcomp>
    self._column_section_renderer.render(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\column_section_renderer.py", line 485, in render
    remaining_evrs, content_block = self._render_table(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\column_section_renderer.py", line 473, in _render_table
    new_block = self._table_renderer.render(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\content_block.py", line 63, in render
    result = render_fn(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\content_block.py", line 124, in _render_list
    result = content_block_fn(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\validation_results_table_content_block.py", line 114, in row_generator_fn
    expectation_string_cell = expectation_string_fn(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\validation_results_table_content_block.py", line 236, in expectation_string_fn_with_legacy_translation
    return legacy_expectation_string_fn(
  File "c:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\great_expectations\render\renderer\content_block\expectation_string.py", line 25, in _missing_content_block_fn
    "expectation_type": configuration.expectation_type,
AttributeError: 'NoneType' object has no attribute 'expectation_type'
".

".

uglypod avatar Jul 26 '22 06:07 uglypod

Howdy @uglypod 👋 thanks for raising this with us 🙇 and being a part of the community 🤗

We'll bring it up with the team 🔬

AFineDayFor avatar Jul 28 '22 15:07 AFineDayFor

Any update on this? I'm seeing this as well for expect_column_values_to_not_match_like_pattern on Windows 11 with great_expectations version 0.15.23.

daviewales avatar Sep 28 '22 23:09 daviewales

Thanks for looking into this for us @rdodev we really appreciate it as we have quite a few expectation suites depending on the expect_column_values_to_not_match_like_pattern() function. Our team is working on debugging this error also.

Commenting out the data_docs build code from the Jupyter Notebook (lines 104 & 107 below) circumvents the bug but obviously this is not a viable solution:

image

We suspect this core GE file is problematic:

/usr/local/lib/python3.10/dist-packages/great_expectations/render/renderer/content_block/validation_results_table_content_block.py

image

image

We're running Great Expectations version 0.15.31 under Ubuntu 22.04 (bug occurs also in previous versions). We've found that this error also occurs under Windows 11 after running a new expectation suite generated in Jupyter Notebook. Our database is Microsoft SQL Server 2017.

jstucken avatar Nov 09 '22 22:11 jstucken

Looking at a debugger, I can see that the function which creates the problematic expectation_string_cell is expectation_string_fn in /usr/local/lib/python3.10/dist-packages/great_expectations/render/renderer/content_block/validation_results_table_content_block.py. However, further inspection reveals that this function is in fact _prescriptive_renderer from /usr/local/lib/python3.10/dist-packages/great_expectations/expectations/core/expect_column_values_to_match_like_pattern.py. It is interesting to note that this functionn explicitly returns None, and the traceback is due to attempting to add None to something.

daviewales avatar Nov 09 '22 23:11 daviewales

Can we please escalate this issue as I believe it is not just limited to mssql databases as it occurs also using a sqlite database within a very limited/isolated test environment, which I have attached as a zip file.

Steps to reproduce

  1. Download and extract great_expectations_sqlite_sharks.zip. This very simple sqlite database sharks.db contains 3 test records:

image

  1. Run the working benchmark checkpoint great_expectations checkpoint run sharks_checkpoint
  2. Note that the data docs get correctly generated within the uncommitted/data_docs/ folder, as expected
  3. Now run great_expectations checkpoint run sharks_checkpoint_bug and note the data docs render error:

image

Other steps taken to isolate the bug:

  • have tested in Microsoft SQL Server 2017 and Microsoft SQL Server 2019
  • have tested under Python 3.8 and Python 3.10
  • the bug affects all environments listed above

Is there any other GE function we could use in the meantime which performs a similar job of 'Expect column entries to be strings that do NOT match a given like pattern expression'?

Many thanks!

jstucken avatar Nov 10 '22 06:11 jstucken

Hey @uglypod and @daviewales 👋 I will escalate with the engineering team. Will update as soon as I have an answer.

rdodev avatar Nov 10 '22 14:11 rdodev

A quick update: @uglypod / @daviewales

We determined this is a bug and it has been put in engineering queue. No promise on timing, but they're aware of the issue.

rdodev avatar Nov 10 '22 14:11 rdodev

Thanks @rdodev!

Something I've struggled with trying to debug this is that we only get the very last bit of traceback. If we make the following changes, we can get a full traceback:

Add raise e to the following lines:

great_expectations/render/renderer/content_block/content_block.py:113
great_expectations/render/renderer/site_builder.py:490

This skips GEs custom exception handling and allows the full traceback to bubble up to the top, giving the following:

Traceback (most recent call last):
  File "/home/great-expectations/./custom_scripts/new_expectation.py", line 102, in <module>
    context.build_data_docs()
  File "/usr/local/lib/python3.10/dist-packages/great_expectations/core/usage_statistics/usage_statistics.py", line 304, in usage_statistics_wrapped_method
    result = func(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/great_expectations/data_context/data_context/base_data_context.py", line 862, in build_data_docs
    index_page_resource_identifier_tuple = site_builder.build(
  File "/usr/local/lib/python3.10/dist-packages/great_expectations/render/renderer/site_builder.py", line 307, in build
    site_section_builder.build(resource_identifiers=resource_identifiers)
  File "/usr/local/lib/python3.10/dist-packages/great_expectations/render/renderer/site_builder.py", line 490, in build
    raise e
  File "/usr/local/lib/python3.10/dist-packages/great_expectations/render/renderer/site_builder.py", line 464, in build
    rendered_content = self.renderer_class.render(resource)
  File "/usr/local/lib/python3.10/dist-packages/great_expectations/render/renderer/page_renderer.py", line 125, in render
    sections = self._collect_rendered_document_content_sections(
  File "/usr/local/lib/python3.10/dist-packages/great_expectations/render/renderer/page_renderer.py", line 266, in _collect_rendered_document_content_sections
    sections += [
  File "/usr/local/lib/python3.10/dist-packages/great_expectations/render/renderer/page_renderer.py", line 267, in <listcomp>
    self._column_section_renderer.render(
  File "/usr/local/lib/python3.10/dist-packages/great_expectations/render/renderer/column_section_renderer.py", line 486, in render
    remaining_evrs, content_block = self._render_table(
  File "/usr/local/lib/python3.10/dist-packages/great_expectations/render/renderer/column_section_renderer.py", line 474, in _render_table
    new_block = self._table_renderer.render(
  File "/usr/local/lib/python3.10/dist-packages/great_expectations/render/renderer/content_block/content_block.py", line 64, in render
    result = render_fn(
  File "/usr/local/lib/python3.10/dist-packages/great_expectations/render/renderer/content_block/content_block.py", line 113, in _render_list
    raise e
  File "/usr/local/lib/python3.10/dist-packages/great_expectations/render/renderer/content_block/content_block.py", line 100, in _render_list
    result = content_block_fn(
  File "/usr/local/lib/python3.10/dist-packages/great_expectations/render/renderer/content_block/validation_results_table_content_block.py", line 196, in row_generator_fn
    expectation_string_cell += unexpected_statement
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'list'

custom_scripts/new_expectation.py is just a script containing the code you'd get from great_expectations suite new.

daviewales avatar Nov 10 '22 22:11 daviewales

One final trick that might help debug this.

If you run the code with IPython, you can enable a verbose traceback mode which automatically prints the values of all variables that appear in the Traceback. Enable this as follows:

ipython --InteractiveShell.xmode=Verbose script.py

daviewales avatar Nov 11 '22 03:11 daviewales

I have also found this issue to occur with these expectations:

  • expect_column_values_to_match_like_pattern_list
  • expect_column_values_to_match_like_pattern

Not running these allows the renderer to work with my (small) suite at least.

Is there any news on when this will be resolved?

Python: 3.8.10 GX Version: 0.17.17 Data source: mcr.microsoft.com/mssql/server:2019-latest

Error below:

An unexpected Exception occurred during data docs rendering.  Because of this error, certain parts of data docs will not be rendered properly and/or may not appear altogether.  Please use the trace, included in this message, to diagnose and repair the underlying issue.  Detailed information follows:
        TypeError: "object of type 'NoneType' has no len()".  Traceback: "Traceback (most recent call last):
  File "c:\users\c84058\cmds\.venv38\lib\site-packages\great_expectations\render\renderer\content_block\content_block.py", line 101, in _render_list
    result = content_block_fn(
  File "c:\users\c84058\cmds\.venv38\lib\site-packages\great_expectations\render\renderer\content_block\validation_results_table_content_block.py", line 202, in row_generator_fn
    if len(expectation_string_cell) > 1:
TypeError: object of type 'NoneType' has no len()
".
An unexpected Exception occurred during data docs rendering.  Because of this error, certain parts of data docs will not be rendered properly and/or may not appear altogether.  Please use the trace, included in this message, to diagnose and repair the underlying issue.  Detailed information follows:
                AttributeError: "'NoneType' object has no attribute 'kwargs'".  Traceback: "Traceback (most recent call last):
  File "c:\users\c84058\cmds\.venv38\lib\site-packages\great_expectations\render\renderer\content_block\content_block.py", line 101, in _render_list
    result = content_block_fn(
  File "c:\users\c84058\cmds\.venv38\lib\site-packages\great_expectations\render\renderer\content_block\validation_results_table_content_block.py", line 202, in row_generator_fn
    if len(expectation_string_cell) > 1:
TypeError: object of type 'NoneType' has no len()

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\c84058\cmds\.venv38\lib\site-packages\great_expectations\render\renderer\site_builder.py", line 475, in build
    rendered_content = self.renderer_class.render(resource)
  File "c:\users\c84058\cmds\.venv38\lib\site-packages\great_expectations\render\renderer\page_renderer.py", line 125, in render
    sections = self._collect_rendered_document_content_sections(
  File "c:\users\c84058\cmds\.venv38\lib\site-packages\great_expectations\render\renderer\page_renderer.py", line 265, in _collect_rendered_document_content_sections
    sections += [
  File "c:\users\c84058\cmds\.venv38\lib\site-packages\great_expectations\render\renderer\page_renderer.py", line 266, in <listcomp>
    self._column_section_renderer.render(
  File "c:\users\c84058\cmds\.venv38\lib\site-packages\great_expectations\render\renderer\column_section_renderer.py", line 452, in render
    remaining_evrs, content_block = self._render_table(
  File "c:\users\c84058\cmds\.venv38\lib\site-packages\great_expectations\render\renderer\column_section_renderer.py", line 440, in _render_table
    new_block = self._table_renderer.render(
  File "c:\users\c84058\cmds\.venv38\lib\site-packages\great_expectations\render\renderer\content_block\content_block.py", line 66, in render
    result = render_fn(
  File "c:\users\c84058\cmds\.venv38\lib\site-packages\great_expectations\render\renderer\content_block\content_block.py", line 126, in _render_list
    result = content_block_fn(
  File "c:\users\c84058\cmds\.venv38\lib\site-packages\great_expectations\render\renderer\content_block\validation_results_table_content_block.py", line 118, in row_generator_fn
    expectation_string_cell = expectation_string_fn(
  File "c:\users\c84058\cmds\.venv38\lib\site-packages\great_expectations\render\renderer\content_block\validation_results_table_content_block.py", line 240, in expectation_string_fn_with_legacy_translation
    return legacy_expectation_string_fn(
  File "c:\users\c84058\cmds\.venv38\lib\site-packages\great_expectations\render\renderer\content_block\expectation_string.py", line 25, in _missing_content_block_fn
    renderer_configuration: RendererConfiguration = RendererConfiguration(
  File "c:\users\c84058\cmds\.venv38\lib\site-packages\great_expectations\render\renderer_configuration.py", line 180, in __init__
    super().__init__(**values)
  File "pydantic\main.py", line 339, in pydantic.main.BaseModel.__init__
  File "pydantic\main.py", line 1102, in pydantic.main.validate_model
  File "c:\users\c84058\cmds\.venv38\lib\site-packages\great_expectations\render\renderer_configuration.py", line 364, in _validate_for_row_condition
    kwargs = values["configuration"].kwargs
AttributeError: 'NoneType' object has no attribute 'kwargs'
".

robinstauntoncollins avatar Sep 20 '23 15:09 robinstauntoncollins

This issue was just flagged in slack which led to looking: it appears to have been fixed as of the 0.18.x series of releases (I'm not sure the specific PR where it was fixed, but could reproduce on 0.17.17 but not 0.18.1)

jcampbell avatar May 06 '24 20:05 jcampbell