Skip to content

Commit

Permalink
Code cleaning + docstring consolidation
Browse files Browse the repository at this point in the history
  • Loading branch information
paulstretenowich committed Nov 21, 2023
1 parent 66e1944 commit 620fdf4
Showing 1 changed file with 23 additions and 32 deletions.
55 changes: 23 additions & 32 deletions project_tracking/api/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
"""

Expand All @@ -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 <project>
Query:
Expand Down Expand Up @@ -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 <project>
"""

Expand Down Expand Up @@ -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 <project>
"""

Expand Down Expand Up @@ -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 <project>
Query:
Expand Down Expand Up @@ -276,19 +280,19 @@ 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 <project>
We also accept POST data with comma separeted list
metric_name = <NAME> [,NAME] [...]
readset_name = <NAME> [,NAME] [...]
sample_name = <NAME> [,NAME] [...]
patient_name = <NAME> [,NAME] [...]
return: selected metrics, belonging to <project>
Query:
(deliverable): Default (None)
The deliverable query allows to get all metrics labelled as deliverable
Expand Down Expand Up @@ -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 <sample_id>
"""

Expand Down Expand Up @@ -427,21 +432,14 @@ def digest_pair_file(project_id: str):
return db_action.digest_pair_file(project_id=project_id, digest_data=ingest_data)


@bp.route('/<string:project>/ingest_run_processing', methods=['GET', 'POST'])
@bp.route('/<string:project>/ingest_run_processing', methods=['POST'])
@convcheck_project
def ingest_run_processing(project_id: str):
"""
POST: json describing run processing
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)
Expand Down Expand Up @@ -480,21 +478,14 @@ 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('/<string:project>/ingest_genpipes', methods=['GET', 'POST'])
@bp.route('/<string:project>/ingest_genpipes', methods=['POST'])
@convcheck_project
def ingest_genpipes(project_id: str):
"""
POST: json describing genpipes analysis
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)
Expand Down

0 comments on commit 620fdf4

Please sign in to comment.