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/).
4949- Fixed debugging with VSCode IDE ([ #15747 ] ( https://github.com/Lightning-AI/lightning/pull/15747 ) )
5050
5151
52+ - Fixed setting property to the LightningFlow ([ #15750 ] ( https://github.com/Lightning-AI/lightning/pull/15750 ) )
53+
54+
5255
5356## [ 1.8.1] - 2022-11-10
5457
Original file line number Diff line number Diff line change @@ -110,7 +110,11 @@ def name(self):
110110 """Return the current LightningFlow name."""
111111 return self ._name or "root"
112112
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+
114118 from lightning_app .structures import Dict , List
115119
116120 if (
Original file line number Diff line number Diff line change @@ -1108,3 +1108,36 @@ def test_cloud_compute_binding():
11081108
11091109 with pytest .raises (Exception , match = "A Cloud Compute can be assigned only to a single Work" ):
11101110 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