@@ -68,13 +68,18 @@ def generate_id(stream_type: str) -> str:
6868class CommandParameterBase :
6969 """Represents a parameter for a Plan."""
7070
71+ # NOTE: This attribute is only used by workflow-file machinery to check if plans are the same or not. We need it,
72+ # because names are generated randomly when not set by users which make the comparison return incorrect result.
73+ name_set_by_user : bool = False
74+
7175 def __init__ (
7276 self ,
7377 * ,
7478 default_value : Any ,
7579 description : Optional [str ],
7680 id : str ,
7781 name : Optional [str ],
82+ name_set_by_user : bool = False ,
7883 position : Optional [int ] = None ,
7984 prefix : Optional [str ] = None ,
8085 derived_from : Optional [str ] = None ,
@@ -90,6 +95,7 @@ def __init__(
9095 self .derived_from : Optional [str ] = derived_from
9196 # NOTE: ``postfix`` is used only to generate a nicer ``id`` for a parameter. Its value isn't used anywhere else.
9297 self .postfix : Optional [str ] = postfix
98+ self .name_set_by_user : bool = name_set_by_user
9399
94100 if name is not None :
95101 self .name : str = name
@@ -132,10 +138,13 @@ def role(self) -> str:
132138 @staticmethod
133139 def _get_equality_attributes () -> List [str ]:
134140 """Return a list of attributes values that determine if instances are equal."""
135- return ["name" , "description" , "default_value" , "prefix" , "position" ]
141+ # NOTE: We treat name differently
142+ return ["description" , "default_value" , "prefix" , "position" ]
136143
137144 def is_equal_to (self , other ) -> bool :
138145 """Return if attributes that cause a change in the parameter, are the same."""
146+ if self .name_set_by_user != other .name_set_by_user or (self .name_set_by_user and self .name != other .name ):
147+ return False
139148 return all (getattr (self , a ) == getattr (other , a ) for a in self ._get_equality_attributes ())
140149
141150 def to_argv (self , quote_string : bool = True ) -> List [Any ]:
@@ -193,6 +202,7 @@ def __init__(
193202 description : str = None ,
194203 id : str ,
195204 name : str = None ,
205+ name_set_by_user : bool = False ,
196206 position : Optional [int ] = None ,
197207 prefix : str = None ,
198208 derived_from : str = None ,
@@ -203,6 +213,7 @@ def __init__(
203213 description = description ,
204214 id = id ,
205215 name = name ,
216+ name_set_by_user = name_set_by_user ,
206217 position = position ,
207218 prefix = prefix ,
208219 derived_from = derived_from ,
@@ -245,6 +256,7 @@ def __init__(
245256 id : str ,
246257 mapped_to : Optional [MappedIOStream ] = None ,
247258 name : Optional [str ] = None ,
259+ name_set_by_user : bool = False ,
248260 position : Optional [int ] = None ,
249261 prefix : Optional [str ] = None ,
250262 encoding_format : Optional [List [str ]] = None ,
@@ -258,6 +270,7 @@ def __init__(
258270 description = description ,
259271 id = id ,
260272 name = name ,
273+ name_set_by_user = name_set_by_user ,
261274 position = position ,
262275 prefix = prefix ,
263276 derived_from = derived_from ,
@@ -323,6 +336,7 @@ def __init__(
323336 id : str ,
324337 mapped_to : Optional [MappedIOStream ] = None ,
325338 name : Optional [str ] = None ,
339+ name_set_by_user : bool = False ,
326340 position : Optional [int ] = None ,
327341 prefix : Optional [str ] = None ,
328342 encoding_format : Optional [List [str ]] = None ,
@@ -336,6 +350,7 @@ def __init__(
336350 description = description ,
337351 id = id ,
338352 name = name ,
353+ name_set_by_user = name_set_by_user ,
339354 position = position ,
340355 prefix = prefix ,
341356 derived_from = derived_from ,
@@ -381,7 +396,8 @@ def is_equal_to(self, other) -> bool:
381396 @staticmethod
382397 def _get_equality_attributes () -> List [str ]:
383398 """Return a list of attributes values that determine if instances are equal."""
384- return CommandParameterBase ._get_equality_attributes () + ["encoding_format" , "create_folder" ]
399+ # NOTE: Don't include ``create_folder`` in comparison since its value is state-dependent
400+ return CommandParameterBase ._get_equality_attributes () + ["encoding_format" ]
385401
386402 def derive (self , plan_id : str ) -> "CommandOutput" :
387403 """Create a new ``CommandOutput`` that is derived from self."""
@@ -400,10 +416,18 @@ def __init__(
400416 description : Optional [str ] = None ,
401417 id : str ,
402418 name : Optional [str ] = None ,
419+ name_set_by_user : bool = False ,
403420 mapped_parameters : List [CommandParameterBase ],
404421 ** kwargs ,
405422 ):
406- super ().__init__ (default_value = default_value , description = description , id = id , name = name , ** kwargs )
423+ super ().__init__ (
424+ default_value = default_value ,
425+ description = description ,
426+ id = id ,
427+ name = name ,
428+ name_set_by_user = name_set_by_user ,
429+ ** kwargs ,
430+ )
407431
408432 self .mapped_parameters : List [CommandParameterBase ] = mapped_parameters
409433
0 commit comments