From 620fdf44a9aea3e01cd8772df8e3c471d2e7a16b Mon Sep 17 00:00:00 2001 From: Paul Stretenowich Date: Tue, 21 Nov 2023 16:56:11 -0500 Subject: [PATCH] Code cleaning + docstring consolidation --- project_tracking/api/project.py | 55 ++++++++++++++------------------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/project_tracking/api/project.py b/project_tracking/api/project.py index 6591009..98d218f 100644 --- a/project_tracking/api/project.py +++ b/project_tracking/api/project.py @@ -64,7 +64,8 @@ def sanity_check(item, action_output): @convcheck_project def projects(project_id: str = None): """ - project: uses the form "/project/1" for project ID and "/project/name" for project name + GET: + project: uses the form "/project/1" for project ID and "/project/name" for project name return: list of all the details of the poject with name "project_name" or ID "project_id" """ @@ -81,7 +82,8 @@ def projects(project_id: str = None): @convcheck_project def patients(project_id: str, patient_id: str = None): """ - patient_id: uses the form "1,3-8,9", if not provided all patients are returned + GET: + patient_id: uses the form "1,3-8,9", if not provided all patients are returned return: list all patients or selected patients, belonging to Query: @@ -144,7 +146,8 @@ def patients(project_id: str, patient_id: str = None): @convcheck_project def samples(project_id: str, sample_id: str = None): """ - sample_id: uses the form "1,3-8,9", if not provided all samples are returned + GET: + sample_id: uses the form "1,3-8,9", if not provided all samples are returned return: list all patients or selected samples, belonging to """ @@ -174,7 +177,8 @@ def samples(project_id: str, sample_id: str = None): @convcheck_project def readsets(project_id: str, readset_id: str=None): """ - readset_id: uses the form "1,3-8,9", if not provided all readsets are returned + GET: + readset_id: uses the form "1,3-8,9", if not provided all readsets are returned return: list all patients or selected readsets, belonging to """ @@ -207,11 +211,11 @@ def readsets(project_id: str, readset_id: str=None): @convcheck_project def files(project_id: str, patient_id: str=None, sample_id: str=None, readset_id: str=None, file_id: str=None): """ - file_id: uses the form "1,3-8,9". Select file by ids - patient_id: uses the form "1,3-8,9". Select file by patient ids - sample_id: uses the form "1,3-8,9". Select file by sample ids - redeaset_id: uses the form "1,3-8,9". Select file by readset ids - + GET: + file_id: uses the form "1,3-8,9". Select file by ids + patient_id: uses the form "1,3-8,9". Select file by patient ids + sample_id: uses the form "1,3-8,9". Select file by sample ids + redeaset_id: uses the form "1,3-8,9". Select file by readset ids return: selected files, belonging to Query: @@ -276,10 +280,12 @@ def files(project_id: str, patient_id: str=None, sample_id: str=None, readset_id @convcheck_project def metrics(project_id: str, patient_id: str=None, sample_id: str=None, readset_id: str=None, metric_id: str=None): """ - metric_id: uses the form "1,3-8,9". Select metric by ids - patient_id: uses the form "1,3-8,9". Select metric by patient ids - sample_id: uses the form "1,3-8,9". Select metric by sample ids - redeaset_id: uses the form "1,3-8,9". Select metric by readset ids + GET: + metric_id: uses the form "1,3-8,9". Select metric by ids + patient_id: uses the form "1,3-8,9". Select metric by patient ids + sample_id: uses the form "1,3-8,9". Select metric by sample ids + redeaset_id: uses the form "1,3-8,9". Select metric by readset ids + return: selected metrics, belonging to We also accept POST data with comma separeted list metric_name = [,NAME] [...] @@ -287,8 +293,6 @@ def metrics(project_id: str, patient_id: str=None, sample_id: str=None, readset_ sample_name = [,NAME] [...] patient_name = [,NAME] [...] - return: selected metrics, belonging to - Query: (deliverable): Default (None) The deliverable query allows to get all metrics labelled as deliverable @@ -360,7 +364,8 @@ def metrics(project_id: str, patient_id: str=None, sample_id: str=None, readset_ @convcheck_project def readsets_from_samples(project_id: str, sample_id: str): """ - sample_id: uses the form "1,3-8,9" + GET: + sample_id: uses the form "1,3-8,9" return: selected readsets belonging to """ @@ -427,7 +432,7 @@ def digest_pair_file(project_id: str): return db_action.digest_pair_file(project_id=project_id, digest_data=ingest_data) -@bp.route('//ingest_run_processing', methods=['GET', 'POST']) +@bp.route('//ingest_run_processing', methods=['POST']) @convcheck_project def ingest_run_processing(project_id: str): """ @@ -435,13 +440,6 @@ def ingest_run_processing(project_id: str): return: The Operation object """ - # Is this if required? - if request.method == 'GET': - return abort( - 405, - "Use post method to ingest runs" - ) - if request.method == 'POST': try: ingest_data = request.get_json(force=True) @@ -480,7 +478,7 @@ def ingest_transfer(project_id: str): return [i.flat_dict for i in db_action.ingest_transfer(project_id=project_id, ingest_data=ingest_data)] -@bp.route('//ingest_genpipes', methods=['GET', 'POST']) +@bp.route('//ingest_genpipes', methods=['POST']) @convcheck_project def ingest_genpipes(project_id: str): """ @@ -488,13 +486,6 @@ def ingest_genpipes(project_id: str): return: The Operation object and Jobs associated """ - # Is this if required? - if request.method == 'GET': - return abort( - 405, - "Use post method to ingest genpipes analysis" - ) - if request.method == 'POST': try: ingest_data = request.get_json(force=True)