Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #23

Merged
merged 20 commits into from
Jan 15, 2024
Merged

Dev #23

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
588803a
Adding digest_unanalyzed route + debug Operation being linked to Read…
paulstretenowich Oct 19, 2023
d262f87
Debug missing arg
paulstretenowich Oct 19, 2023
d91dcfc
Using project rather than project_name or project_id in routes - test 1
paulstretenowich Oct 26, 2023
8a982ee
Adding project converter/checker
paulstretenowich Oct 31, 2023
83bc30c
Debug pytest
paulstretenowich Oct 31, 2023
84bbdc0
Adding if to avoid failure if project_name in json set to null
paulstretenowich Nov 2, 2023
85e6a2f
Small fix
paulstretenowich Nov 9, 2023
e6389d2
Need to convert project_id from name_to_id from list of int into str
paulstretenowich Nov 9, 2023
bc43e8a
Merge branch 'main' into dev
paulstretenowich Nov 10, 2023
d935efd
Adding a new attribute for experiment: nucleic_acid_type
paulstretenowich Nov 20, 2023
dae290a
Debug
paulstretenowich Nov 21, 2023
66e1944
Consolidating docstring + adding experiment_nucleic_acid_type to dige…
paulstretenowich Nov 21, 2023
620fdf4
Code cleaning + docstring consolidation
paulstretenowich Nov 21, 2023
8674a8a
Changing error message
paulstretenowich Nov 29, 2023
0f80cf8
Accepting metric without flag set
paulstretenowich Nov 29, 2023
24319cb
Allowing job_status being null if job hasn't been submitted
paulstretenowich Nov 29, 2023
2375fdd
Skipping null job during ingesting genpipes as we don't want files no…
paulstretenowich Nov 29, 2023
3a12631
Build and push Image. Dockefile to Containerfile
poquirion Dec 19, 2023
476ae6e
typo in tag
poquirion Dec 19, 2023
556206e
typo in action
poquirion Dec 19, 2023
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
38 changes: 36 additions & 2 deletions .github/workflows/run_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ on:
- 'main'
- 'dev'

jobs:
build:
tags:
- '[0-9]+.[0-9]+.[0-9]+'

env:
REGISTRY_USER: c3genomics+github_pusher
IMAGE_REGISTRY: quay.io
REGISTRY_PASSWORD: ${{ secrets.QUAY_ROBOT_TOKEN }}
IMAGE: c3genomics/project_tracking

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down Expand Up @@ -41,3 +49,29 @@ jobs:
- name: Test with pytest
run: |
pytest -v
build:
needs: test
if: startsWith(github.ref, 'refs/tags')
name: Build image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: set tag
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Buildah Action
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE }}
tags: ${{ env.RELEASE_VERSION }} latest_release
containerfiles: ./Containerfile
- name: Push to repo
uses: redhat-actions/push-to-registry@v2
with:
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
registry: ${{ env.IMAGE_REGISTRY }}
image: ${{ env.IMAGE }}
tags: ${{ env.RELEASE_VERSION }} latest_release
- name: Print image url
run: echo "Image pushed to ${{ steps.push-to-repo.outputs.registry-paths }}"

3 changes: 2 additions & 1 deletion Dockerfile → Containerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM fedora:36
FROM fedora:39
MAINTAINER P-O Quirion [email protected]
ENV APP=project_tracking

RUN mkdir /app /sqlite
Expand Down
89 changes: 40 additions & 49 deletions project_tracking/api/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def wrap(*args, project=None, **kwargs):
all_available = [f"id: {project.id}, name: {project.name}" for project in db_action.projects()]
project_id = {"DB_ACTION_WARNING": f"Requested Project '{project}' doesn't exist. Please try again with one of the following: {all_available}"}
else:
project_id = db_action.name_to_id("Project", project.upper())
project_id = str(db_action.name_to_id("Project", project.upper())[0])
if not project_id:
all_available = [f"id: {project.id}, name: {project.name}" for project in db_action.projects()]
project_id = {"DB_ACTION_WARNING": f"Requested Project '{project}' doesn't exist. Please try again with one of the following: {all_available}"}
Expand All @@ -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,8 +82,9 @@ 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"
return: list all patient or selected patient that are also par of <project>
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:
(pair, tumor): Default (None, true)
Expand All @@ -93,7 +95,7 @@ def patients(project_id: str, patient_id: str = None):
Return: a subset of patient who have Tumor=False & Tumor=True samples
(false, true):
return: a subset of patient who only have Tumor=True samples
(false, true):
(false, false):
return: a subset of patient who only have Tumor=false samples
"""

Expand Down Expand Up @@ -144,8 +146,9 @@ 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 provides, all sample are returned
return: all or selected sample that are in sample_id and part of project
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>
"""

query = request.args
Expand Down Expand Up @@ -174,8 +177,9 @@ 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
return: selected readsets that are in sample_id and part of project
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>
"""

query = request.args
Expand Down Expand Up @@ -207,12 +211,12 @@ 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

return: selected files
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:
(deliverable): Default (None)
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

We also accespt POST data with comma separeted list
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

Query:
(deliverable): Default (None)
The deliverable query allows to get all metrics labelled as deliverable
Expand Down Expand Up @@ -360,8 +364,9 @@ 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"
return: readsets for selected sample_id
GET:
sample_id: uses the form "1,3-8,9"
return: selected readsets belonging to <sample_id>
"""

query = request.args
Expand All @@ -382,14 +387,14 @@ def readsets_from_samples(project_id: str, sample_id: str):

action_output = db_action.readsets(project_id, sample_id)

return sanity_check("Metric", action_output)
return sanity_check("Readset", action_output)


@bp.route('/<string:project>/digest_readset_file', methods=['POST'])
@convcheck_project
def digest_readset_file(project_id: str):
"""
POST: list of Readset/Sample Name or id
POST: json holding the list of Patient/Sample/Readset Name or id AND location endpoint + experiment nucleic_acid_type
return: all information to create a "Genpipes readset file"
"""

Expand All @@ -410,7 +415,7 @@ def digest_readset_file(project_id: str):
@convcheck_project
def digest_pair_file(project_id: str):
"""
POST: list of Readset/Sample Name or id
POST: json holding the list of Patient/Sample/Readset Name or id AND location endpoint + experiment nucleic_acid_type
return: all information to create a "Genpipes pair file"
"""

Expand All @@ -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 All @@ -454,7 +452,7 @@ def ingest_run_processing(project_id: str):


if ingest_data[vc.PROJECT_NAME]:
project_id_from_name = db_action.name_to_id("Project", ingest_data[vc.PROJECT_NAME].upper())
project_id_from_name = str(db_action.name_to_id("Project", ingest_data[vc.PROJECT_NAME].upper())[0])
if project_id != project_id_from_name:
return {"DB_ACTION_WARNING": f"Requested Project {project_id_from_name} in the input json is not matching the Project in the route {project_id}"}

Expand All @@ -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
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 All @@ -507,7 +498,7 @@ def ingest_genpipes(project_id: str):


if ingest_data[vc.PROJECT_NAME]:
project_id_from_name = db_action.name_to_id("Project", ingest_data[vc.PROJECT_NAME].upper())
project_id_from_name = str(db_action.name_to_id("Project", ingest_data[vc.PROJECT_NAME].upper())[0])
if project_id != project_id_from_name:
return {"DB_ACTION_WARNING": f"Requested Project {project_id_from_name} in the input json is not matching the Project in the route {project_id}"}

Expand All @@ -520,8 +511,8 @@ def ingest_genpipes(project_id: str):
@convcheck_project
def digest_unanalyzed(project_id: str):
"""
POST: list of Readset/Sample Name or id
return: Readsets or Samples unanalyzed
POST: json holding the list of Sample/Readset Name or id AND location endpoint + experiment nucleic_acid_type
return: Samples/Readsets unanalyzed with location endpoint + experiment nucleic_acid_type
"""
if request.method == 'POST':
try:
Expand Down
Loading