Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion qiita_pet/handlers/study_handlers/ebi_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def display_template(self, preprocessed_data_id, msg, msg_level):
# 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 not fail.
# 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]
Expand Down
64 changes: 40 additions & 24 deletions qiita_pet/handlers/study_handlers/vamps_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Copy link
Contributor

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?

Copy link
Member Author

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 ...

Copy link
Contributor

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:

  •    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]
    

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 ...


Reply to this email directly or view it on GitHub:
https://github.com/biocore/qiita/pull/1671/files#r54789962

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)

Expand All @@ -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

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meant to be here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

On (Mar-02-16|12:57), Antonio Gonzalez wrote:

@@ -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
    

Meant to be here.


Reply to this email directly or view it on GitHub:
https://github.com/biocore/qiita/pull/1671/files#r54789976

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):
Expand All @@ -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)
13 changes: 11 additions & 2 deletions qiita_pet/templates/vamps_submission.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends sitebase.html %}
{% block content %}
{% from future.utils import viewitems %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is being used anywhere.


<h1>Submission summary for study: <b>{{study_title}}</b></h1>

Expand All @@ -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>
Expand Down