Skip to content

Patch 61 - transfer all parameters to str #2379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions qiita_db/handlers/tests/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def test_get_artifact(self):
'prep_information': [],
'study': None,
'analysis': 1,
'processing_parameters': {'biom_table': 8, 'depth': 9000,
'subsample_multinomial': False},
'processing_parameters': {'biom_table': '8', 'depth': '9000',
'subsample_multinomial': 'False'},
'files': exp_fps}
obs = loads(obs.body)
# The timestamp is genreated at patch time, so we can't check for it
Expand Down
2 changes: 2 additions & 0 deletions qiita_db/support_files/patches/61.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- October 30th, 2017
SELECT 42;
28 changes: 28 additions & 0 deletions qiita_db/support_files/patches/python_patches/61.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# October 30th, 2017
# A change introduced in July made all the parameters to be stored as strings
# The DB needs to be patched so all the artifacts follow this structure

from json import dumps

from qiita_db.sql_connection import TRN

with TRN:
sql = """SELECT *
FROM qiita.artifact
JOIN qiita.artifact_output_processing_job
USING (artifact_id)
WHERE command_id IS NOT NULL"""
TRN.add(sql)

sql_update_artifact = """UPDATE qiita.artifact
SET command_parameters = %s
WHERE artifact_id = %s"""
sql_update_job = """UPDATE qiita.processing_job
SET command_parameters = %s
WHERE processing_job_id = %s"""
for ainfo in TRN.execute_fetchindex():
ainfo = dict(ainfo)
params = dumps(
{k: str(v) for k, v in ainfo['command_parameters'].items()})
TRN.add(sql_update_artifact, [params, ainfo['artifact_id']])
TRN.add(sql_update_job, [params, ainfo['processing_job_id']])
24 changes: 12 additions & 12 deletions qiita_db/test/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,24 @@ def test_processing_parameters(self):
obs = qdb.artifact.Artifact(2).processing_parameters
exp = qdb.software.Parameters.load(
qdb.software.Command(1),
values_dict={'max_barcode_errors': 1.5, 'sequence_max_n': 0,
'max_bad_run_length': 3, 'rev_comp': False,
'phred_quality_threshold': 3, 'input_data': 1,
'rev_comp_barcode': False,
'rev_comp_mapping_barcodes': False,
'min_per_read_length_fraction': 0.75,
values_dict={'max_barcode_errors': '1.5', 'sequence_max_n': '0',
'max_bad_run_length': '3', 'rev_comp': 'False',
'phred_quality_threshold': '3', 'input_data': '1',
'rev_comp_barcode': 'False',
'rev_comp_mapping_barcodes': 'False',
'min_per_read_length_fraction': '0.75',
'barcode_type': 'golay_12',
'phred_offset': 'auto'})
self.assertEqual(obs, exp)
obs = qdb.artifact.Artifact(3).processing_parameters
exp = qdb.software.Parameters.load(
qdb.software.Command(1),
values_dict={'max_barcode_errors': 1.5, 'sequence_max_n': 0,
'max_bad_run_length': 3, 'rev_comp': False,
'phred_quality_threshold': 3, 'input_data': 1,
'rev_comp_barcode': False,
'rev_comp_mapping_barcodes': True,
'min_per_read_length_fraction': 0.75,
values_dict={'max_barcode_errors': '1.5', 'sequence_max_n': '0',
'max_bad_run_length': '3', 'rev_comp': 'False',
'phred_quality_threshold': '3', 'input_data': '1',
'rev_comp_barcode': 'False',
'rev_comp_mapping_barcodes': 'True',
'min_per_read_length_fraction': '0.75',
'barcode_type': 'golay_12',
'phred_offset': 'auto'})
self.assertEqual(obs, exp)
Expand Down
6 changes: 3 additions & 3 deletions qiita_db/test/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,9 +930,9 @@ def test_get_artifacts_information(self):
'Pick closed-reference OTUs, QIIMEv1.9.1 | Defaults'),
'data_type': '18S', 'prep_samples': 27,
'parameters': {
'reference': 1, 'similarity': 0.97, 'sortmerna_e_value': 1,
'sortmerna_max_pos': 10000, 'threads': 1,
'sortmerna_coverage': 0.97}, 'name': 'BIOM'},
'reference': '1', 'similarity': '0.97',
'sortmerna_e_value': '1', 'sortmerna_max_pos': '10000',
'threads': '1', 'sortmerna_coverage': '0.97'}, 'name': 'BIOM'},
{'files': [], 'target_subfragment': ['V4'], 'algorithm': '',
'artifact_id': 7, 'data_type': '16S', 'prep_samples': 27,
'parameters': {}, 'name': 'BIOM'},
Expand Down
12 changes: 6 additions & 6 deletions qiita_pet/handlers/api_proxy/tests/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,19 +229,19 @@ def test_artifact_get_info(self):
'artifact_id': 6, 'data_type': '16S',
'timestamp': '2012-10-02 17:30:00', 'prep_samples': 27,
'parameters': {
'reference': 2, 'similarity': 0.97, u'sortmerna_e_value': 1,
'sortmerna_max_pos': 10000, 'threads': 1,
'sortmerna_coverage': 0.97}, 'name': 'BIOM'},
'reference': '2', 'similarity': '0.97',
'sortmerna_e_value': '1', 'sortmerna_max_pos': '10000',
'threads': '1', 'sortmerna_coverage': '0.97'}, 'name': 'BIOM'},
{'files': ['1_study_1001_closed_reference_otu_table.biom'],
'target_subfragment': ['V4'],
'algorithm': (
'Pick closed-reference OTUs, QIIMEv1.9.1 | Defaults'),
'artifact_id': 5, 'data_type': '18S',
'timestamp': '2012-10-02 17:30:00', 'prep_samples': 27,
'parameters': {
'reference': 1, 'similarity': 0.97, 'sortmerna_e_value': 1,
'sortmerna_max_pos': 10000, 'threads': 1,
'sortmerna_coverage': 0.97}, 'name': 'BIOM'},
'reference': '1', 'similarity': '0.97',
'sortmerna_e_value': '1', 'sortmerna_max_pos': '10000',
'threads': '1', 'sortmerna_coverage': '0.97'}, 'name': 'BIOM'},
{'files': [], 'target_subfragment': ['V4'], 'algorithm': '',
'artifact_id': 7, 'data_type': '16S',
'timestamp': '2012-10-02 17:30:00', 'prep_samples': 27,
Expand Down
12 changes: 6 additions & 6 deletions qiita_pet/handlers/artifact_handlers/tests/test_base_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,12 @@ def test_artifact_summary_get_request(self):
'btn-sm" href="/vamps/2"><span class="glyphicon '
'glyphicon-export"></span> Submit to VAMPS</a>'),
'processing_parameters': {
'max_barcode_errors': 1.5, 'sequence_max_n': 0,
'max_bad_run_length': 3, 'phred_offset': u'auto',
'rev_comp': False, 'phred_quality_threshold': 3,
'input_data': 1, 'rev_comp_barcode': False,
'rev_comp_mapping_barcodes': False,
'min_per_read_length_fraction': 0.75,
'max_barcode_errors': '1.5', 'sequence_max_n': '0',
'max_bad_run_length': '3', 'phred_offset': u'auto',
'rev_comp': 'False', 'phred_quality_threshold': '3',
'input_data': '1', 'rev_comp_barcode': 'False',
'rev_comp_mapping_barcodes': 'False',
'min_per_read_length_fraction': '0.75',
'barcode_type': u'golay_12'},
'files': exp_files,
'is_from_analysis': False,
Expand Down
6 changes: 3 additions & 3 deletions qiita_pet/handlers/study_handlers/tests/test_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ def test_get(self):
'prep_samples': 27,
'algorithm': 'Pick closed-reference OTUs, QIIMEv1.9.1 | Defaults',
'parameters': {
'reference': 2, 'similarity': 0.97, 'sortmerna_e_value': 1,
'sortmerna_max_pos': 10000, 'threads': 1,
'sortmerna_coverage': 0.97}, 'name': 'BIOM'},
'reference': '2', 'similarity': '0.97',
'sortmerna_e_value': '1', 'sortmerna_max_pos': '10000',
'threads': '1', 'sortmerna_coverage': '0.97'}, 'name': 'BIOM'},
{'files': [], 'target_subfragment': ['V4'], 'artifact_id': 7,
'data_type': '16S', 'timestamp': '2012-10-02 17:30:00',
'prep_samples': 27, 'algorithm': '', 'parameters': {},
Expand Down