@@ -56,11 +56,16 @@ def update_dataset(
5656 If the attribute exists in the source object or the key exists in the dictionary,
5757 it will be set as the corresponding attribute in the destination dataset.
5858
59+ Computed items are automatically skipped as they are read-only and their values
60+ are calculated automatically based on other dataset items.
61+
5962 Returns:
6063 None
6164 """
6265 for item in dest ._items :
6366 key = item ._name
67+ if isinstance (item .get_prop ("data" , "computed" , None ), gdt .ComputedProp ):
68+ continue # Skip computed items
6469 if hasattr (source , key ):
6570 try :
6671 hide = item .get_prop_value ("display" , source , "hide" , False )
@@ -86,13 +91,19 @@ def restore_dataset(source: gdt.DataSet, dest: Any | dict[str, Any]) -> None:
8691
8792 Symmetrically from `update_dataset`, `dest` may also be a dictionary.
8893
94+ Computed items are automatically skipped when restoring to another dataset object
95+ (since computed values should be recalculated), but are included when restoring
96+ to a dictionary (since dictionaries store all current values).
97+
8998 Returns:
9099 None
91100 """
92101 for item in source ._items :
93102 key = item ._name
94103 value = getattr (source , key )
95104 if hasattr (dest , key ):
105+ if isinstance (item .get_prop ("data" , "computed" , None ), gdt .ComputedProp ):
106+ continue # Skip computed items if destination is not a dictionary
96107 try :
97108 setattr (dest , key , value )
98109 except AttributeError :
0 commit comments