Explorar el Código

better message on column not found (#967)

* Updated utils.py for better warning messages (#617)

* Updated utils.py for better warning messages

* added value check for dataframe

* added the check at the warning level

* resolved linter comments

* added required changes

* Linter Changes

* Linter Changes

---------

Co-authored-by: Fred Lefévère-Laoide <90181748+FredLL-Avaiga@users.noreply.github.com>

* format and small fix

* Update taipy/gui/_renderers/utils.py

Co-authored-by: Fabien Lelaquais <86590727+FabienLelaquais@users.noreply.github.com>

* Update taipy/gui/_renderers/utils.py

Co-authored-by: Fabien Lelaquais <86590727+FabienLelaquais@users.noreply.github.com>

* mypy

* linter

---------

Co-authored-by: Srinivas Pavan <34889400+srinivaspavan9@users.noreply.github.com>
Co-authored-by: Fred Lefévère-Laoide <Fred.Lefevere-Laoide@Taipy.io>
Co-authored-by: Fabien Lelaquais <86590727+FabienLelaquais@users.noreply.github.com>
Fred Lefévère-Laoide hace 1 año
padre
commit
055f7983e4
Se han modificado 2 ficheros con 25 adiciones y 4 borrados
  1. 1 1
      taipy/core/_orchestrator/_orchestrator.py
  2. 24 3
      taipy/gui/_renderers/utils.py

+ 1 - 1
taipy/core/_orchestrator/_orchestrator.py

@@ -77,7 +77,7 @@ class _Orchestrator(_AbstractOrchestrator):
             getattr(submittable, "config_id", None),
             getattr(submittable, "config_id", None),
             **properties,
             **properties,
         )
         )
-        jobs = []
+        jobs: List[Job] = []
         tasks = submittable._get_sorted_tasks()
         tasks = submittable._get_sorted_tasks()
         with cls.lock:
         with cls.lock:
             for ts in tasks:
             for ts in tasks:

+ 24 - 3
taipy/gui/_renderers/utils.py

@@ -11,6 +11,8 @@
 
 
 import typing as t
 import typing as t
 
 
+import pandas as pd
+
 from .._warnings import _warn
 from .._warnings import _warn
 from ..types import NumberTypes
 from ..types import NumberTypes
 from ..utils import _RE_PD_TYPE, _get_date_col_str_name, _MapDict
 from ..utils import _RE_PD_TYPE, _get_date_col_str_name, _MapDict
@@ -31,14 +33,33 @@ def _get_columns_dict_from_list(
 ):
 ):
     col_dict = {}
     col_dict = {}
     idx = 0
     idx = 0
+    cols = None
+
     for col in col_list:
     for col in col_list:
         if col in col_types_keys:
         if col in col_types_keys:
             col_dict[col] = {"index": idx}
             col_dict[col] = {"index": idx}
             idx += 1
             idx += 1
         elif col:
         elif col:
-            _warn(
-                f'Error column "{col}" is not present in the Dataframe "{value.head(0) if hasattr(value, "head") else value}".'  # noqa: E501
-            )
+            if cols is None:
+                cols = (
+                    list(value.columns)
+                    if isinstance(value, pd.DataFrame)
+                    else list(value.keys())
+                    if isinstance(value, (dict, _MapDict))
+                    else value
+                    if isinstance(value, (list, tuple))
+                    else []
+                )
+
+            if cols and (col not in cols):
+                _warn(
+                    f'Column "{col}" is not present. Available columns: {cols}.'  # noqa: E501
+                )
+            else:
+                _warn(
+                    "The 'data' property value is of an unsupported type."
+                    + " Only DataFrame, dict, list, or tuple are supported."
+                )
     return col_dict
     return col_dict