From 4fa0c706c00255053281b7fac28155962f5b80e3 Mon Sep 17 00:00:00 2001 From: gossty Date: Fri, 30 Aug 2024 12:34:00 -0700 Subject: [PATCH] =?UTF-8?q?Updates=20to=20Antonio=E2=80=99s=20coments?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- qiita_db/meta_util.py | 17 ++++++++--------- qiita_db/test/test_util.py | 4 ++-- qiita_db/util.py | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/qiita_db/meta_util.py b/qiita_db/meta_util.py index 71a8df353..c36e8764a 100644 --- a/qiita_db/meta_util.py +++ b/qiita_db/meta_util.py @@ -37,14 +37,14 @@ from re import sub from json import loads, dump, dumps -from qiita_db.util import create_nested_path, _retrieve_resource_data +from qiita_db.util import create_nested_path, retrieve_resource_data from qiita_db.util import resource_allocation_plot from qiita_core.qiita_settings import qiita_config, r_client from qiita_core.configuration_manager import ConfigurationManager import qiita_db as qdb # global constant list used in resource_allocation_page -columns = [ +COLUMNS = [ "sName", "sVersion", "cID", "cName", "processing_job_id", "parameters", "samples", "columns", "input_size", "extra_info", "MaxRSSRaw", "ElapsedRaw", "Start", "node_name", "node_model"] @@ -557,18 +557,17 @@ def generate_plugin_releases(): def get_software_commands(active): software_list = [s for s in qdb.software.Software.iter(active=active)] - software_commands = dict() + software_commands = defaultdict(lambda: defaultdict(list)) + for software in software_list: sname = software.name sversion = software.version commands = software.commands - if sname not in software_commands: - software_commands[sname] = {} - if sversion not in software_commands[sname]: - software_commands[sname][sversion] = [] + for command in commands: software_commands[sname][sversion].append(command.name) - return software_commands + + return dict(software_commands) def update_resource_allocation_redis(active=True): @@ -590,7 +589,7 @@ def update_resource_allocation_redis(active=True): for cname in commands: col_name = "samples * columns" - df = _retrieve_resource_data(cname, sname, version, columns) + df = retrieve_resource_data(cname, sname, version, COLUMNS) if len(df) == 0: continue diff --git a/qiita_db/test/test_util.py b/qiita_db/test/test_util.py index a71be3e49..cad800752 100644 --- a/qiita_db/test/test_util.py +++ b/qiita_db/test/test_util.py @@ -1322,7 +1322,7 @@ def setUp(self): # df is a dataframe that represents a table with columns specified in # self.columns - self.df = qdb.util._retrieve_resource_data( + self.df = qdb.util.retrieve_resource_data( self.cname, self.sname, self.version, self.columns) def test_plot_return(self): @@ -1423,7 +1423,7 @@ def test_db_update(self): qdb.util.update_resource_allocation_table(test=test_data) for curr_cname, ids in types.items(): - updated_df = qdb.util._retrieve_resource_data( + updated_df = qdb.util.retrieve_resource_data( curr_cname, self.sname, self.version, self.columns) updated_ids_set = set(updated_df['processing_job_id']) previous_ids_set = set(self.df['processing_job_id']) diff --git a/qiita_db/util.py b/qiita_db/util.py index 1007298e5..35a25cee9 100644 --- a/qiita_db/util.py +++ b/qiita_db/util.py @@ -2402,7 +2402,7 @@ def resource_allocation_plot(df, cname, sname, col_name): return fig, axs -def _retrieve_resource_data(cname, sname, version, columns): +def retrieve_resource_data(cname, sname, version, columns): with qdb.sql_connection.TRN: sql = """ SELECT