@@ -155,6 +155,8 @@ def path(self) -> str:
155
155
156
156
@path .setter
157
157
def path (self , path ):
158
+ # For un-configured input/output, we build a default data entry for them.
159
+ self ._build_default_data ()
158
160
if hasattr (self ._data , "path" ):
159
161
self ._data .path = path
160
162
else :
@@ -361,7 +363,9 @@ def is_control(self) -> str:
361
363
def _build_default_data (self ):
362
364
"""Build default data when output not configured."""
363
365
if self ._data is None :
364
- self ._data = Output ()
366
+ # _meta will be None when node._component is not a Component object
367
+ # so we just leave the type inference work to backend
368
+ self ._data = Output (type = None )
365
369
366
370
def _build_data (self , data , key = None ):
367
371
"""Build output data according to assigned input, eg: node.outputs.key = data"""
@@ -593,15 +597,13 @@ def _validate_inputs(cls, inputs):
593
597
594
598
def __getattr__ (self , name : K ) -> V :
595
599
if name not in self :
596
- # pylint: disable=unnecessary-comprehension
597
- raise UnexpectedAttributeError (keyword = name , keywords = [key for key in self ])
600
+ raise UnexpectedAttributeError (keyword = name , keywords = list (self ))
598
601
return super ().__getitem__ (name )
599
602
600
603
def __getitem__ (self , item : K ) -> V :
601
604
# We raise this exception instead of KeyError
602
605
if item not in self :
603
- # pylint: disable=unnecessary-comprehension
604
- raise UnexpectedKeywordError (func_name = "ParameterGroup" , keyword = item , keywords = [key for key in self ])
606
+ raise UnexpectedKeywordError (func_name = "ParameterGroup" , keyword = item , keywords = list (self ))
605
607
return super ().__getitem__ (item )
606
608
607
609
# For Jupyter Notebook auto-completion
@@ -654,6 +656,13 @@ def __init__(self, outputs: dict, **kwargs):
654
656
def __getattr__ (self , item ) -> NodeOutput :
655
657
return self .__getitem__ (item )
656
658
659
+ def __getitem__ (self , item ) -> NodeOutput :
660
+ if item not in self :
661
+ # We raise this exception instead of KeyError as OutputsAttrDict doesn't support add new item after
662
+ # __init__.
663
+ raise UnexpectedAttributeError (keyword = item , keywords = list (self ))
664
+ return super ().__getitem__ (item )
665
+
657
666
def __setattr__ (self , key : str , value : Union [Data , Output ]):
658
667
if isinstance (value , Output ):
659
668
mode = value .mode
0 commit comments