Skip to content

Commit

Permalink
Updates to Antonio’s coments
Browse files Browse the repository at this point in the history
  • Loading branch information
Gossty committed Aug 30, 2024
1 parent 437b8c8 commit 4fa0c70
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
17 changes: 8 additions & 9 deletions qiita_db/meta_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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):
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions qiita_db/test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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'])
Expand Down
2 changes: 1 addition & 1 deletion qiita_db/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4fa0c70

Please sign in to comment.