From 2d3b945709c266694978ae4d9edbf21c561ffb3a Mon Sep 17 00:00:00 2001 From: Wilmer Uruchi Ticona Date: Mon, 2 Dec 2019 09:36:12 +0100 Subject: [PATCH] =?UTF-8?q?Fixed=20#444.=20There=20was=20an=20uncontrolled?= =?UTF-8?q?=20recursion=20call=20in=20the=20new=20implementation=20of=20th?= =?UTF-8?q?e=20text=20file=20generator=20that=20made=20the=20function=20ru?= =?UTF-8?q?n=20out=20of=20memory=20in=20some=20specific=20experiment=20str?= =?UTF-8?q?uctures,=20high=20out=20degree=20and=20in=20degree=C2=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autosubmit/job/job_list.py | 61 ++++++++++++++++++----------------- autosubmit/monitor/monitor.py | 3 +- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/autosubmit/job/job_list.py b/autosubmit/job/job_list.py index e9ceca8df..4cf0b7aaf 100644 --- a/autosubmit/job/job_list.py +++ b/autosubmit/job/job_list.py @@ -1134,10 +1134,11 @@ class JobList: for job in allJobs: if job.has_parents() == False: root = job - + visited = list() + print(root) # root exists if root is not None: - result += self._recursion_print(root, 0, statusChange = statusChange, nocolor = nocolor) + result += self._recursion_print(root, 0, visited, statusChange = statusChange, nocolor = nocolor) else: result += "\nCannot find root." @@ -1168,7 +1169,7 @@ class JobList: return result - def _recursion_print(self, job, level, statusChange = None, nocolor = False): + def _recursion_print(self, job, level, visited, statusChange = None, nocolor = False): """ Returns the list of children in a recursive way Traverses the dependency tree @@ -1177,31 +1178,33 @@ class JobList: :rtype: String """ result = "" - prefix = "" - for i in range(level): - prefix += "| " - # Prefix + Job Name - result = "\n"+ prefix + \ - (bcolors.BOLD + bcolors.CODE_TO_COLOR[job.status] if nocolor == False else '') + \ - job.name + \ - (bcolors.ENDC + bcolors.ENDC if nocolor == False else '') - if len(job._children) > 0: - level += 1 - children = job._children - total_children = len(job._children) - # Writes children number and status if color are not being showed - result += " ~ [" + str(total_children) + (" children] " if total_children > 1 else " child] ") + \ - ("[" +Status.VALUE_TO_KEY[job.status] + "] " if nocolor == True else "") - if statusChange is not None: - # Writes change if performed - result += (bcolors.BOLD + bcolors.OKGREEN if nocolor == False else '') - result += (statusChange[job.name] if job.name in statusChange else "") - result += (bcolors.ENDC + bcolors.ENDC if nocolor == False else "") - - for child in children: - # Continues recursion - result += self._recursion_print(child, level, statusChange=statusChange, nocolor = nocolor) - else: - result += (" [" + Status.VALUE_TO_KEY[job.status] + "] " if nocolor == True else "") + if job.name not in visited: + visited.append(job.name) + prefix = "" + for i in range(level): + prefix += "| " + # Prefix + Job Name + result = "\n"+ prefix + \ + (bcolors.BOLD + bcolors.CODE_TO_COLOR[job.status] if nocolor == False else '') + \ + job.name + \ + (bcolors.ENDC + bcolors.ENDC if nocolor == False else '') + if len(job._children) > 0: + level += 1 + children = job._children + total_children = len(job._children) + # Writes children number and status if color are not being showed + result += " ~ [" + str(total_children) + (" children] " if total_children > 1 else " child] ") + \ + ("[" +Status.VALUE_TO_KEY[job.status] + "] " if nocolor == True else "") + if statusChange is not None: + # Writes change if performed + result += (bcolors.BOLD + bcolors.OKGREEN if nocolor == False else '') + result += (statusChange[job.name] if job.name in statusChange else "") + result += (bcolors.ENDC + bcolors.ENDC if nocolor == False else "") + + for child in children: + # Continues recursion + result += self._recursion_print(child, level, visited, statusChange=statusChange, nocolor = nocolor) + else: + result += (" [" + Status.VALUE_TO_KEY[job.status] + "] " if nocolor == True else "") return result \ No newline at end of file diff --git a/autosubmit/monitor/monitor.py b/autosubmit/monitor/monitor.py index eec9a3652..5d45d306c 100644 --- a/autosubmit/monitor/monitor.py +++ b/autosubmit/monitor/monitor.py @@ -332,7 +332,8 @@ class Monitor: # Replaced call to function for a call to the function of the object that # was previously implemented, nocolor is set to True because we don't want # strange ANSI codes in our plain text file - if job_list_object is not None: + if job_list_object is not None: + print("In the new thingy") output_file.write(job_list_object.print_with_status(statusChange = None, nocolor=True, existingList=joblist)) else: output_file.write("Writing jobs, they're grouped by [FC and DATE] \n") -- GitLab