taipy icon indicating copy to clipboard operation
taipy copied to clipboard

Provide more explainability to TaipyGui Warnings/Errors

Open FlorianJacta opened this issue 1 year ago • 3 comments

Description The goal would be to explain the warning raised by Taipy GUI. This will make debugging of code easier.

Example of Taipy GUI warnings:

TaipyGuiWarning: Decoding Message has failed: {'type': 'U', 'name': '_TpLv_tpec_TpExPr_selected_q_question_TPMDL_1', 
'payload': {'value': 'Wie zufrieden bist Du alles in allem mit Deiner ArbeitMit Arbeit ist der Arbeitsplatz / die Anstellung 
insgesamt gemeint. bei Prognos?', 'relvar': '_TpL_tpec_TpExPr_q_questions_TPMDL_1', 'on_change': 'update_graph'}, 
'propagate': True, 'client_id': '20230710143328671703-0.5853907425756374', 'ack_id': 'e82fca37-39bd-48d7-9b98-
5ebe6c5d8449', 'module_context': '__main__'}
'types.SimpleNamespace' object has no attribute '_TpLv_tpec_TpExPr_selected_q_question_TPMDL_1'

Acceptance Criteria

  • [ ] Ensure new code is unit tested, and check code coverage is at least 90%
  • [ ] Propagate any change on the demos and run all of them to ensure there is no breaking change
  • [ ] Ensure any change is well documented

FlorianJacta avatar Jul 20 '23 10:07 FlorianJacta

That would be really great. I was going to raise a similar thing for Python exceptions, though I am not sure if it's the same or should I raise another issue? When you get exceptions on callbacks you only get the description. You don't get where it happened or which exception. Can make complex projects confusing and hard to debug.

Examples:

page = """
<|button|label=Press for errors|on_action=raise_exceptions|>
"""
def raise_exceptions(state:State):
    raise KeyError("This is an KeyError")
# This would give us:
# TaipyGuiWarning: on_action(): Exception raised in 'raise_exceptions()':
# 'This is an KeyError'
# TaipyGuiWarning: on_action(): 'raise_exceptions' is not a valid function.
page = """
<|button|label=Press for errors|on_action=raise_exceptions|>
"""
def raise_exceptions(state:State):
    assert False, "This is an assertion error message!"
# This would give us:
# TaipyGuiWarning: on_action(): Exception raised in 'raise_exceptions()':
# This is an assertion error message!
# TaipyGuiWarning: on_action(): 'raise_exceptions' is not a valid function.

Only workaround I know is using the traceback library:

from taipy.gui import State, Gui
import traceback
page = """
<|button|label=Press for errors|on_action=raise_exceptions|>
"""
def raise_exceptions(state:State):
    try:
        raise KeyError("This is an KeyError")
    except:
        traceback.print_exc()
        raise
# This would give you:
# Traceback (most recent call last):
#   File "/path/to/file.py", line 8, in raise_exceptions
#     raise KeyError("This is an KeyError")
# KeyError: 'This is an KeyError'
# TaipyGuiWarning: on_action(): Exception raised in 'raise_exceptions()':
# 'This is an KeyError'
# TaipyGuiWarning: on_action(): 'raise_exceptions' is not a valid function.

gbritoda avatar Sep 25 '23 16:09 gbritoda

I think this is a different issue, as you are not talking about user code errors. This issue is more focused on a specifc type of warnings/errors that comes from Taipy (even if the errors are the product of the users).

Nonetheless, this is an interesting issue. Do you want me to create another issue or do you want to create it?

FlorianJacta avatar Sep 26 '23 11:09 FlorianJacta

Hi @FlorianJacta , I can raise another issue. That's no problem. Raised Avaiga/taipy-gui#933

gbritoda avatar Sep 26 '23 14:09 gbritoda

Hi @FlorianJacta, Do you have some simple code that reproduce this issue ? Tx

FredLL-Avaiga avatar Feb 28 '24 09:02 FredLL-Avaiga

Hi @FlorianJacta, Do you have some simple code that reproduce this issue ? Tx

No, I don't have one right now.

FlorianJacta avatar Feb 28 '24 12:02 FlorianJacta