Skip to content

Commit 735bc39

Browse files
josenavasantgonza
authored andcommitted
Patch 61 - transfer all parameters to str (#2379)
* Patch 61 - transfer all parameters to str * Fixing errors
1 parent 0107f97 commit 735bc39

File tree

8 files changed

+62
-32
lines changed

8 files changed

+62
-32
lines changed

qiita_db/handlers/tests/test_artifact.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ def test_get_artifact(self):
103103
'prep_information': [],
104104
'study': None,
105105
'analysis': 1,
106-
'processing_parameters': {'biom_table': 8, 'depth': 9000,
107-
'subsample_multinomial': False},
106+
'processing_parameters': {'biom_table': '8', 'depth': '9000',
107+
'subsample_multinomial': 'False'},
108108
'files': exp_fps}
109109
obs = loads(obs.body)
110110
# The timestamp is genreated at patch time, so we can't check for it

qiita_db/support_files/patches/61.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- October 30th, 2017
2+
SELECT 42;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# October 30th, 2017
2+
# A change introduced in July made all the parameters to be stored as strings
3+
# The DB needs to be patched so all the artifacts follow this structure
4+
5+
from json import dumps
6+
7+
from qiita_db.sql_connection import TRN
8+
9+
with TRN:
10+
sql = """SELECT *
11+
FROM qiita.artifact
12+
JOIN qiita.artifact_output_processing_job
13+
USING (artifact_id)
14+
WHERE command_id IS NOT NULL"""
15+
TRN.add(sql)
16+
17+
sql_update_artifact = """UPDATE qiita.artifact
18+
SET command_parameters = %s
19+
WHERE artifact_id = %s"""
20+
sql_update_job = """UPDATE qiita.processing_job
21+
SET command_parameters = %s
22+
WHERE processing_job_id = %s"""
23+
for ainfo in TRN.execute_fetchindex():
24+
ainfo = dict(ainfo)
25+
params = dumps(
26+
{k: str(v) for k, v in ainfo['command_parameters'].items()})
27+
TRN.add(sql_update_artifact, [params, ainfo['artifact_id']])
28+
TRN.add(sql_update_job, [params, ainfo['processing_job_id']])

qiita_db/test/test_artifact.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,24 +96,24 @@ def test_processing_parameters(self):
9696
obs = qdb.artifact.Artifact(2).processing_parameters
9797
exp = qdb.software.Parameters.load(
9898
qdb.software.Command(1),
99-
values_dict={'max_barcode_errors': 1.5, 'sequence_max_n': 0,
100-
'max_bad_run_length': 3, 'rev_comp': False,
101-
'phred_quality_threshold': 3, 'input_data': 1,
102-
'rev_comp_barcode': False,
103-
'rev_comp_mapping_barcodes': False,
104-
'min_per_read_length_fraction': 0.75,
99+
values_dict={'max_barcode_errors': '1.5', 'sequence_max_n': '0',
100+
'max_bad_run_length': '3', 'rev_comp': 'False',
101+
'phred_quality_threshold': '3', 'input_data': '1',
102+
'rev_comp_barcode': 'False',
103+
'rev_comp_mapping_barcodes': 'False',
104+
'min_per_read_length_fraction': '0.75',
105105
'barcode_type': 'golay_12',
106106
'phred_offset': 'auto'})
107107
self.assertEqual(obs, exp)
108108
obs = qdb.artifact.Artifact(3).processing_parameters
109109
exp = qdb.software.Parameters.load(
110110
qdb.software.Command(1),
111-
values_dict={'max_barcode_errors': 1.5, 'sequence_max_n': 0,
112-
'max_bad_run_length': 3, 'rev_comp': False,
113-
'phred_quality_threshold': 3, 'input_data': 1,
114-
'rev_comp_barcode': False,
115-
'rev_comp_mapping_barcodes': True,
116-
'min_per_read_length_fraction': 0.75,
111+
values_dict={'max_barcode_errors': '1.5', 'sequence_max_n': '0',
112+
'max_bad_run_length': '3', 'rev_comp': 'False',
113+
'phred_quality_threshold': '3', 'input_data': '1',
114+
'rev_comp_barcode': 'False',
115+
'rev_comp_mapping_barcodes': 'True',
116+
'min_per_read_length_fraction': '0.75',
117117
'barcode_type': 'golay_12',
118118
'phred_offset': 'auto'})
119119
self.assertEqual(obs, exp)

qiita_db/test/test_util.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -930,9 +930,9 @@ def test_get_artifacts_information(self):
930930
'Pick closed-reference OTUs, QIIMEv1.9.1 | Defaults'),
931931
'data_type': '18S', 'prep_samples': 27,
932932
'parameters': {
933-
'reference': 1, 'similarity': 0.97, 'sortmerna_e_value': 1,
934-
'sortmerna_max_pos': 10000, 'threads': 1,
935-
'sortmerna_coverage': 0.97}, 'name': 'BIOM'},
933+
'reference': '1', 'similarity': '0.97',
934+
'sortmerna_e_value': '1', 'sortmerna_max_pos': '10000',
935+
'threads': '1', 'sortmerna_coverage': '0.97'}, 'name': 'BIOM'},
936936
{'files': [], 'target_subfragment': ['V4'], 'algorithm': '',
937937
'artifact_id': 7, 'data_type': '16S', 'prep_samples': 27,
938938
'parameters': {}, 'name': 'BIOM'},

qiita_pet/handlers/api_proxy/tests/test_artifact.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,19 +229,19 @@ def test_artifact_get_info(self):
229229
'artifact_id': 6, 'data_type': '16S',
230230
'timestamp': '2012-10-02 17:30:00', 'prep_samples': 27,
231231
'parameters': {
232-
'reference': 2, 'similarity': 0.97, u'sortmerna_e_value': 1,
233-
'sortmerna_max_pos': 10000, 'threads': 1,
234-
'sortmerna_coverage': 0.97}, 'name': 'BIOM'},
232+
'reference': '2', 'similarity': '0.97',
233+
'sortmerna_e_value': '1', 'sortmerna_max_pos': '10000',
234+
'threads': '1', 'sortmerna_coverage': '0.97'}, 'name': 'BIOM'},
235235
{'files': ['1_study_1001_closed_reference_otu_table.biom'],
236236
'target_subfragment': ['V4'],
237237
'algorithm': (
238238
'Pick closed-reference OTUs, QIIMEv1.9.1 | Defaults'),
239239
'artifact_id': 5, 'data_type': '18S',
240240
'timestamp': '2012-10-02 17:30:00', 'prep_samples': 27,
241241
'parameters': {
242-
'reference': 1, 'similarity': 0.97, 'sortmerna_e_value': 1,
243-
'sortmerna_max_pos': 10000, 'threads': 1,
244-
'sortmerna_coverage': 0.97}, 'name': 'BIOM'},
242+
'reference': '1', 'similarity': '0.97',
243+
'sortmerna_e_value': '1', 'sortmerna_max_pos': '10000',
244+
'threads': '1', 'sortmerna_coverage': '0.97'}, 'name': 'BIOM'},
245245
{'files': [], 'target_subfragment': ['V4'], 'algorithm': '',
246246
'artifact_id': 7, 'data_type': '16S',
247247
'timestamp': '2012-10-02 17:30:00', 'prep_samples': 27,

qiita_pet/handlers/artifact_handlers/tests/test_base_handlers.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,12 @@ def test_artifact_summary_get_request(self):
240240
'btn-sm" href="/vamps/2"><span class="glyphicon '
241241
'glyphicon-export"></span> Submit to VAMPS</a>'),
242242
'processing_parameters': {
243-
'max_barcode_errors': 1.5, 'sequence_max_n': 0,
244-
'max_bad_run_length': 3, 'phred_offset': u'auto',
245-
'rev_comp': False, 'phred_quality_threshold': 3,
246-
'input_data': 1, 'rev_comp_barcode': False,
247-
'rev_comp_mapping_barcodes': False,
248-
'min_per_read_length_fraction': 0.75,
243+
'max_barcode_errors': '1.5', 'sequence_max_n': '0',
244+
'max_bad_run_length': '3', 'phred_offset': u'auto',
245+
'rev_comp': 'False', 'phred_quality_threshold': '3',
246+
'input_data': '1', 'rev_comp_barcode': 'False',
247+
'rev_comp_mapping_barcodes': 'False',
248+
'min_per_read_length_fraction': '0.75',
249249
'barcode_type': u'golay_12'},
250250
'files': exp_files,
251251
'is_from_analysis': False,

qiita_pet/handlers/study_handlers/tests/test_artifact.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ def test_get(self):
169169
'prep_samples': 27,
170170
'algorithm': 'Pick closed-reference OTUs, QIIMEv1.9.1 | Defaults',
171171
'parameters': {
172-
'reference': 2, 'similarity': 0.97, 'sortmerna_e_value': 1,
173-
'sortmerna_max_pos': 10000, 'threads': 1,
174-
'sortmerna_coverage': 0.97}, 'name': 'BIOM'},
172+
'reference': '2', 'similarity': '0.97',
173+
'sortmerna_e_value': '1', 'sortmerna_max_pos': '10000',
174+
'threads': '1', 'sortmerna_coverage': '0.97'}, 'name': 'BIOM'},
175175
{'files': [], 'target_subfragment': ['V4'], 'artifact_id': 7,
176176
'data_type': '16S', 'timestamp': '2012-10-02 17:30:00',
177177
'prep_samples': 27, 'algorithm': '', 'parameters': {},

0 commit comments

Comments
 (0)