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
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
23 changes: 0 additions & 23 deletions qiita_db/test/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,29 +211,6 @@ def tearDown(self):
if exists(fp):
remove(fp)

def test_load_parameters_from_cmd_error(self):
with self.assertRaises(qdb.exceptions.QiitaDBUnknownIDError):
qdb.commands.load_parameters_from_cmd(
"test", self.fp, 20000)

def test_load_parameters_from_cmd_error_format(self):
with self.assertRaises(ValueError):
qdb.commands.load_parameters_from_cmd(
"test", self.fp_wrong, 1)

def test_load_parameters_from_cmd(self):
new = qdb.commands.load_parameters_from_cmd(
"test", self.fp, 1)
obs = new.values
exp = {"barcode_type": "hamming_8", "max_bad_run_length": "3",
"phred_offset": "auto", "max_barcode_errors": "1.5",
"min_per_read_length_fraction": "0.75",
"phred_quality_threshold": "3", "sequence_max_n": "0",
"rev_comp": "False", "rev_comp_barcode": "False",
"rev_comp_mapping_barcodes": "False",
"sequence_max_n": "0"}
self.assertEqual(obs, exp)


@qiita_test_checker()
class TestPatch(TestCase):
Expand Down
4 changes: 0 additions & 4 deletions qiita_pet/handlers/auth_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# -----------------------------------------------------------------------------

from tornado.escape import url_escape, json_encode
from tornado.web import HTTPError

from qiita_pet.handlers.base_handlers import BaseHandler
from qiita_core.qiita_settings import qiita_config, r_client
Expand Down Expand Up @@ -106,9 +105,6 @@ def get(self):

@execute_as_transaction
def post(self):
if r_client.get('maintenance') is not None:
raise HTTPError(503, reason="Site is down for maintenance")

username = self.get_argument("username", "").strip().lower()
passwd = self.get_argument("password", "")
nextpage = self.get_argument("next", None)
Expand Down
9 changes: 1 addition & 8 deletions qiita_pet/templates/sitebase.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{% from qiita_core.util import get_qiita_version, get_release_info %}
{% from qiita_pet import allowed_min_browser_versions %}
{% from qiita_pet.portal import portal_styling %}
{% set maintenance = r_client.get('maintenance') %}
{% set sysmessage = r_client.get('sysmessage') %}
{% set user = current_user %}
{% set qiita_version, qiita_sha = get_qiita_version() %}
Expand All @@ -13,11 +12,7 @@
{% set level = 'info' %}
{% end %}
{% set message = globals().get('message', '') %}
{% if maintenance is not None %}
{# maintenance mode takes precedence #}
{% set level = 'danger' %}
{% set message = maintenance %}
{% elif sysmessage is not None %}
{% if sysmessage is not None %}
{# since this is a systemwide message, allow regular messages as well #}
{% set message = sysmessage + "<br />" + str(message) %}
{% end %}
Expand Down Expand Up @@ -427,7 +422,6 @@
</li>
</ul>
<!-- otherwise show the login form -->
{% elif maintenance is None %}
<ul class="nav navbar-nav">
<li>
<a href="{% raw qiita_config.portal_dir %}/auth/forgot/">Forgot Password</a>
Expand All @@ -445,7 +439,6 @@
</div>
<button tabindex="3" type="submit" class="btn btn-success">Sign in</button>
</form>
{% end %}
<ul class="nav navbar-nav">
<!-- generic elements -->
<li class="dropdown">
Expand Down
20 changes: 0 additions & 20 deletions qiita_pet/test/test_user_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

from unittest import main

from qiita_core.qiita_settings import r_client

from qiita_pet.test.tornado_test_base import TestHandlerBase


Expand All @@ -33,24 +31,6 @@ def test_post_password(self):
response = self.post('/profile/', post_args)
self.assertEqual(response.code, 200)

def test_post_select_samples(self):
# just making sure that the key is not set in redis
r_client.delete('maintenance')
response = self.get('/auth/reset/')
self.assertEqual(response.code, 200)
self.assertIn(('<label for="newpass2" class="col-sm-2 '
'control-label">Repeat New Password'
'</label>'), response.body)

# not displaying due to maintenance
r_client.set('maintenance', 'This is my error message')
response = self.get('/auth/reset/')
self.assertEqual(response.code, 200)
self.assertNotIn(('<label for="newpass2" class="col-sm-2 '
'control-label">Repeat New Password'
'</label>'), response.body)
r_client.delete('maintenance')

def test_post_profile(self):
post_args = {
'action': ['profile'],
Expand Down
137 changes: 0 additions & 137 deletions scripts/qiita
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,11 @@ def plugins():
pass


# The private group holds commands that should never be called by the user
# since they are used internally by Qiita to be able to distribute compute
@qiita.group()
def private():
pass


@ware.group()
def ebi():
pass


@db.group()
def portal():
pass

# #############################################################################
# DB COMMANDS
# #############################################################################
Expand Down Expand Up @@ -165,23 +154,6 @@ def load_artifact(fp, fp_type, artifact_type, prep_template, parents,
click.echo("Artifact %s successfully created" % artifact.id)


@db.command()
@click.option('--fp', required=True, type=click.Path(resolve_path=True,
readable=True, exists=True), multiple=True,
help='Path to the artifact files. This option can be used '
'multiple times if there are multiple artifact files.')
@click.option('--fp_type', required=True, multiple=True, help='Describes the '
'contents of the file. Pass one fp_type per fp.',
type=click.Choice(qdb.util.get_filepath_types().keys()))
@click.option('--artifact_id', required=True,
help="The artifact to update",
type=click.IntRange(1))
def update_artifact(fp, fp_type, artifact_id):
"""Updates an artifact from the database"""
artifact = qdb.commands.update_artifact_from_cmd(fp, fp_type, artifact_id)
click.echo("Artifact %s successfully updated" % artifact.id)


@db.command()
@click.argument('fp', required=True,
type=click.Path(resolve_path=True, readable=True, exists=True))
Expand Down Expand Up @@ -210,96 +182,10 @@ def load_prep_template(fp, study, data_type):
% prep_template.id)


@db.command()
@click.option('--name', required=True, type=str,
help='The name of the new reference database')
@click.option('--version', required=True, type=str,
help='The version of the reference database')
@click.option('--seq_fp', required=True,
type=click.Path(resolve_path=True, readable=True, exists=True),
help="Path to the reference sequences file")
@click.option('--tax_fp', required=False,
type=click.Path(resolve_path=True, readable=True, exists=True),
help="Path to the reference taxonomy file")
@click.option('--tree_fp', required=False,
type=click.Path(resolve_path=True, readable=True, exists=True),
help="Path to the reference tree file")
def load_reference_db(name, version, seq_fp, tax_fp, tree_fp):
"""Loads a reference db to the database"""
reference = qdb.reference.Reference.create(
name, version, seq_fp, tax_fp, tree_fp)
click.echo("Reference db successfully added to the database with id %s"
% reference.id)


@db.command()
@click.argument('fp', required=True,
type=click.Path(resolve_path=True, readable=True, exists=True))
@click.option('--cmd-id', required=True,
type=click.IntRange(1, None),
help='The command to add the parameter set')
@click.option('--name', required=True, type=str,
help='The name of the parameters set')
def load_parameters(fp, cmd_id, name):
"""Loads a parameter set to the database"""
param = qdb.commands.load_parameters_from_cmd(name, fp, cmd_id)
click.echo("Parameters successfully added to the command %s with id %s"
% (cmd_id, param.id))


# #############################################################################
# PORTAL COMMANDS
# #############################################################################


@portal.command(name="add-analyses")
@click.argument('portal', required=True,
type=click.Choice(qdb.portal.Portal.list_portals()))
@click.argument('analyses', required=True, type=int, nargs=-1)
def add_analysis(portal, analyses):
try:
qdb.portal.Portal(portal).add_analyses(analyses)
except qdb.exceptions.QiitaDBError as e:
raise click.BadOptionUsage("analyses", str(e))


@portal.command(name="remove-analyses")
@click.argument('portal', required=True,
type=click.Choice(qdb.portal.Portal.list_portals()))
@click.argument('analyses', required=True, type=int, nargs=-1)
def remove_analysis(portal, analyses):
try:
qdb.portal.Portal(portal).remove_analyses(analyses)
except qdb.exceptions.QiitaDBError as e:
raise click.BadOptionUsage("analyses", str(e))


@portal.command(name="add-studies")
@click.argument('portal', required=True,
type=click.Choice(qdb.portal.Portal.list_portals()))
@click.argument('studies', required=True, type=int, nargs=-1)
def add_study(portal, studies):
try:
qdb.portal.Portal(portal).add_studies(studies)
except qdb.exceptions.QiitaDBError as e:
raise click.BadOptionUsage("studies", str(e))


@portal.command(name="remove-studies")
@click.argument('portal', required=True,
type=click.Choice(qdb.portal.Portal.list_portals()))
@click.argument('studies', required=True, type=int, nargs=-1)
def remove_study(portal, studies):
try:
qdb.portal.Portal(portal).remove_studies(studies)
except qdb.exceptions.QiitaDBError as e:
raise click.BadOptionUsage("studies", str(e))

# #############################################################################
# EBI COMMANDS
# #############################################################################


@ebi.command()
@click.option('--preprocessed_data_id', required=True, type=int)
@click.option('--action', type=click.Choice(EBISubmission.valid_ebi_actions),
Expand All @@ -317,21 +203,6 @@ def submit(preprocessed_data_id, action, send):
# MAINTENANCE COMMANDS
# #############################################################################


@maintenance.command()
@click.option('--time', required=True, type=int,
help='The amount of time to lock the site, in hours')
@click.option('--message', required=True, type=str,
help="Message to show users")
def lock(message, time):
r_client.setex('maintenance', message, time * 60 * 60)


@maintenance.command()
def unlock():
r_client.delete('maintenance')


@maintenance.command()
@click.option('--time', required=True, type=int,
help='The amount of time to show message, in hours')
Expand All @@ -355,16 +226,8 @@ def clear_sysmessage():

@maintenance.command()
def status():
maint_status = r_client.get('maintenance')
sys_status = r_client.get('sysmessage')

if maint_status is None:
click.echo("Site is not in maintenance mode")
else:
click.echo("Site is in maintenance mode:")
click.echo(maint_status)
click.echo(r_client.ttl('maintenance'), "seconds remaining")

if sys_status is None:
click.echo("Site has no system message")
else:
Expand Down
16 changes: 1 addition & 15 deletions test_data_studies/commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,10 @@ for i in ${studies[@]}; do
pt_id=`echo -e "${output}" | cut -d " " -f 10`
echo "Ok"

# Loading raw data
echo "\tloading raw data... "
echo -e ">seq\nAAAA" > temp/seqs.fna
output="`qiita db load_artifact --fp temp/seqs.fna --fp_type raw_forward_seqs --artifact_type FASTQ --prep_template $pt_id`"
raw_id=`echo -e "${output}" | cut -d " " -f 2`
echo "Ok"

# Loading preprocessed data
echo "\tloading preprocessed data... "
echo -e ">seq\nAAAA" > temp/seqs.fna
output=`qiita db load_artifact --artifact_type FASTA_Sanger --dflt_params 1 --fp temp/ --fp_type preprocessed_fasta --parents ${raw_id}`
ppd_id=`echo -e "${output}" | cut -d " " -f 2`
echo "Ok"

# Loading processed data
echo "\tloading processed data... "
cp $otu_table ${otu_table}_backup
output="`qiita db load_artifact --artifact_type BIOM --fp $otu_table --fp_type biom --dflt_params 2 --parents ${ppd_id}`"
output="`qiita db load_artifact --artifact_type BIOM --fp $otu_table --fp_type biom --prep_template $pt_id`"
pd_id=`echo -e "${output}" | cut -d " " -f 2`
mv ${otu_table}_backup $otu_table
echo "Ok"
Expand Down