-
Couldn't load subscription status.
- Fork 79
fixing VAMPS submission and fix #756 #1671
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,9 +12,6 @@ | |
| from qiita_ware.context import submit | ||
| from qiita_ware.demux import stats as demux_stats | ||
| from qiita_ware.dispatchable import submit_to_VAMPS | ||
| from qiita_db.metadata_template.prep_template import PrepTemplate | ||
| from qiita_db.metadata_template.sample_template import SampleTemplate | ||
| from qiita_db.study import Study | ||
| from qiita_db.exceptions import QiitaDBUnknownIDError | ||
| from qiita_db.artifact import Artifact | ||
| from qiita_pet.handlers.base_handlers import BaseHandler | ||
|
|
@@ -36,15 +33,26 @@ def display_template(self, preprocessed_data_id, msg, msg_level): | |
| if user.level != 'admin': | ||
| raise HTTPError(403, "No permissions of admin, " | ||
| "get/VAMPSSubmitHandler: %s!" % user.id) | ||
|
|
||
| prep_template = PrepTemplate(preprocessed_data.prep_template) | ||
| sample_template = SampleTemplate(preprocessed_data.study) | ||
| study = Study(preprocessed_data.study) | ||
| prep_templates = preprocessed_data.prep_templates | ||
| allow_submission = len(prep_templates) == 1 | ||
| msg_list = ["Submission to EBI disabled:"] | ||
| if not allow_submission: | ||
| msg_list.append( | ||
| "Only artifacts with a single prep template can be submitted") | ||
| # If allow_submission is already false, we technically don't need to | ||
| # do the following work. However, there is no clean way to fix this | ||
| # using the current structure, so we perform the work as we | ||
| # did so it doesn't fail. | ||
| # We currently support only one prep template for submission, so | ||
| # grabbing the first one | ||
| prep_template = prep_templates[0] | ||
| study = preprocessed_data.study | ||
| sample_template = study.sample_template | ||
| stats = [('Number of samples', len(prep_template)), | ||
| ('Number of metadata headers', | ||
| len(sample_template.categories()))] | ||
|
|
||
| demux = [path for _, path, ftype in preprocessed_data.get_filepaths() | ||
| demux = [path for _, path, ftype in preprocessed_data.filepaths | ||
| if ftype == 'preprocessed_demux'] | ||
| demux_length = len(demux) | ||
|
|
||
|
|
@@ -61,10 +69,21 @@ def display_template(self, preprocessed_data_id, msg, msg_level): | |
| stats.append(('Number of sequences', demux_file_stats.n)) | ||
| msg_level = 'success' | ||
|
|
||
| # In EBI here we check that we have the required field for submission, | ||
| # however for VAMPS we don't need that | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was this line accidental or meant to be here, highlighting just in case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Meant to be here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks! On (Mar-02-16|12:57), Antonio Gonzalez wrote:
|
||
| if not allow_submission: | ||
| disabled_msg = "<br/>".join(msg_list) | ||
| else: | ||
| disabled_msg = None | ||
|
|
||
| self.render('vamps_submission.html', | ||
| study_title=study.title, stats=stats, message=msg, | ||
| study_id=study.id, level=msg_level, | ||
| preprocessed_data_id=preprocessed_data_id) | ||
| preprocessed_data_id=preprocessed_data_id, | ||
| investigation_type=prep_template.investigation_type, | ||
| allow_submission=allow_submission, | ||
| disabled_msg=disabled_msg) | ||
|
|
||
| @authenticated | ||
| def get(self, preprocessed_data_id): | ||
|
|
@@ -73,33 +92,30 @@ def get(self, preprocessed_data_id): | |
| @authenticated | ||
| @execute_as_transaction | ||
| def post(self, preprocessed_data_id): | ||
| user = self.current_user | ||
| # make sure user is admin and can therefore actually submit to VAMPS | ||
| if self.current_user.level != 'admin': | ||
| if user.level != 'admin': | ||
| raise HTTPError(403, "User %s cannot submit to VAMPS!" % | ||
| self.current_user.id) | ||
| user.id) | ||
| msg = '' | ||
| msg_level = 'success' | ||
| preprocessed_data = Artifact(preprocessed_data_id) | ||
| state = preprocessed_data.submitted_to_vamps_status() | ||
|
|
||
| demux = [path for _, path, ftype in preprocessed_data.get_filepaths() | ||
| if ftype == 'preprocessed_demux'] | ||
| demux_length = len(demux) | ||
|
|
||
| if state in ('submitting', 'success'): | ||
| study = Artifact(preprocessed_data_id).study | ||
| study_id = study.id | ||
| state = study.ebi_submission_status | ||
| if state == 'submitting': | ||
| msg = "Cannot resubmit! Current state is: %s" % state | ||
| msg_level = 'danger' | ||
| elif demux_length != 1: | ||
| msg = "The study doesn't have demux files or have too many" % state | ||
| msg_level = 'danger' | ||
| else: | ||
| channel = self.current_user.id | ||
| channel = user.id | ||
| job_id = submit(channel, submit_to_VAMPS, | ||
| int(preprocessed_data_id)) | ||
|
|
||
| self.render('compute_wait.html', | ||
| job_id=job_id, title='VAMPS Submission', | ||
| completion_redirect='/compute_complete/%s' % job_id) | ||
| completion_redirect=('/study/description/%s?top_tab=' | ||
| 'preprocessed_data_tab&sub_tab=%s' | ||
| % (study_id, | ||
| preprocessed_data_id))) | ||
| return | ||
|
|
||
| self.display_template(preprocessed_data_id, msg, msg_level) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| {% extends sitebase.html %} | ||
| {% block content %} | ||
| {% from future.utils import viewitems %} | ||
|
||
|
|
||
| <h1>Submission summary for study: <b>{{study_title}}</b></h1> | ||
|
|
||
|
|
@@ -23,9 +24,17 @@ <h1>Submission summary for study: <b>{{study_title}}</b></h1> | |
| {% end %} | ||
| </table> | ||
| </div> | ||
| {% if level != 'danger' and maintenance is None %} | ||
| <input type="submit" class="btn btn-primary" value="Submit to VAMPS"> | ||
| The investigation type is: <b>{{investigation_type}}</b> | ||
| <br/><br/> | ||
|
|
||
| {% if level != 'danger' and maintenance is None %} | ||
| {% if allow_submission %} | ||
| <input type="submit" class="btn btn-primary" value="Submit to VAMPS"> | ||
| {% else %} | ||
| <b>{% raw disabled_msg %} | ||
| {% end %} | ||
| {% end %} | ||
|
|
||
| <br/><br/> | ||
| <a class="btn btn-primary" href="/study/description/{{study_id}}?top_tab=preprocessed_data_tab&sub_tab={{preprocessed_data_id}}">Return to study</a> | ||
| </form> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be that at this point, the number of prep templates is zero and that this would throw an
IndexError?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theoretically it could but in practice it can't: the only way to get to this point is by clicking on a button that is only shown when you see the summary of the prep template ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noted, thanks!
On (Mar-02-16|12:57), Antonio Gonzalez wrote: