Open superstar54 opened 3 months ago
When passing parameters to the decorator, we define some nonlocal variables, this make the codes not clean. e.g., task_type.
task_type
class TaskDecoratorCollection: """Collection of task decorators.""" # decorator with arguments indentifier, args, kwargs, properties, inputs, outputs, executor @staticmethod @nonfunctional_usage def decorator_task( identifier: Optional[str] = None, task_type: str = "Normal", properties: Optional[List[Tuple[str, str]]] = None, inputs: Optional[List[Tuple[str, str]]] = None, outputs: Optional[List[Tuple[str, str]]] = None, catalog: str = "Others", ) -> Callable: """Generate a decorator that register a function as a task. Attributes: indentifier (str): task identifier catalog (str): task catalog args (list): task args kwargs (dict): task kwargs properties (list): task properties inputs (list): task inputs outputs (list): task outputs """ def decorator(func): nonlocal identifier, task_type if identifier is None: identifier = func.__name__ # Determine task_type based on AiiDA's node classes task_type = task_type if hasattr(func, "node_class"): task_type = task_types.get(func.node_class, task_type)```
use another name.
When passing parameters to the decorator, we define some nonlocal variables, this make the codes not clean. e.g.,
task_type
.Simple solution
use another name.