diff --git a/inference/core/workflows/core_steps/common/query_language/operations/core.py b/inference/core/workflows/core_steps/common/query_language/operations/core.py index 1404ff68b3..69f98ef652 100644 --- a/inference/core/workflows/core_steps/common/query_language/operations/core.py +++ b/inference/core/workflows/core_steps/common/query_language/operations/core.py @@ -93,16 +93,15 @@ def identity(value: Any, **kwargs) -> Any: def build_operations_chain( operations: List[OperationDefinition], execution_context: str = "" ) -> Callable[[T, Dict[str, Any]], V]: - if not len(operations): + if not operations: return identity # return identity function - operations_functions = [] - for operation_id, operation_definition in enumerate(operations): - operation_context = f"{execution_context}[{operation_id}]" - operation_function = build_operation( + operations_functions = [ + build_operation( operation_definition=operation_definition, - execution_context=operation_context, + execution_context=f"{execution_context}[{operation_id}]", ) - operations_functions.append(operation_function) + for operation_id, operation_definition in enumerate(operations) + ] return partial(chain, functions=operations_functions)