Skip to content

Commit 208a7f1

Browse files
Merge pull request #3220 from antgonza/updates-after-deploy-2022.11
Updates after deploy 2022.11
2 parents c169c6b + 8e81593 commit 208a7f1

File tree

12 files changed

+89
-15
lines changed

12 files changed

+89
-15
lines changed

qiita_core/util.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
from qiita_db.environment_manager import reset_test_database
1717

1818

19+
REDIS_QIITA_GIT_SHA_KEY = 'qiita-git-sha'
20+
21+
1922
def is_test_environment():
2023
"""Checks if Qiita is running in a test environment
2124
@@ -81,24 +84,33 @@ def wrapper(*args, **kwargs):
8184
return wrapper
8285

8386

84-
def get_qiita_version():
85-
"""Returns the Qiita version and Git sha if present
86-
87-
Returns
88-
------
89-
tuple (version, sha)
90-
The Qiita version and SHA. SHA can be an empty string.
91-
"""
87+
def update_redis_qiita_sha_version():
9288
# the actual repo is the abspath of the current file without
9389
# qiita_core
9490
git_repo_path = dirname(dirname(__file__))
9591

9692
try:
9793
repo = Repo(git_repo_path)
9894
sha = repo.active_branch.commit.hexsha
95+
repo.__del__()
9996
except (InvalidGitRepositoryError, TypeError):
10097
sha = ''
10198

99+
r_client.set(REDIS_QIITA_GIT_SHA_KEY, sha)
100+
101+
102+
def get_qiita_version():
103+
"""Returns the Qiita version and Git sha if present
104+
105+
Returns
106+
------
107+
tuple (version, sha)
108+
The Qiita version and SHA. SHA can be an empty string.
109+
"""
110+
sha = r_client.get(REDIS_QIITA_GIT_SHA_KEY)
111+
if sha is None:
112+
sha = ''
113+
102114
return (qiita_pet_lib_version, sha)
103115

104116

qiita_db/analysis.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,22 @@ class Analysis(qdb.base.QiitaObject):
6969
_portal_table = "analysis_portal"
7070
_analysis_id_column = 'analysis_id'
7171

72+
@classmethod
73+
def iter(cls):
74+
"""Iter over the analyses"""
75+
with qdb.sql_connection.TRN:
76+
sql = """SELECT DISTINCT analysis_id
77+
FROM qiita.analysis
78+
JOIN qiita.analysis_portal USING (analysis_id)
79+
JOIN qiita.portal_type USING (portal_type_id)
80+
WHERE portal = %s
81+
ORDER BY analysis_id"""
82+
qdb.sql_connection.TRN.add(sql, [qiita_config.portal])
83+
aids = qdb.sql_connection.TRN.execute_fetchflatten()
84+
85+
for aid in aids:
86+
yield cls(aid)
87+
7288
@classmethod
7389
def get_by_status(cls, status):
7490
"""Returns all Analyses with given status

qiita_db/metadata_template/base_metadata_template.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ def _helper_get_categories(table):
6363
WHERE sample_id = '{1}'""".format(table, QIITA_COLUMN_NAME)
6464
qdb.sql_connection.TRN.add(sql)
6565
results = qdb.sql_connection.TRN.execute_fetchflatten()
66-
if results:
66+
if results and results != [None]:
6767
results = sorted(loads(results[0]))
68+
else:
69+
results = []
6870
return results
6971

7072

@@ -1179,7 +1181,7 @@ def _common_to_dataframe_steps(self, samples=None):
11791181
data = qdb.sql_connection.TRN.execute_fetchindex()
11801182
df = pd.DataFrame([d for _, d in data], index=[i for i, _ in data],
11811183
dtype=str)
1182-
df.index.name = 'sample_id'
1184+
df.index.name = 'sample_name'
11831185
df.where((pd.notnull(df)), None)
11841186
id_column_name = 'qiita_%sid' % (self._table_prefix)
11851187
if id_column_name == 'qiita_sample_id':

qiita_db/metadata_template/test/test_sample_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1940,7 +1940,7 @@ def test_to_dataframe(self):
19401940
'scientific_name': 'homo sapiens'},
19411941
}
19421942
exp = pd.DataFrame.from_dict(exp_dict, orient='index', dtype=str)
1943-
exp.index.name = 'sample_id'
1943+
exp.index.name = 'sample_name'
19441944
obs.sort_index(axis=0, inplace=True)
19451945
obs.sort_index(axis=1, inplace=True)
19461946
exp.sort_index(axis=0, inplace=True)

qiita_db/sql_connection.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,10 @@ def _raise_execution_error(self, sql, sql_args, error):
198198
ec_lu = errorcodes.lookup(error.pgcode)
199199
raise ValueError(
200200
"Error running SQL: %s. MSG: %s\n" % (ec_lu, str(error)))
201-
except (KeyError, AttributeError, TypeError):
201+
# the order of except statements is important, do not change
202+
except (KeyError, AttributeError, TypeError) as error:
203+
raise ValueError("Error running SQL query: %s" % str(error))
204+
except ValueError as error:
202205
raise ValueError("Error running SQL query: %s" % str(error))
203206

204207
@_checker

qiita_db/test/test_analysis.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@
2222
# -----------------------------------------------------------------------------
2323

2424

25+
class TestAnalysisIter(TestCase):
26+
def test_iter(self):
27+
obs = list(qdb.analysis.Analysis.iter())
28+
exp = [
29+
qdb.analysis.Analysis(1), qdb.analysis.Analysis(2),
30+
qdb.analysis.Analysis(3), qdb.analysis.Analysis(4),
31+
qdb.analysis.Analysis(5), qdb.analysis.Analysis(6)]
32+
self.assertCountEqual(obs, exp)
33+
34+
2535
@qiita_test_checker()
2636
class TestAnalysis(TestCase):
2737
def setUp(self):

qiita_pet/handlers/admin_processing_job.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
class AdminProcessingJobBaseClass(BaseHandler):
2222
def _check_access(self):
23-
if self.current_user.level not in {'admin', 'wet-lab admin'}:
23+
if self.current_user is None or self.current_user.level not in {
24+
'admin', 'wet-lab admin'}:
2425
raise HTTPError(403, reason="User %s doesn't have sufficient "
2526
"privileges to view error page" %
2627
self.current_user.email)

qiita_pet/support_files/doc/source/processingdata/processing-recommendations.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,33 @@ Reference databases
127127

128128
Note that some of these are legacy option but not available for new processing.
129129

130+
131+
132+
#. WoLr2 (“Web of Life” release 2): A significant upgrade from WoLr1. The genome
133+
pool is an even representation of microbial diversity, sampled from
134+
non-redundant bacterial and archaeal genomes from NCBI (RefSeq and GenBank,
135+
complete and draft). A high-quality reference phylogeny was reconstructed
136+
using the uDance workflow (manuscript in submission). Taxonomic
137+
classifications were curated according to phylogeny based on GTDB (default)
138+
and NCBI. Functional annotations were performed using EggNOG, GO, KEGG,
139+
MetaCyc, Pfam and UniRef.
140+
141+
- Domains: Bacteria, Archaea
142+
- Number of genomes: 15,953
143+
- Total length (bp): 48,809,171,826
144+
- Citation: Zhu Q, Mai U, Pfeiffer W, et al. Phylogenomics of 10,575 genomes
145+
reveals evolutionary proximity between domains Bacteria and Archaea. Nat
146+
Commun. 2019. 10(1):5477. doi: 10.1038/s41467-019-13443-4.
147+
- Numbers of taxonomic units:
148+
149+
- Domains: 2
150+
- Phyla: 124
151+
- Classes: 321
152+
- Orders: 914
153+
- Families: 2,057
154+
- Genera: 6,811
155+
- Species: 12,258
156+
130157
#. WoLr1 ("Web of Life" release 1): An even representation of microbial diversity, selected using an prototype
131158
selection algorithm based on the MinHash distance matrix among all non-redundant bacterial and archaeal genomes
132159
from NCBI (RefSeq and GenBank, complete and draft), plus several genome quality control criteria. A

qiita_pet/templates/study_ajax/sample_prep_summary.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
var prep_names = {% raw columns %};
6464

6565
// adding header
66-
var header = ['sample_id']
66+
var header = ['sample_name']
6767
$.each(prep_colums, function(i, prep){
6868
header.push(prep_names[prep]);
6969
});

qiita_pet/test/rest/test_study_preparation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_post_valid_study(self):
5656
exp = json_decode(response.body)
5757
exp_prep = PrepTemplate(exp['id']).to_dataframe()
5858

59-
prep_table.index.name = 'sample_id'
59+
prep_table.index.name = 'sample_name'
6060

6161
# sort columns to be comparable
6262
prep_table = prep_table[sorted(prep_table.columns.tolist())]

0 commit comments

Comments
 (0)