File tree Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
49
49
- Fixed debugging with VSCode IDE ([ #15747 ] ( https://github.com/Lightning-AI/lightning/pull/15747 ) )
50
50
51
51
52
+ - Fixed setting property to the LightningFlow ([ #15750 ] ( https://github.com/Lightning-AI/lightning/pull/15750 ) )
53
+
54
+
52
55
53
56
## [ 1.8.1] - 2022-11-10
54
57
Original file line number Diff line number Diff line change @@ -110,7 +110,11 @@ def name(self):
110
110
"""Return the current LightningFlow name."""
111
111
return self ._name or "root"
112
112
113
- def __setattr__ (self , name , value ):
113
+ def __setattr__ (self , name : str , value : Any ) -> None :
114
+ attr = getattr (self .__class__ , name , None )
115
+ if isinstance (attr , property ) and attr .fset is not None :
116
+ return attr .fset (self , value )
117
+
114
118
from lightning_app .structures import Dict , List
115
119
116
120
if (
Original file line number Diff line number Diff line change @@ -1108,3 +1108,36 @@ def test_cloud_compute_binding():
1108
1108
1109
1109
with pytest .raises (Exception , match = "A Cloud Compute can be assigned only to a single Work" ):
1110
1110
FlowCC ()
1111
+
1112
+
1113
+ class FlowValue (LightningFlow ):
1114
+ def __init__ (self ):
1115
+ super ().__init__ ()
1116
+ self ._value = None
1117
+ self ._has_found = False
1118
+
1119
+ @property
1120
+ def value (self ):
1121
+ return self ._value
1122
+
1123
+ @value .setter
1124
+ def value (self , value ):
1125
+ self ._value = value
1126
+
1127
+ def run (self ):
1128
+ if self .value is None :
1129
+ self .value = True
1130
+
1131
+ def __setattr__ (self , name , value ):
1132
+ if name == "_value" and value is True :
1133
+ self ._has_found = True
1134
+ super ().__setattr__ (name , value )
1135
+
1136
+
1137
+ def test_lightning_flow_properties ():
1138
+ """Validates setting properties to the LightningFlow properly calls property.fset."""
1139
+
1140
+ flow = FlowValue ()
1141
+ assert not flow ._has_found
1142
+ flow .run ()
1143
+ assert flow ._has_found
You can’t perform that action at this time.
0 commit comments