Skip to content

Commit 709997c

Browse files
committed
use enum
1 parent 54573a0 commit 709997c

4 files changed

Lines changed: 12 additions & 14 deletions

File tree

mmeds/database/database.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,14 +1005,14 @@ def check_study_name(self, study_name):
10051005
""" Verifies the provided study name is valid and not already in use. """
10061006
if not study_name.replace('_', '').isalnum():
10071007
raise StudyNameError("Only alpha numeric characters and '_' are allowed in the study name")
1008-
if MMEDSDoc.objects(study_name=study_name, doc_type='study'):
1008+
if MMEDSDoc.objects(study_name=study_name, doc_type=DocType.STUDY):
10091009
raise StudyNameError(f"Study name {study_name} already in use")
10101010

10111011
def check_sequencing_run_name(self, run_name):
10121012
""" Verifies the provided sequencing run name is valid and not already in use. """
10131013
if not run_name.replace('_', '').isalnum():
10141014
raise StudyNameError("Only alpha-numeric characters and '_' are allowed in the sequencing run name")
1015-
if MMEDSDoc.objects(study_name=run_name, doc_type='sequencing_run'):
1015+
if MMEDSDoc.objects(data_name=run_name, doc_type=DocType.DATA):
10161016
raise StudyNameError(f"Sequencing Run name {run_name} already in use")
10171017

10181018
def get_sequencing_run_locations(self, metadata, user, column=("RawDataProtocol", "RawDataProtocolID")):
@@ -1042,27 +1042,27 @@ def get_sequencing_run_locations(self, metadata, user, column=("RawDataProtocol"
10421042

10431043
def get_all_studies(self):
10441044
""" Return all studies currently stored in the database. """
1045-
return MMEDSDoc.objects(doc_type='study')
1045+
return MMEDSDoc.objects(doc_type=DocType.STUDY)
10461046

10471047
def get_all_analyses(self):
10481048
""" Return all analyses currently stored in the database. """
1049-
return MMEDSDoc.objects(doc_type='analysis')
1049+
return MMEDSDoc.objects(doc_type=DocType.ANALYSIS)
10501050

10511051
def get_all_sequencing_runs(self):
10521052
""" Return all sequencing runs currently stored in the database. """
1053-
return MMEDSDoc.objects(doc_type='sequencing_run')
1053+
return MMEDSDoc.objects(doc_type=DocType.DATA)
10541054

10551055
def get_all_user_sequencing_runs(self, user):
10561056
""" Return all sequencing runs currently stored in the database owned by USER. """
1057-
return MMEDSDoc.objects(doc_type='sequencing_run', owner=user)
1057+
return MMEDSDoc.objects(doc_type=DocType.DATA, owner=user)
10581058

10591059
def get_all_user_studies(self, user):
10601060
""" Return all studies currently stored in the database owned by USER. """
1061-
return MMEDSDoc.objects(doc_type='study', owner=user)
1061+
return MMEDSDoc.objects(doc_type=DocType.STUDY, owner=user)
10621062

10631063
def get_all_analyses_from_study(self, access_code):
10641064
""" Return all studies currently stored in the database. """
1065-
return MMEDSDoc.objects(study_code=access_code, doc_type='analysis')
1065+
return MMEDSDoc.objects(study_code=access_code, doc_type=DocType.ANALYSIS)
10661066

10671067
def check_files(self, access_code):
10681068
""" Check that all files associated with the study actually exist. """
@@ -1076,7 +1076,7 @@ def check_files(self, access_code):
10761076

10771077
def get_metadata_file_location(self, study_name):
10781078
""" Return the metadata.tsv file location for a given study """
1079-
doc = MMEDSDoc.objects(doc_type='study', study_name=study_name).first()
1079+
doc = MMEDSDoc.objects(doc_type=DocType.STUDY, study_name=study_name).first()
10801080
return doc['files']['metadata']
10811081

10821082
def delete_mongo_documents(self):

mmeds/secrets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
EMAIL_PASS = ''
2323
TEST_PASS = 'testpassL33TG@m3r'
2424
TEST_USER_PASS = 'password'
25-
TEST_ROOT_PASS = 'root'
25+
TEST_ROOT_PASS = ''
2626
REUPLOAD_PASS = 'r3Up10@D'
2727
AUTH_KEY = b'F1ndTh3W@tch3r'
2828
WATCHER_PORT = 52953

mmeds/spawn.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ def handle_upload(self, process):
328328
if 'ids' in process[0]:
329329
(ptype, owner, access_code, aliquot_table, id_type, generate_id) = process
330330
p = MetaDataAdder(owner, access_code, aliquot_table, id_type, generate_id, self.testing)
331-
self.db_lock.acquire()
332331

333332
# Add new sequencing run
334333
elif 'run' in process[0]:
@@ -337,7 +336,6 @@ def handle_upload(self, process):
337336

338337
p = DataUploader(new_access_code, username, sequencing_run_name, reads_type,
339338
datafiles, public, self.testing)
340-
self.db_lock.acquire()
341339
# Add new study
342340
else:
343341
Logger.debug(f"length: {len(process)}")

mmeds/tests/unit/test_analysis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from unittest import TestCase
1+
from unittest import TestCase, skip
22
from pathlib import Path
33
import mmeds.config as fig
44
from time import sleep
@@ -47,7 +47,7 @@ def test_b_analysis_init(self):
4747
self.analysis += [Analysis(self.queue, fig.TEST_USER_0, self.analysis_code_1, fig.TEST_CODE_MIXED,
4848
'lefse', 'default', 'test_lefse', self.config_lefse, True, {}, False, threads=2)]
4949

50-
50+
@skip
5151
def test_c_core_pipeline_taxonomic(self):
5252
""" Test running a standard analysis """
5353
# run_analysis() executes analyses synchronously rather than submitting as a job

0 commit comments

Comments
 (0)