Skip to content

Commit 22b0f4f

Browse files
authored
Merge pull request #3144 from antgonza/pgsql-13.4
postgres 9.5->13.4
2 parents 331293c + 30b39cb commit 22b0f4f

File tree

10 files changed

+29
-37
lines changed

10 files changed

+29
-37
lines changed

.github/workflows/qiita-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
services:
2020
postgres:
2121
# Docker Hub image
22-
image: postgres:9.5
22+
image: postgres:13.4
2323
env:
2424
POSTGRES_DB: postgres
2525
POSTGRES_USER: postgres

qiita_db/artifact.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def delete(cls, artifact_id):
520520
raise qdb.exceptions.QiitaDBArtifactDeletionError(
521521
artifact_id, "it is public")
522522

523-
all_artifacts = list(instance.descendants.nodes())
523+
all_artifacts = list(set(instance.descendants.nodes()))
524524
all_artifacts.reverse()
525525
all_ids = tuple([a.id for a in all_artifacts])
526526

qiita_db/base.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,14 @@ def __init__(self, id_):
184184

185185
with qdb.sql_connection.TRN:
186186
self._check_subclass()
187-
if not self._check_id(id_):
187+
try:
188+
_id = self._check_id(id_)
189+
except ValueError as error:
190+
if 'INVALID_TEXT_REPRESENTATION' not in str(error):
191+
raise error
192+
_id = False
193+
194+
if not _id:
188195
raise qdb.exceptions.QiitaDBUnknownIDError(id_, self._table)
189196

190197
if not self._check_portal(id_):

qiita_db/metadata_template/base_metadata_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ def _common_extend_steps(self, md_template):
837837

838838
# check that we are within the limit of number of samples
839839
ms = self.max_samples()
840-
nsamples = len(existing_samples) + len(new_samples) + len(self)
840+
nsamples = len(curr_samples) + len(new_samples)
841841
if ms is not None and nsamples > ms:
842842
raise ValueError(f'{nsamples} exceeds the max allowed number '
843843
f'of samples: {ms}')

qiita_db/study.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,8 @@ def prep_templates(self, data_type=None):
11521152
sql = """SELECT prep_template_id
11531153
FROM qiita.study_prep_template
11541154
JOIN qiita.prep_template USING (prep_template_id)
1155-
WHERE study_id = %s{0}""".format(spec_data)
1155+
WHERE study_id = %s{0}
1156+
ORDER BY prep_template_id""".format(spec_data)
11561157
qdb.sql_connection.TRN.add(sql, args)
11571158
return [qdb.metadata_template.prep_template.PrepTemplate(ptid)
11581159
for ptid in qdb.sql_connection.TRN.execute_fetchflatten()]

qiita_db/test/test_study.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ def test_retrieve_artifacts_none(self):
796796
qdb.study.Study.delete(new.id)
797797

798798
def test_retrieve_prep_templates(self):
799-
self.assertEqual(
799+
self.assertCountEqual(
800800
self.study.prep_templates(),
801801
[qdb.metadata_template.prep_template.PrepTemplate(1),
802802
qdb.metadata_template.prep_template.PrepTemplate(2)])

qiita_pet/handlers/admin_processing_job.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def get(self):
6060
continue
6161

6262
for job in cmd.processing_jobs:
63+
if job.hidden:
64+
continue
6365
msg = '' if job.status != 'error' else job.log.msg
6466
msg = msg.replace('\n', '</br>')
6567
outputs = []

qiita_pet/test/rest/test_sample_detail.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_samples_detail(self):
4242
obs = _sample_details(qiita_db.study.Study(1),
4343
['1.SKD7.640191', 'doesnotexist'])
4444
self.assertEqual(len(obs), len(exp))
45-
self.assertEqual(obs, exp)
45+
self.assertCountEqual(obs, exp)
4646

4747

4848
class SampleDetailHandlerTests(RESTHandlerTestCase):
@@ -81,7 +81,7 @@ def test_get_valid_sample(self):
8181
headers=self.headers)
8282
self.assertEqual(response.code, 200)
8383
obs = json_decode(response.body)
84-
self.assertEqual(obs, exp)
84+
self.assertCountEqual(obs, exp)
8585

8686
def test_post_samples_status_bad_request(self):
8787
body = {'malformed': 'with garbage'}
@@ -134,7 +134,7 @@ def test_post_samples_status(self):
134134
data=body, asjson=True)
135135
self.assertEqual(response.code, 200)
136136
obs = json_decode(response.body)
137-
self.assertEqual(obs, exp)
137+
self.assertCountEqual(obs, exp)
138138

139139

140140
if __name__ == '__main__':

qiita_ware/private_plugin.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ def delete_sample_or_column(job):
291291

292292

293293
def _delete_analysis_artifacts(analysis):
294-
aids = [a.id for a in analysis.artifacts]
294+
aids = [a.id for a in analysis.artifacts if not a.parents]
295295
aids.sort(reverse=True)
296296
for aid in aids:
297297
qdb.artifact.Artifact.delete(aid)
@@ -316,11 +316,10 @@ def delete_study(job):
316316
_delete_analysis_artifacts(analysis)
317317

318318
for pt in study.prep_templates():
319-
if pt.artifact:
320-
to_delete = list(pt.artifact.descendants.nodes())
321-
to_delete.reverse()
322-
for td in to_delete:
323-
qdb.artifact.Artifact.delete(td.id)
319+
if pt.artifact is not None:
320+
# Artifact.delete will delete descendants so just delete
321+
# the root
322+
qdb.artifact.Artifact.delete(pt.artifact.id)
324323
MT.prep_template.PrepTemplate.delete(pt.id)
325324

326325
if MT.sample_template.SampleTemplate.exists(study_id):

qiita_ware/test/test_private_plugin.py

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -443,31 +443,10 @@ def test_delete_study(self):
443443
job = self._create_job('delete_study', {'study': 1})
444444
private_task(job.id)
445445
self.assertEqual(job.status, 'error')
446-
self.assertIn("Cannot delete artifact 2: Artifact 2 has been "
447-
"submitted to EBI", job.log.msg)
446+
self.assertIn("Artifact 2 has been submitted to EBI", job.log.msg)
448447
# making sure the analysis, first thing to delete, still exists
449448
self.assertTrue(Analysis.exists(1))
450449

451-
# delete everything from the EBI submissions and the processing job so
452-
# we can try again: test success (with tags)
453-
with TRN:
454-
sql = """DELETE FROM qiita.ebi_run_accession"""
455-
TRN.add(sql)
456-
sql = """DELETE FROM qiita.artifact_processing_job"""
457-
TRN.add(sql)
458-
TRN.execute()
459-
460-
# adding tags
461-
Study(1).update_tags(self.user, ['my new tag!'])
462-
463-
job = self._create_job('delete_study', {'study': 1})
464-
private_task(job.id)
465-
466-
self.assertEqual(job.status, 'success')
467-
with self.assertRaises(QiitaDBUnknownIDError):
468-
Study(1)
469-
470-
def test_delete_study_empty_study(self):
471450
info = {
472451
"timeseries_type_id": '1',
473452
"metadata_complete": 'true',
@@ -481,6 +460,10 @@ def test_delete_study_empty_study(self):
481460
"lab_person_id": StudyPerson(1)}
482461
new_study = Study.create(User('test@foo.bar'),
483462
"Fried Chicken Microbiome %s" % time(), info)
463+
464+
# adding tags
465+
new_study.update_tags(User('test@foo.bar'), ['my new tag!'])
466+
484467
# creating a sample information file
485468
metadata = pd.DataFrame.from_dict({
486469
'Sample1': {'physical_specimen_location': 'location1',

0 commit comments

Comments
 (0)