Skip to content
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

[WIP] Improve SQL study listing #3162

Closed
wants to merge 3 commits into from
Closed
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
31 changes: 18 additions & 13 deletions qiita_db/study.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,24 +1001,23 @@ def _ebi_submission_jobs(self):
'Qiita', 'alpha')
cmd = plugin.get_command('submit_to_EBI')

sql = """SELECT processing_job_id,
sql = f"""SELECT processing_job_id,
pj.command_parameters->>'artifact' as aid,
processing_job_status, can_be_submitted_to_ebi,
array_agg(ebi_run_accession)
processing_job_status
FROM qiita.processing_job pj
LEFT JOIN qiita.processing_job_status
USING (processing_job_status_id)
LEFT JOIN qiita.artifact ON (
artifact_id = (
pj.command_parameters->>'artifact')::INT)
LEFT JOIN qiita.ebi_run_accession era USING (artifact_id)
LEFT JOIN qiita.artifact_type USING (artifact_type_id)
LEFT JOIN qiita.ebi_run_accession USING (artifact_id)

WHERE pj.command_parameters->>'artifact' IN (
SELECT artifact_id::text
FROM qiita.study_artifact WHERE study_id = {0})
AND pj.command_id = {1}
GROUP BY processing_job_id, aid, processing_job_status,
can_be_submitted_to_ebi""".format(self._id, cmd.id)
FROM qiita.study_artifact
WHERE study_id = {self._id})
AND pj.command_id = {cmd.id}"""
qdb.sql_connection.TRN.add(sql)

return qdb.sql_connection.TRN.execute_fetchindex()
Expand Down Expand Up @@ -1047,11 +1046,10 @@ def ebi_submission_status(self):
status = 'submitted'

jobs = defaultdict(dict)
for info in self._ebi_submission_jobs():
jid, aid, js, cbste, era = info
if not cbste or era != [None]:
continue
artifacts = defaultdict()
for jid, aid, js in self._ebi_submission_jobs():
jobs[js][aid] = jid
artifacts[aid] = None

if 'queued' in jobs or 'running' in jobs:
status = 'submitting'
Expand All @@ -1060,7 +1058,14 @@ def ebi_submission_status(self):
aids_other = []
for s, aids in jobs.items():
for aid in aids.keys():
if s == 'error':
if artifacts[aid] is None:
a = qdb.artifact.Artifact(aid)
cbste = a.can_be_submitted_to_ebi
era = False
if cbste:
era = bool(a.ebi_run_accessions)
artifacts[aid] = [cbste, era]
if s == 'error' and artifacts[aid] == [True, False]:
aids_error.append(aid)
else:
aids_other.append(aid)
Expand Down
2 changes: 1 addition & 1 deletion qiita_ware/private_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def submit_to_EBI(job):
artifact = qdb.artifact.Artifact(artifact_id)

for info in artifact.study._ebi_submission_jobs():
jid, aid, js, cbste, era = info
jid, aid, js = info
if js in ('running', 'queued') and jid != job.id:
error_msg = ("Cannot perform parallel EBI submission for "
"the same study. Current job running: %s" % js)
Expand Down