Skip to content

Commit 7659c88

Browse files
antgonzaElDeveloper
authored andcommitted
fix #1999 (#2514)
* fix #1999 * fix template error * rm maintenance conditional * some improvements * fix #1053
1 parent 82c546a commit 7659c88

File tree

10 files changed

+13
-251
lines changed

10 files changed

+13
-251
lines changed

qiita_db/commands.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -186,45 +186,6 @@ def load_prep_template_from_cmd(prep_temp_path, study_id, data_type):
186186
prep_temp, qdb.study.Study(study_id), data_type)
187187

188188

189-
def load_parameters_from_cmd(name, fp, cmd_id):
190-
"""Add a new parameters entry on `table`
191-
192-
Parameters
193-
----------
194-
fp : str
195-
The filepath to the parameters file
196-
cmd_id : int
197-
The command to add the new default parameter set
198-
199-
Returns
200-
-------
201-
qiita_db.software.DefaultParameters
202-
The newly parameter set object created
203-
204-
Raises
205-
------
206-
ValueError
207-
If the table does not exists on the DB
208-
If the fp is not correctly formatted
209-
210-
Notes
211-
-----
212-
`fp` should be a tab-delimited text file following this format:
213-
parameter_1<TAB>value
214-
parameter_2<TAB>value
215-
...
216-
"""
217-
cmd = qdb.software.Command(cmd_id)
218-
219-
try:
220-
params = dict(tuple(l.strip().split('\t')) for l in open(fp, 'U'))
221-
except ValueError:
222-
raise ValueError("The format of the parameters files is not correct. "
223-
"The format is PARAMETER_NAME<tab>VALUE")
224-
225-
return qdb.software.DefaultParameters.create(name, cmd, **params)
226-
227-
228189
def update_artifact_from_cmd(filepaths, filepath_types, artifact_id):
229190
"""Updates the artifact `artifact_id` with the given files
230191

qiita_db/test/test_commands.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -211,29 +211,6 @@ def tearDown(self):
211211
if exists(fp):
212212
remove(fp)
213213

214-
def test_load_parameters_from_cmd_error(self):
215-
with self.assertRaises(qdb.exceptions.QiitaDBUnknownIDError):
216-
qdb.commands.load_parameters_from_cmd(
217-
"test", self.fp, 20000)
218-
219-
def test_load_parameters_from_cmd_error_format(self):
220-
with self.assertRaises(ValueError):
221-
qdb.commands.load_parameters_from_cmd(
222-
"test", self.fp_wrong, 1)
223-
224-
def test_load_parameters_from_cmd(self):
225-
new = qdb.commands.load_parameters_from_cmd(
226-
"test", self.fp, 1)
227-
obs = new.values
228-
exp = {"barcode_type": "hamming_8", "max_bad_run_length": "3",
229-
"phred_offset": "auto", "max_barcode_errors": "1.5",
230-
"min_per_read_length_fraction": "0.75",
231-
"phred_quality_threshold": "3", "sequence_max_n": "0",
232-
"rev_comp": "False", "rev_comp_barcode": "False",
233-
"rev_comp_mapping_barcodes": "False",
234-
"sequence_max_n": "0"}
235-
self.assertEqual(obs, exp)
236-
237214

238215
@qiita_test_checker()
239216
class TestPatch(TestCase):

qiita_pet/handlers/auth_handlers.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# -----------------------------------------------------------------------------
88

99
from tornado.escape import url_escape, json_encode
10-
from tornado.web import HTTPError
1110

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

107106
@execute_as_transaction
108107
def post(self):
109-
if r_client.get('maintenance') is not None:
110-
raise HTTPError(503, reason="Site is down for maintenance")
111-
112108
username = self.get_argument("username", "").strip().lower()
113109
passwd = self.get_argument("password", "")
114110
nextpage = self.get_argument("next", None)

qiita_pet/templates/change_lost_pass.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{%end%}
99

1010
{% block content %}
11-
{% if level != 'danger' and maintenance is None %}
11+
{% if level != 'danger' %}
1212
<div style='width: 50%;'>
1313
<h1>Password Reset</h1>
1414
<h3>Enter new password below</h3>

qiita_pet/templates/ebi_submission.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ <h1>Submission summary for study: <b>{{study_title}}</b></h1>
1111
and prep templates which will be submitted to EBI.
1212
</div>
1313

14-
{% if level != 'danger' and maintenance is None %}
14+
{% if level != 'danger' %}
1515
<table class="table">
1616
{% for category, summary in stats %}
1717
<tr>
@@ -27,7 +27,7 @@ <h1>Submission summary for study: <b>{{study_title}}</b></h1>
2727
The investigation type is: <b>{{investigation_type}}</b>
2828
<br/><br/>
2929
{% if investigation_type %}
30-
{% if level != 'danger' and maintenance is None %}
30+
{% if level != 'danger' %}
3131
{% if allow_submission %}
3232
<br/>
3333
What kind of submission do you want to do?

qiita_pet/templates/sitebase.html

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
{% from qiita_core.util import get_qiita_version, get_release_info %}
33
{% from qiita_pet import allowed_min_browser_versions %}
44
{% from qiita_pet.portal import portal_styling %}
5-
{% set maintenance = r_client.get('maintenance') %}
65
{% set sysmessage = r_client.get('sysmessage') %}
76
{% set user = current_user %}
87
{% set qiita_version, qiita_sha = get_qiita_version() %}
@@ -13,11 +12,7 @@
1312
{% set level = 'info' %}
1413
{% end %}
1514
{% set message = globals().get('message', '') %}
16-
{% if maintenance is not None %}
17-
{# maintenance mode takes precedence #}
18-
{% set level = 'danger' %}
19-
{% set message = maintenance %}
20-
{% elif sysmessage is not None %}
15+
{% if sysmessage is not None %}
2116
{# since this is a systemwide message, allow regular messages as well #}
2217
{% set message = sysmessage + "<br />" + str(message) %}
2318
{% end %}
@@ -427,7 +422,7 @@
427422
</li>
428423
</ul>
429424
<!-- otherwise show the login form -->
430-
{% elif maintenance is None %}
425+
{% else %}
431426
<ul class="nav navbar-nav">
432427
<li>
433428
<a href="{% raw qiita_config.portal_dir %}/auth/forgot/">Forgot Password</a>

qiita_pet/templates/vamps_submission.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ <h1>Submission summary for study: <b>{{study_title}}</b></h1>
1010
and prep templates which will be submitted to VAMPS.
1111
</div>
1212

13-
{% if level != 'danger' and maintenance is None %}
13+
{% if level != 'danger' %}
1414
<table class="table">
1515
{% for category, summary in stats %}
1616
<tr>
@@ -26,7 +26,7 @@ <h1>Submission summary for study: <b>{{study_title}}</b></h1>
2626
The investigation type is: <b>{{investigation_type}}</b>
2727
<br/><br/>
2828

29-
{% if level != 'danger' and maintenance is None %}
29+
{% if level != 'danger' %}
3030
{% if allow_submission %}
3131
<input type="submit" class="btn btn-primary" value="Submit to VAMPS">
3232
{% else %}

qiita_pet/test/test_user_handlers.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
from unittest import main
1010

11-
from qiita_core.qiita_settings import r_client
12-
1311
from qiita_pet.test.tornado_test_base import TestHandlerBase
1412

1513

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

36-
def test_post_select_samples(self):
37-
# just making sure that the key is not set in redis
38-
r_client.delete('maintenance')
39-
response = self.get('/auth/reset/')
40-
self.assertEqual(response.code, 200)
41-
self.assertIn(('<label for="newpass2" class="col-sm-2 '
42-
'control-label">Repeat New Password'
43-
'</label>'), response.body)
44-
45-
# not displaying due to maintenance
46-
r_client.set('maintenance', 'This is my error message')
47-
response = self.get('/auth/reset/')
48-
self.assertEqual(response.code, 200)
49-
self.assertNotIn(('<label for="newpass2" class="col-sm-2 '
50-
'control-label">Repeat New Password'
51-
'</label>'), response.body)
52-
r_client.delete('maintenance')
53-
5434
def test_post_profile(self):
5535
post_args = {
5636
'action': ['profile'],

scripts/qiita

Lines changed: 0 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,11 @@ def plugins():
9090
pass
9191

9292

93-
# The private group holds commands that should never be called by the user
94-
# since they are used internally by Qiita to be able to distribute compute
95-
@qiita.group()
96-
def private():
97-
pass
98-
99-
10093
@ware.group()
10194
def ebi():
10295
pass
10396

10497

105-
@db.group()
106-
def portal():
107-
pass
108-
10998
# #############################################################################
11099
# DB COMMANDS
111100
# #############################################################################
@@ -165,23 +154,6 @@ def load_artifact(fp, fp_type, artifact_type, prep_template, parents,
165154
click.echo("Artifact %s successfully created" % artifact.id)
166155

167156

168-
@db.command()
169-
@click.option('--fp', required=True, type=click.Path(resolve_path=True,
170-
readable=True, exists=True), multiple=True,
171-
help='Path to the artifact files. This option can be used '
172-
'multiple times if there are multiple artifact files.')
173-
@click.option('--fp_type', required=True, multiple=True, help='Describes the '
174-
'contents of the file. Pass one fp_type per fp.',
175-
type=click.Choice(qdb.util.get_filepath_types().keys()))
176-
@click.option('--artifact_id', required=True,
177-
help="The artifact to update",
178-
type=click.IntRange(1))
179-
def update_artifact(fp, fp_type, artifact_id):
180-
"""Updates an artifact from the database"""
181-
artifact = qdb.commands.update_artifact_from_cmd(fp, fp_type, artifact_id)
182-
click.echo("Artifact %s successfully updated" % artifact.id)
183-
184-
185157
@db.command()
186158
@click.argument('fp', required=True,
187159
type=click.Path(resolve_path=True, readable=True, exists=True))
@@ -210,96 +182,10 @@ def load_prep_template(fp, study, data_type):
210182
% prep_template.id)
211183

212184

213-
@db.command()
214-
@click.option('--name', required=True, type=str,
215-
help='The name of the new reference database')
216-
@click.option('--version', required=True, type=str,
217-
help='The version of the reference database')
218-
@click.option('--seq_fp', required=True,
219-
type=click.Path(resolve_path=True, readable=True, exists=True),
220-
help="Path to the reference sequences file")
221-
@click.option('--tax_fp', required=False,
222-
type=click.Path(resolve_path=True, readable=True, exists=True),
223-
help="Path to the reference taxonomy file")
224-
@click.option('--tree_fp', required=False,
225-
type=click.Path(resolve_path=True, readable=True, exists=True),
226-
help="Path to the reference tree file")
227-
def load_reference_db(name, version, seq_fp, tax_fp, tree_fp):
228-
"""Loads a reference db to the database"""
229-
reference = qdb.reference.Reference.create(
230-
name, version, seq_fp, tax_fp, tree_fp)
231-
click.echo("Reference db successfully added to the database with id %s"
232-
% reference.id)
233-
234-
235-
@db.command()
236-
@click.argument('fp', required=True,
237-
type=click.Path(resolve_path=True, readable=True, exists=True))
238-
@click.option('--cmd-id', required=True,
239-
type=click.IntRange(1, None),
240-
help='The command to add the parameter set')
241-
@click.option('--name', required=True, type=str,
242-
help='The name of the parameters set')
243-
def load_parameters(fp, cmd_id, name):
244-
"""Loads a parameter set to the database"""
245-
param = qdb.commands.load_parameters_from_cmd(name, fp, cmd_id)
246-
click.echo("Parameters successfully added to the command %s with id %s"
247-
% (cmd_id, param.id))
248-
249-
250-
# #############################################################################
251-
# PORTAL COMMANDS
252-
# #############################################################################
253-
254-
255-
@portal.command(name="add-analyses")
256-
@click.argument('portal', required=True,
257-
type=click.Choice(qdb.portal.Portal.list_portals()))
258-
@click.argument('analyses', required=True, type=int, nargs=-1)
259-
def add_analysis(portal, analyses):
260-
try:
261-
qdb.portal.Portal(portal).add_analyses(analyses)
262-
except qdb.exceptions.QiitaDBError as e:
263-
raise click.BadOptionUsage("analyses", str(e))
264-
265-
266-
@portal.command(name="remove-analyses")
267-
@click.argument('portal', required=True,
268-
type=click.Choice(qdb.portal.Portal.list_portals()))
269-
@click.argument('analyses', required=True, type=int, nargs=-1)
270-
def remove_analysis(portal, analyses):
271-
try:
272-
qdb.portal.Portal(portal).remove_analyses(analyses)
273-
except qdb.exceptions.QiitaDBError as e:
274-
raise click.BadOptionUsage("analyses", str(e))
275-
276-
277-
@portal.command(name="add-studies")
278-
@click.argument('portal', required=True,
279-
type=click.Choice(qdb.portal.Portal.list_portals()))
280-
@click.argument('studies', required=True, type=int, nargs=-1)
281-
def add_study(portal, studies):
282-
try:
283-
qdb.portal.Portal(portal).add_studies(studies)
284-
except qdb.exceptions.QiitaDBError as e:
285-
raise click.BadOptionUsage("studies", str(e))
286-
287-
288-
@portal.command(name="remove-studies")
289-
@click.argument('portal', required=True,
290-
type=click.Choice(qdb.portal.Portal.list_portals()))
291-
@click.argument('studies', required=True, type=int, nargs=-1)
292-
def remove_study(portal, studies):
293-
try:
294-
qdb.portal.Portal(portal).remove_studies(studies)
295-
except qdb.exceptions.QiitaDBError as e:
296-
raise click.BadOptionUsage("studies", str(e))
297-
298185
# #############################################################################
299186
# EBI COMMANDS
300187
# #############################################################################
301188

302-
303189
@ebi.command()
304190
@click.option('--preprocessed_data_id', required=True, type=int)
305191
@click.option('--action', type=click.Choice(EBISubmission.valid_ebi_actions),
@@ -317,21 +203,6 @@ def submit(preprocessed_data_id, action, send):
317203
# MAINTENANCE COMMANDS
318204
# #############################################################################
319205

320-
321-
@maintenance.command()
322-
@click.option('--time', required=True, type=int,
323-
help='The amount of time to lock the site, in hours')
324-
@click.option('--message', required=True, type=str,
325-
help="Message to show users")
326-
def lock(message, time):
327-
r_client.setex('maintenance', message, time * 60 * 60)
328-
329-
330-
@maintenance.command()
331-
def unlock():
332-
r_client.delete('maintenance')
333-
334-
335206
@maintenance.command()
336207
@click.option('--time', required=True, type=int,
337208
help='The amount of time to show message, in hours')
@@ -355,16 +226,8 @@ def clear_sysmessage():
355226

356227
@maintenance.command()
357228
def status():
358-
maint_status = r_client.get('maintenance')
359229
sys_status = r_client.get('sysmessage')
360230

361-
if maint_status is None:
362-
click.echo("Site is not in maintenance mode")
363-
else:
364-
click.echo("Site is in maintenance mode:")
365-
click.echo(maint_status)
366-
click.echo(r_client.ttl('maintenance'), "seconds remaining")
367-
368231
if sys_status is None:
369232
click.echo("Site has no system message")
370233
else:

0 commit comments

Comments
 (0)