From 1523aa786ba053c076c0ba0abd76e688031f7472 Mon Sep 17 00:00:00 2001 From: Julian Rodrigo Berlin Date: Tue, 5 Jul 2022 17:22:17 +0200 Subject: [PATCH 1/3] add change to get_tree_structured_from_previous_run and get_tree_structured and get_tree_structured to sort alphabetically using refKey field --- autosubmit_api/autosubmit_legacy/job/job_list.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/autosubmit_api/autosubmit_legacy/job/job_list.py b/autosubmit_api/autosubmit_legacy/job/job_list.py index 9a7770bc..176efb9b 100644 --- a/autosubmit_api/autosubmit_legacy/job/job_list.py +++ b/autosubmit_api/autosubmit_legacy/job/job_list.py @@ -1685,6 +1685,7 @@ class JobList: failed_tag = " " + \ str(failed) + " FAILED" # Wrapper group + # todo: apply sort here result_exp.append({'title': 'Wrapper: ' + str(package) + completed_tag + (failed_tag if failed > 0 else '') + (running_tag if running > 0 else '') + (queueing_tag if queueing > 0 else '') + (check_mark if completed == len(jobs_in_package) else ''), 'folder': True, 'refKey': 'Wrapper: ' + str(package), @@ -1763,7 +1764,8 @@ class JobList: 'rm_id': job.job_id, 'status_color': Monitor.color_status(Status.STRING_TO_CODE[job.status])}) - return result_exp, nodes, result_header + return result_exp.sort(key=lambda x: x.refKey), nodes, result_header + def get_tree_structured(self, BasicConfig, chunk_unit=None, chunk_size=1): """ @@ -2226,7 +2228,7 @@ class JobList: 'rm_id': job.id if job.id and job.id > 0 else None, 'status_color': Monitor.color_status(job.status)}) - return result_exp, nodes, result_header + return result_exp.sort(key=lambda x: x.refKey), nodes, result_header @staticmethod def date_plus(date, chunk_unit, chunk, chunk_size=1): -- GitLab From b060480f68e4f55556137b9c628e806c9335f503 Mon Sep 17 00:00:00 2001 From: jberlin Date: Mon, 11 Jul 2022 13:08:20 +0200 Subject: [PATCH 2/3] fix for group ordering of the package folders of the three so wrappers folders are sorted - #803 --- autosubmit_api/autosubmit_legacy/job/job_list.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/autosubmit_api/autosubmit_legacy/job/job_list.py b/autosubmit_api/autosubmit_legacy/job/job_list.py index 176efb9b..4cf90b11 100644 --- a/autosubmit_api/autosubmit_legacy/job/job_list.py +++ b/autosubmit_api/autosubmit_legacy/job/job_list.py @@ -1764,7 +1764,8 @@ class JobList: 'rm_id': job.job_id, 'status_color': Monitor.color_status(Status.STRING_TO_CODE[job.status])}) - return result_exp.sort(key=lambda x: x.refKey), nodes, result_header + result_exp.sort(key=lambda x: x["refKey"]) + return result_exp, nodes, result_header def get_tree_structured(self, BasicConfig, chunk_unit=None, chunk_size=1): @@ -2228,7 +2229,8 @@ class JobList: 'rm_id': job.id if job.id and job.id > 0 else None, 'status_color': Monitor.color_status(job.status)}) - return result_exp.sort(key=lambda x: x.refKey), nodes, result_header + result_exp.sort(key=lambda x: x["refKey"]) + return result_exp, nodes, result_header @staticmethod def date_plus(date, chunk_unit, chunk, chunk_size=1): -- GitLab From 24de501140ad34794a540e19481faf6ac54f9b84 Mon Sep 17 00:00:00 2001 From: Julian Rodrigo Berlin Date: Thu, 14 Jul 2022 13:26:31 +0200 Subject: [PATCH 3/3] Fixed issue with the sorting of the wrappers, by sorting only the wrappers elements instead of the whole tree and also sorting it by title --- .../autosubmit_legacy/job/job_list.py | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/autosubmit_api/autosubmit_legacy/job/job_list.py b/autosubmit_api/autosubmit_legacy/job/job_list.py index 4cf90b11..a1f0476f 100644 --- a/autosubmit_api/autosubmit_legacy/job/job_list.py +++ b/autosubmit_api/autosubmit_legacy/job/job_list.py @@ -1404,6 +1404,7 @@ class JobList: date_member_groups = {} result_header = {} result_exp = [] + result_exp_wrappers = [] sync_jobs = [] # members (sections in database) members = {job.section for job in job_list if len(job.section) > 0} @@ -1686,7 +1687,9 @@ class JobList: str(failed) + " FAILED" # Wrapper group # todo: apply sort here - result_exp.append({'title': 'Wrapper: ' + str(package) + completed_tag + (failed_tag if failed > 0 else '') + (running_tag if running > 0 else '') + (queueing_tag if queueing > 0 else '') + (check_mark if completed == len(jobs_in_package) else ''), + # create an auxiliary list to sort + + result_exp_wrappers.append({'title': 'Wrapper: ' + str(package) + completed_tag + (failed_tag if failed > 0 else '') + (running_tag if running > 0 else '') + (queueing_tag if queueing > 0 else '') + (check_mark if completed == len(jobs_in_package) else ''), 'folder': True, 'refKey': 'Wrapper: ' + str(package), 'data': {'completed': completed, 'failed': failed, 'running': running, 'queuing': queueing, 'total': len(jobs_in_package)}, @@ -1764,7 +1767,11 @@ class JobList: 'rm_id': job.job_id, 'status_color': Monitor.color_status(Status.STRING_TO_CODE[job.status])}) - result_exp.sort(key=lambda x: x["refKey"]) + + result_exp_wrappers.sort(key=lambda x: x["title"]) + for wrapper_job in result_exp_wrappers: + result_exp.append(wrapper_job) + return result_exp, nodes, result_header @@ -1791,6 +1798,7 @@ class JobList: job_name_to_job_title = {} sync_jobs = [] result_exp = [] + result_exp_wrappers = [] result_header = {} job_dictionary = {} year_per_sim = datechunk_to_year(chunk_unit, chunk_size) @@ -2133,7 +2141,7 @@ class JobList: failed_tag = " " + \ str(failed) + " FAILED" # Wrapper group - result_exp.append({'title': 'Wrapper: ' + str(package) + completed_tag + (failed_tag if failed > 0 else '') + (running_tag if running > 0 else '') + (queueing_tag if queueing > 0 else '') + (check_mark if completed == len(jobs_in_package) else ''), + result_exp_wrappers.append({'title': 'Wrapper: ' + str(package) + completed_tag + (failed_tag if failed > 0 else '') + (running_tag if running > 0 else '') + (queueing_tag if queueing > 0 else '') + (check_mark if completed == len(jobs_in_package) else ''), 'folder': True, 'refKey': 'Wrapper: ' + str(package), 'data': {'completed': completed, 'failed': failed, 'running': running, 'queuing': queueing, 'total': len(jobs_in_package)}, @@ -2229,7 +2237,11 @@ class JobList: 'rm_id': job.id if job.id and job.id > 0 else None, 'status_color': Monitor.color_status(job.status)}) - result_exp.sort(key=lambda x: x["refKey"]) + # sort and add these sorted elements to the result list + result_exp_wrappers.sort(key=lambda x: x["title"]) + for wrapper_job in result_exp_wrappers: + result_exp.append(wrapper_job) + return result_exp, nodes, result_header @staticmethod -- GitLab