diff --git a/src/call.py b/src/call.py index be9135cf4a6b8b7a158b0e67841dbbe6b3c67ece..1f8bd77478bbd6a0aaf1559bd3eb1cff2e7a7de8 100644 --- a/src/call.py +++ b/src/call.py @@ -209,10 +209,14 @@ class Call(Executor): #Step 1 -> get parameters tab_params, start, next_param = [], 0, None temp_param = param - while(start!=-1): + timeout = 0 + while(start!=-1 and timeout<constant.WHILE_UPPER_BOUND): temp_param = temp_param[start:] next_param, start = get_next_param(temp_param) tab_params.append(next_param.strip()) + timeout+=1 + if(timeout>=constant.WHILE_UPPER_BOUND): + raise BioFlowInsightError(f"The WHILE_UPPER_BOUND was exceeded. BioFlow-Insight was unable to extract the parameters for the call '{self.get_code(get_OG=True)}'. Make sure the workflow uses correct Nextflow syntaxe (https://www.nextflow.io/docs/latest/index.html).", type="Unable to extract call parameters") #Step 2 -> analyse paramters for param in tab_params: diff --git a/src/code_.py b/src/code_.py index 6a44399192d426873fe4334c03ef1e0a356ccfbb..5c315b9e1cd84ae101304b52aa41202f53052754 100644 --- a/src/code_.py +++ b/src/code_.py @@ -45,8 +45,8 @@ class Code: quote_single, quote_double = False, False triple_single, triple_double = False, False - - while(start<len(code)): + timeout = 0 + while(start<len(code) and timeout<constant.WHILE_UPPER_BOUND): checked_triple = False if(start+3<=len(code)): if(code[start:start+3]=="'''" and not quote_single and not quote_double and not triple_single and not triple_double): @@ -116,6 +116,9 @@ class Code: start+=1 + timeout+=1 + if(timeout>=constant.WHILE_UPPER_BOUND): + raise BioFlowInsightError(f"The WHILE_UPPER_BOUND was exceeded. BioFlow-Insight was unable to turn a single line condition into a multi line condition. Make sure the workflow uses correct Nextflow syntaxe (https://www.nextflow.io/docs/latest/index.html).", type="Unable to turn single line condition into multi line") @@ -128,7 +131,8 @@ class Code: def remove_things_inside_map(self, code): index = 0 searching = True - while(searching): + timeout = 0 + while(searching and timeout<constant.WHILE_UPPER_BOUND): searching = False #TODO -> do the same with flatMap -> 668 for word in ["map", "flatMap"]: @@ -153,6 +157,10 @@ class Code: searching = True index+=1 break + timeout+=1 + if(timeout>=constant.WHILE_UPPER_BOUND): + raise BioFlowInsightError(f"The WHILE_UPPER_BOUND was exceeded. BioFlow-Insight was unable to extract the inside of a 'map' operator. Make sure the workflow uses correct Nextflow syntaxe (https://www.nextflow.io/docs/latest/index.html).", type="Unable to extract the inside of a 'map' operator") + return code diff --git a/src/outils.py b/src/outils.py index c941f7183023ec656ee3070c8eb508099624b5ac..83b420f68c8f09e53117fd22aa7c26612250c7a5 100644 --- a/src/outils.py +++ b/src/outils.py @@ -1,7 +1,7 @@ import re import subprocess import os -from .constant import WHILE_UPPER_BOUND +from . import constant from .bioflowinsighterror import BioFlowInsightError @@ -936,7 +936,7 @@ def extract_conditions(code, only_get_inside = True): timeout = 0 - while(start<len(code) and timeout < WHILE_UPPER_BOUND): + while(start<len(code) and timeout < constant.WHILE_UPPER_BOUND): checked_triple = False if(start+3<=len(code)): if(code[start:start+3]=="'''" and not quote_single and not quote_double and not triple_single and not triple_double): @@ -1061,7 +1061,7 @@ def extract_conditions(code, only_get_inside = True): start+=1 timeout+=1 - if(timeout>=WHILE_UPPER_BOUND): + if(timeout>=constant.WHILE_UPPER_BOUND): raise BioFlowInsightError("The WHILE_UPPER_BOUND was exceeded. BioFlow-Insight was unable to extarct the conditions. Make sure the workflow uses correct Nextflow syntaxe (https://www.nextflow.io/docs/latest/index.html).", type="Unable to extract conditions") for c in conditions_dico: start, end = conditions_dico[c]