Skip to content

Commit 437b8c8

Browse files
committed
Minor changes
1 parent 7241754 commit 437b8c8

File tree

4 files changed

+17
-22
lines changed

4 files changed

+17
-22
lines changed

qiita_db/meta_util.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,8 @@ def generate_plugin_releases():
555555
f(redis_key, v)
556556

557557

558-
def get_software_commands():
559-
# TODO change active=False to True. In test, the data is active=False.
560-
software_list = [s for s in qdb.software.Software.iter(active=False)]
558+
def get_software_commands(active):
559+
software_list = [s for s in qdb.software.Software.iter(active=active)]
561560
software_commands = dict()
562561
for software in software_list:
563562
sname = software.name
@@ -572,21 +571,27 @@ def get_software_commands():
572571
return software_commands
573572

574573

575-
def update_resource_allocation_redis():
574+
def update_resource_allocation_redis(active=True):
575+
"""Updates redis with plots and information about current software.
576+
577+
Parameters
578+
----------
579+
active: boolean, optional
580+
Defaults to True. Should only be False when testing.
581+
582+
"""
576583
time = datetime.now().strftime('%m-%d-%y')
577-
scommands = get_software_commands()
584+
scommands = get_software_commands(active)
578585
redis_key = 'resources:commands'
579586
r_client.set(redis_key, str(scommands))
580587

581588
for sname, versions in scommands.items():
582589
for version, commands in versions.items():
583590
for cname in commands:
584591

585-
print("Generating plot for:", sname, version, cname)
586592
col_name = "samples * columns"
587593
df = _retrieve_resource_data(cname, sname, version, columns)
588594
if len(df) == 0:
589-
print("No available data for", sname, version, cname)
590595
continue
591596

592597
fig, axs = resource_allocation_plot(df, cname, sname, col_name)
@@ -641,7 +646,6 @@ def update_resource_allocation_redis():
641646
("title_mem", titles[0], r_client.set),
642647
("title_time", titles[1], r_client.set)
643648
]
644-
print(time, titles[0], titles[1])
645649

646650
for k, v, f in values:
647651
redis_key = 'resources$#%s$#%s$#%s$#%s:%s' % (

qiita_db/test/test_meta_util.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from os.path import exists, join
1414

1515
import pandas as pd
16-
from datetime import datetime
1716

1817
from qiita_core.qiita_settings import qiita_config, r_client
1918
from qiita_core.util import qiita_test_checker
@@ -525,28 +524,21 @@ def test_update_resource_allocation_redis(self):
525524
sname = "QIIMEq2"
526525
col_name = "samples * columns"
527526
version = "1.9.1"
528-
qdb.meta_util.update_resource_allocation_redis()
529-
# since time is month, day, year, it should be equal unless test is ran
530-
# at midnight.
531-
time = datetime.now().strftime('%m-%d-%y')
527+
qdb.meta_util.update_resource_allocation_redis(False)
532528
title_mem_str = 'resources$#%s$#%s$#%s$#%s:%s' % (
533529
cname, sname, version, col_name, 'title_mem')
534530
title_mem = str(r_client.get(title_mem_str))
535531
self.assertTrue(
536-
"model_chosen: "
532+
"model: "
537533
"k * log(x) + "
538534
"b * log(x)^2 + "
539-
"a * log(x)^2.5" in title_mem
535+
"a * log(x)^3" in title_mem
540536
)
541537

542538
title_time_str = 'resources$#%s$#%s$#%s$#%s:%s' % (
543539
cname, sname, version, col_name, 'title_time')
544540
title_time = str(r_client.get(title_time_str))
545-
self.assertTrue("model_chosen: a + b + log(x) * k" in title_time)
546-
time_create_str = 'resources$#%s$#%s$#%s$#%s:%s' % (
547-
cname, sname, version, col_name, 'time')
548-
time_create = str(r_client.get(time_create_str))
549-
self.assertTrue(time in time_create)
541+
self.assertTrue("model: a + b + log(x) * k" in title_time)
550542

551543

552544
if __name__ == '__main__':

qiita_db/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2527,7 +2527,7 @@ def _resource_allocation_plot_helper(
25272527

25282528
ax.set_title(
25292529
f'k||a||b: {k}||{a}||{b}\n'
2530-
f'model_chosen: {get_model_name(best_model)}\n'
2530+
f'model: {get_model_name(best_model)}\n'
25312531
f'real: {mini} || {maxi}\n'
25322532
f'calculated: {cmin} || {cmax}\n'
25332533
f'failures: {failures}')

qiita_pet/templates/sitebase.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@
384384
<li><a href="{% raw qiita_config.portal_dir %}/admin/approval/">View Studies awaiting approval</a></li>
385385
<li><a href="{% raw qiita_config.portal_dir %}/admin/portals/studies/">Edit study portal connections</a></li>
386386
<li><a href="{% raw qiita_config.portal_dir %}/admin/purge_users/">Purge non-validated users</a></li>
387-
<li><a href="{% raw qiita_config.portal_dir %}/admin/resources/">View Resource Allocation Plots</a></li>
388387
{% end %}
389388
<li><a href="{% raw qiita_config.portal_dir %}/admin/sample_validation/">Sample Validation</a></li>
390389
<li><a href="{% raw qiita_config.portal_dir %}/admin/processing_jobs/">Processing Jobs</a></li>

0 commit comments

Comments
 (0)