Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
0c9598b
fix #1067
antgonza Feb 20, 2018
58858ae
addressing @ElDeveloper comments
antgonza Feb 21, 2018
82c546a
Merge pull request #2507 from antgonza/fix-1067
wasade Feb 22, 2018
cbebd76
fix #2512
antgonza Feb 23, 2018
7659c88
fix #1999 (#2514)
antgonza Feb 23, 2018
617831b
addressing @ElDeveloper comments
antgonza Feb 23, 2018
ff87431
Merge branch 'master' of https://github.com/biocore/qiita into dev
antgonza Feb 23, 2018
b1924c3
Merge branch 'dev' of https://github.com/biocore/qiita into dev
antgonza Feb 23, 2018
7462867
adding secret
antgonza Feb 23, 2018
0994537
Merge pull request #2515 from antgonza/fix-2512
Mar 7, 2018
7b63710
WIP: EBI-ENA test (#2516)
antgonza Mar 7, 2018
bb3cd2f
fix secure
antgonza Mar 7, 2018
baf7739
rm single quote
antgonza Mar 7, 2018
5e0f643
upstrem dev
antgonza Mar 7, 2018
ae5d1a3
Fix 2321 (#2522)
antgonza Mar 8, 2018
1d54381
Merge branch 'dev' of https://github.com/biocore/qiita into dev
antgonza Apr 3, 2018
4ba96ab
Illumina models 0318 (#2532)
antgonza Apr 3, 2018
6a06964
adding secure
antgonza Apr 3, 2018
b9a2cba
Merge branch 'dev' of https://github.com/biocore/qiita into dev
antgonza Apr 4, 2018
232c21a
Update index.rst (#2533)
stephanieorch Apr 4, 2018
56aaeac
Plugin API Doc (#2534)
antgonza Apr 4, 2018
2dcdd93
Fix 1810 (#2523)
antgonza Apr 4, 2018
caee66e
DOC: Cleanup of JavaScript libraries and licenses (#2536)
ElDeveloper Apr 4, 2018
39cc48d
Merge branch 'dev' of https://github.com/biocore/qiita into dev
antgonza Apr 5, 2018
b268a42
adding initial download/redbiom info
antgonza Apr 5, 2018
77af7fd
adding docs
antgonza Apr 5, 2018
c1c8e9b
addressing @ElDeveloper comments
antgonza Apr 5, 2018
e7c5832
Fix aid str workflow (#2537)
antgonza Apr 5, 2018
d1d5e44
Merge branch 'dev' of https://github.com/biocore/qiita into dev
antgonza Apr 5, 2018
e356545
fix #2519
antgonza Apr 5, 2018
3799456
fix #2524
antgonza Apr 5, 2018
b510802
fix #2531
antgonza Apr 6, 2018
cc404e0
fix #2529
antgonza Apr 6, 2018
7bad458
split qiita-cron-job into multiple commands
antgonza Apr 6, 2018
eb62b96
rm leftover docs
antgonza Apr 6, 2018
5d53cde
Merge pull request #2540 from antgonza/fix-2524
Apr 6, 2018
d6293b4
Merge pull request #2542 from antgonza/fix-2529
adswafford Apr 6, 2018
af7469b
Merge pull request #2541 from antgonza/fix-2531
adswafford Apr 6, 2018
03ec61b
Merge pull request #2539 from antgonza/fix-2519
adswafford Apr 6, 2018
4672d2c
Update downloading.rst
stephanieorch Apr 6, 2018
3c6416e
fix_reference_order (#2547)
stephanieorch Apr 6, 2018
2437e4f
addressing @stephanieorch comments
antgonza Apr 6, 2018
ed78f0a
addressing @ElDeveloper comments
antgonza Apr 6, 2018
f9ed95f
Fix 2492 (#2544)
antgonza Apr 6, 2018
a9ba0e5
Redbiom -> redbiom @wasade
antgonza Apr 6, 2018
6d72398
addressing @wasade comments
antgonza Apr 6, 2018
59b9bcb
Update .travis.yml
antgonza Apr 6, 2018
9f7e186
Fix 2505 (#2545)
antgonza Apr 7, 2018
2a2cce7
Merge pull request #2543 from antgonza/split-qiita-cron-job
Apr 7, 2018
9f8ab39
Merge pull request #2538 from antgonza/doc-redbiom-download
Apr 7, 2018
2c8b4c6
Fix 2530 (#2546)
antgonza Apr 7, 2018
51986a1
fix-secure
antgonza Apr 7, 2018
d701b81
improve available files display
antgonza Apr 15, 2018
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
12 changes: 3 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ sudo: false
env:
global:
- PYTHON_VERSION=3.5
- secure: "OFyFddp26BbuaYxD2suftmbSfyaLcvleOL9heGh4IqqbvDVX+EcaqvmUALRaBL4HQlK5W0rO9H4pFsXuq26Xl3S2EKr+Pne4SDlw9ekmU3n6bWVNwReG7V+9c7OEgfNHbZ4pNwRzti62n1ESlRSZVkLVGg+pI0Ikvbh1+yUm9Eg="
matrix:
- TEST_ADD_STUDIES=False COVER_PACKAGE=qiita_db
- TEST_ADD_STUDIES=False COVER_PACKAGE=qiita_pet
Expand All @@ -19,9 +20,6 @@ before_install:
- wget ftp://ftp.microbio.me/pub/qiita/ascp-install-3.5.4.102989-linux-64-qiita.sh -O ascp-install-3.5.4.102989-linux-64-qiita.sh
- chmod +x ascp-install-3.5.4.102989-linux-64-qiita.sh
- ./ascp-install-3.5.4.102989-linux-64-qiita.sh
# once we have ebi testing we should uncomment this line
# look for EBI below as it's part of this
# - if [ ${TRAVIS_PULL_REQUEST} == "false" ]; then openssl aes-256-cbc -K $encrypted_a2e23aea5f14_key -iv $encrypted_a2e23aea5f14_iv -in qiita_core/support_files/config_test_travis.cfg.enc -out qiita_core/support_files/config_test_travis.cfg -d ; fi
install:
# install a few of the dependencies that pip would otherwise try to install
# when intalling scikit-bio
Expand Down Expand Up @@ -64,10 +62,6 @@ install:
- source deactivate
- source activate qiita
before_script:
# EBI, see the end of before_install about why this block is commented out
# - if [ ${TRAVIS_PULL_REQUEST} == "false" ]; then
# export QIITA_CONFIG_FP=`pwd`/qiita_core/support_files/config_test_travis.cfg;
# fi
- qiita-env make --no-load-ontologies
- qiita-test-install
script:
Expand All @@ -79,8 +73,8 @@ script:
- nosetests $COVER_PACKAGE --with-doctest --with-coverage --with-timer -v --cover-package=$COVER_PACKAGE
- kill $QIITA_PID
- if [ ${TEST_ADD_STUDIES} == "True" ]; then test_data_studies/commands.sh ; fi
- if [ ${TEST_ADD_STUDIES} == "True" ]; then qiita-cron-job ; fi
- flake8 qiita_* setup.py scripts/*
- if [ ${TEST_ADD_STUDIES} == "True" ]; then all-qiita-cron-job; fi
- flake8 qiita_* setup.py scripts/qiita*
- qiita pet webserver
addons:
postgresql: "9.3"
Expand Down
Binary file removed qiita_core/support_files/config_test_travis.cfg.enc
Binary file not shown.
2 changes: 1 addition & 1 deletion qiita_db/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def get_merging_scheme_from_job(cls, job):
ppms = pms['parameters']
pparams = ','.join(
['%s: %s' % (k, v) for k, v in ppp.values.items()
if list(v)[0] != 'artifact' and k in ppms])
if list(str(v))[0] != 'artifact' and k in ppms])
if pparams:
palgorithm = "%s (%s)" % (palgorithm, pparams)
algorithm = '%s | %s' % (cname, palgorithm)
Expand Down
39 changes: 0 additions & 39 deletions qiita_db/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,45 +186,6 @@ def load_prep_template_from_cmd(prep_temp_path, study_id, data_type):
prep_temp, qdb.study.Study(study_id), data_type)


def load_parameters_from_cmd(name, fp, cmd_id):
"""Add a new parameters entry on `table`

Parameters
----------
fp : str
The filepath to the parameters file
cmd_id : int
The command to add the new default parameter set

Returns
-------
qiita_db.software.DefaultParameters
The newly parameter set object created

Raises
------
ValueError
If the table does not exists on the DB
If the fp is not correctly formatted

Notes
-----
`fp` should be a tab-delimited text file following this format:
parameter_1<TAB>value
parameter_2<TAB>value
...
"""
cmd = qdb.software.Command(cmd_id)

try:
params = dict(tuple(l.strip().split('\t')) for l in open(fp, 'U'))
except ValueError:
raise ValueError("The format of the parameters files is not correct. "
"The format is PARAMETER_NAME<tab>VALUE")

return qdb.software.DefaultParameters.create(name, cmd, **params)


def update_artifact_from_cmd(filepaths, filepath_types, artifact_id):
"""Updates the artifact `artifact_id` with the given files

Expand Down
60 changes: 39 additions & 21 deletions qiita_db/environment_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def _check_db_exists(db, conn_handler):
return (db,) in dbs


def create_layout_and_patch(test=False, verbose=False):
r"""Builds the SQL layout and applies all the patches
def create_layout(test=False, verbose=False):
r"""Builds the SQL layout

Parameters
----------
Expand All @@ -69,10 +69,6 @@ def create_layout_and_patch(test=False, verbose=False):
qdb.sql_connection.TRN.add(f.read())
qdb.sql_connection.TRN.execute()

if verbose:
print('Patching Database...')
patch(verbose=verbose, test=test)


def _populate_test_db():
with qdb.sql_connection.TRN:
Expand Down Expand Up @@ -191,30 +187,51 @@ def make_environment(load_ontologies, download_reference, add_demo_user):

# Create the database
print('Creating database')
create_settings_table = True
admin_conn.autocommit = True
admin_conn.execute('CREATE DATABASE %s' % qiita_config.database)
try:
admin_conn.execute('CREATE DATABASE %s' % qiita_config.database)
except ValueError as error:
# if database exists ignore
msg = 'database "%s" already exists' % qiita_config.database
if msg in error.message:
print("Database exits, let's make sure it's test")
with qdb.sql_connection.TRN:
# Insert the settings values to the database
sql = """SELECT test FROM settings"""
qdb.sql_connection.TRN.add(sql)
is_test = qdb.sql_connection.TRN.execute_fetchlast()
if not is_test:
print('Not a test database')
raise
create_settings_table = False
else:
raise
admin_conn.autocommit = False

del admin_conn
qdb.sql_connection.SQLConnectionHandler.close()

with qdb.sql_connection.TRN:
print('Inserting database metadata')
# Build the SQL layout into the database
with open(SETTINGS_FP, 'U') as f:
qdb.sql_connection.TRN.add(f.read())
qdb.sql_connection.TRN.execute()
test = qiita_config.test_environment
verbose = True
if create_settings_table:
# Build the SQL layout into the database
with open(SETTINGS_FP, 'U') as f:
qdb.sql_connection.TRN.add(f.read())
qdb.sql_connection.TRN.execute()

# Insert the settings values to the database
sql = """INSERT INTO settings (test, base_data_dir, base_work_dir)
VALUES (%s, %s, %s)"""
qdb.sql_connection.TRN.add(
sql, [qiita_config.test_environment, qiita_config.base_data_dir,
qiita_config.working_dir])
qdb.sql_connection.TRN.execute()
# Insert the settings values to the database
sql = """INSERT INTO settings (test, base_data_dir, base_work_dir)
VALUES (%s, %s, %s)"""
qdb.sql_connection.TRN.add(
sql, [test, qiita_config.base_data_dir,
qiita_config.working_dir])
qdb.sql_connection.TRN.execute()
create_layout(test=test, verbose=verbose)

create_layout_and_patch(test=qiita_config.test_environment,
verbose=True)
patch(verbose=verbose, test=test)

if load_ontologies:
_add_ontology_data()
Expand Down Expand Up @@ -315,7 +332,8 @@ def drop_and_rebuild_tst_database():
qdb.sql_connection.TRN.add(
"UPDATE settings SET current_patch = 'unpatched'")
# Create the database and apply patches
create_layout_and_patch(test=True)
create_layout(test=True)
patch(test=True)

qdb.sql_connection.TRN.execute()

Expand Down
9 changes: 9 additions & 0 deletions qiita_db/handlers/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ def get(self, name, version):
class CommandListHandler(OauthBaseHandler):
@authenticate_oauth
def post(self, name, version):
"""Create new command for a plugin

Parameters
----------
name : str
The name of the plugin
version : str
The version of the plugin
"""
with qdb.sql_connection.TRN:
plugin = _get_plugin(name, version)

Expand Down
2 changes: 1 addition & 1 deletion qiita_db/handlers/processing_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def post(self, job_id):
class ActiveStepHandler(OauthBaseHandler):
@authenticate_oauth
def post(self, job_id):
"""Changes the current exectuion step of the given job
"""Changes the current execution step of the given job

Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion qiita_db/processing_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ def _update_children(self, mapping):
params, pending = qdb.sql_connection.TRN.execute_fetchflatten()
for pname, out_name in viewitems(pending[self.id]):
a_id = new_map[out_name]
params[pname] = a_id
params[pname] = str(a_id)
del pending[self.id]
# Link the input artifact with the child job
qdb.sql_connection.TRN.add(sql_link, [a_id, c.id])
Expand Down
99 changes: 62 additions & 37 deletions qiita_db/study.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
# -----------------------------------------------------------------------------

from __future__ import division
from collections import defaultdict
from future.utils import viewitems
from copy import deepcopy
from itertools import chain
Expand All @@ -43,9 +44,6 @@
import qiita_db as qdb


_VALID_EBI_STATUS = ('not submitted', 'submitting', 'submitted')


class Study(qdb.base.QiitaObject):
r"""Study object to access to the Qiita Study information

Expand Down Expand Up @@ -81,8 +79,7 @@ class Study(qdb.base.QiitaObject):
_table = "study"
_portal_table = "study_portal"
# The following columns are considered not part of the study info
_non_info = frozenset(["email", "study_title", "ebi_submission_status",
"ebi_study_accession"])
_non_info = frozenset(["email", "study_title", "ebi_study_accession"])

def _lock_non_sandbox(self):
"""Raises QiitaDBStatusError if study is non-sandboxed"""
Expand Down Expand Up @@ -212,10 +209,19 @@ def get_info(cls, study_ids=None, info_cols=None):
args.append(tuple(study_ids))

qdb.sql_connection.TRN.add(sql, args)
res = qdb.sql_connection.TRN.execute_fetchindex()
if study_ids is not None and len(res) != len(study_ids):
rows = qdb.sql_connection.TRN.execute_fetchindex()
if study_ids is not None and len(rows) != len(study_ids):
raise qdb.exceptions.QiitaDBError(
'Non-portal-accessible studies asked for!')

res = []
for r in rows:
r = dict(r)
if 'ebi_study_accession' in info_cols:
r['ebi_submission_status'] = cls(
r['study_id']).ebi_submission_status
res.append(r)

return res

@classmethod
Expand Down Expand Up @@ -825,39 +831,58 @@ def ebi_submission_status(self):
-------
str
The study EBI submission status
"""
with qdb.sql_connection.TRN:
sql = """SELECT ebi_submission_status
FROM qiita.{0}
WHERE study_id = %s""".format(self._table)
qdb.sql_connection.TRN.add(sql, [self.id])
return qdb.sql_connection.TRN.execute_fetchlast()

@ebi_submission_status.setter
def ebi_submission_status(self, value):
"""Sets the study's EBI submission status

Parameters
----------
value : str {%s}
The new EBI submission status

Raises
------
ValueError
If the status is not known
Notes
-----
There are 4 possible states: 'not submitted', 'submitting',
'submitted' & 'failed'. We are going to assume 'not submitted' if the
study doesn't have an accession, 'submitted' if it has an accession,
'submitting' if there are submit_to_EBI jobs running using the study
artifacts, & 'failed' if there are artifacts with failed jobs without
successful ones.
"""
if not (value in _VALID_EBI_STATUS or
value.startswith('failed')):
raise ValueError("Unknown status: %s" % value)
status = 'not submitted'
with qdb.sql_connection.TRN:
sql = """UPDATE qiita.{}
SET ebi_submission_status = %s
WHERE study_id = %s""".format(self._table)
qdb.sql_connection.TRN.add(sql, [value, self.id])
qdb.sql_connection.TRN.execute()

ebi_submission_status.__doc__.format(', '.join(_VALID_EBI_STATUS))
if self.ebi_study_accession:
status = 'submitted'

plugin = qdb.software.Software.from_name_and_version(
'Qiita', 'alpha')
cmd = plugin.get_command('submit_to_EBI')

sql = """SELECT processing_job_id, command_parameters->>'artifact',
processing_job_status
FROM qiita.processing_job
LEFT JOIN qiita.processing_job_status
USING (processing_job_status_id)
WHERE command_parameters->>'artifact' IN (
SELECT artifact_id::text
FROM qiita.study_artifact
WHERE study_id = {0}) AND command_id = {1}""".format(
self._id, cmd.id)
qdb.sql_connection.TRN.add(sql)
jobs = defaultdict(dict)
for info in qdb.sql_connection.TRN.execute_fetchindex():
jid, aid, js = info
jobs[js][aid] = jid

if 'queued' in jobs or 'running' in jobs:
status = 'submitting'
elif 'error' in jobs:
aids_error = []
aids_other = []
for s, aids in jobs.items():
for aid in aids.keys():
if s == 'error':
aids_error.append(aid)
else:
aids_other.append(aid)
difference = set(aids_error) - set(aids_other)
if difference:
status = ('Some artifact submissions failed: %s' %
', '.join(map(str, list(difference))))

return status

@property
def tags(self):
Expand Down
4 changes: 4 additions & 0 deletions qiita_db/support_files/patches/64.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- March 7, 2018
-- delete ebi_submission_status from study

ALTER TABLE qiita.study DROP ebi_submission_status;
Loading