@@ -138,22 +138,40 @@ def format_value(v):
138
138
return f"BlockState(\n { attributes } \n )"
139
139
140
140
141
+ @dataclass
142
+ class ComponentSpec :
143
+ """Specification for a pipeline component."""
144
+ name : str
145
+ type_hint : Type
146
+ description : Optional [str ] = None
147
+ default : Any = None # you can create a default component if it is a stateless class like scheduler, guider or image processor
148
+ default_class_name : Union [str , List [str ], Tuple [str , str ]] = None # Either "class_name" or ["module", "class_name"]
149
+ default_repo : Optional [Union [str , List [str ]]] = None # either "repo" or ["repo", "subfolder"]
150
+
151
+ @dataclass
152
+ class ConfigSpec :
153
+ """Specification for a pipeline configuration parameter."""
154
+ name : str
155
+ default : Any
156
+ description : Optional [str ] = None
157
+
158
+
141
159
@dataclass
142
160
class InputParam :
143
161
name : str
162
+ type_hint : Any = None
144
163
default : Any = None
145
164
required : bool = False
146
165
description : str = ""
147
- type_hint : Any = Any
148
166
149
167
def __repr__ (self ):
150
168
return f"<{ self .name } : { 'required' if self .required else 'optional' } , default={ self .default } >"
151
169
152
170
@dataclass
153
171
class OutputParam :
154
172
name : str
173
+ type_hint : Any
155
174
description : str = ""
156
- type_hint : Any = Any
157
175
158
176
def __repr__ (self ):
159
177
return f"<{ self .name } : { self .type_hint .__name__ if hasattr (self .type_hint , '__name__' ) else str (self .type_hint )} >"
@@ -338,49 +356,40 @@ def make_doc_string(inputs, intermediates_inputs, outputs, description=""):
338
356
return output
339
357
340
358
341
- @dataclass
342
- class ComponentSpec :
343
- """Specification for a pipeline component."""
344
- name : str
345
- type_hint : Optional [Type ] = None
346
- description : Optional [str ] = None
347
- default : Any = None # you can create a default component if it is a stateless class like scheduler, guider or image processor
348
- default_class_name : Union [str , List [str ], Tuple [str , str ]] # Either "class_name" or ["module", "class_name"]
349
- default_repo : Optional [Union [str , List [str ]]] = None # either "repo" or ["repo", "subfolder"]
350
-
351
- @dataclass
352
- class ConfigSpec :
353
- """Specification for a pipeline configuration parameter."""
354
- name : str
355
- default : Any
356
- description : Optional [str ] = None
357
- type_hint : Optional [Type ] = None
358
359
359
360
class PipelineBlock :
360
-
361
- component_specs : List [ComponentSpec ] = []
362
- config_specs : List [ConfigSpec ] = []
361
+
363
362
model_name = None
364
363
365
364
@property
366
365
def description (self ) -> str :
367
366
"""Description of the block. Must be implemented by subclasses."""
368
367
raise NotImplementedError ("description method must be implemented in subclasses" )
368
+
369
+ @property
370
+ def components (self ) -> List [ComponentSpec ]:
371
+ return []
369
372
373
+ @property
374
+ def configs (self ) -> List [ConfigSpec ]:
375
+ return []
376
+
377
+
378
+ # YiYi TODO: can we combine inputs and intermediates_inputs? the difference is inputs are immutable
370
379
@property
371
380
def inputs (self ) -> List [InputParam ]:
372
381
"""List of input parameters. Must be implemented by subclasses."""
373
- raise NotImplementedError ( "inputs method must be implemented in subclasses" )
382
+ return []
374
383
375
384
@property
376
385
def intermediates_inputs (self ) -> List [InputParam ]:
377
386
"""List of intermediate input parameters. Must be implemented by subclasses."""
378
- raise NotImplementedError ( "intermediates_inputs method must be implemented in subclasses" )
387
+ return []
379
388
380
389
@property
381
390
def intermediates_outputs (self ) -> List [OutputParam ]:
382
391
"""List of intermediate output parameters. Must be implemented by subclasses."""
383
- raise NotImplementedError ( "intermediates_outputs method must be implemented in subclasses" )
392
+ return []
384
393
385
394
# Adding outputs attributes here for consistency between PipelineBlock/AutoPipelineBlocks/SequentialPipelineBlocks
386
395
@property
@@ -403,10 +412,6 @@ def required_intermediates_inputs(self) -> List[str]:
403
412
input_names .append (input_param .name )
404
413
return input_names
405
414
406
- def __init__ (self ):
407
- self .components : Dict [str , Any ] = {}
408
- self .auxiliaries : Dict [str , Any ] = {}
409
- self .configs : Dict [str , Any ] = {}
410
415
411
416
def __call__ (self , pipeline , state : PipelineState ) -> PipelineState :
412
417
raise NotImplementedError ("__call__ method must be implemented in subclasses" )
0 commit comments