Skip to content

Commit

Permalink
Fix merge coflict
Browse files Browse the repository at this point in the history
  • Loading branch information
islean committed Jan 29, 2025
2 parents b44a765 + 8cba7f7 commit b06f1d4
Show file tree
Hide file tree
Showing 386 changed files with 19,573 additions and 8,118 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 64.5.29
current_version = 67.0.9
commit = True
tag = True
tag_name = v{new_version}
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/tests_and_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,8 @@ jobs:
with:
virtualenvs-create: false

- name: Cache dependencies
uses: actions/cache@v4
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('**/poetry.lock') }}

- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: poetry install --no-interaction
run: poetry install --no-interaction --all-extras

- name: Test with Pytest & Coveralls
run: |
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ ENV TRAILBLAZER_SERVICE_ACCOUNT_AUTH_FILE="auth_file"


WORKDIR /home/src/app
COPY pyproject.toml poetry.lock gunicorn.conf.py ./
COPY pyproject.toml poetry.lock gunicorn.conf.py README.md ./

RUN pip install --no-cache-dir poetry \
&& poetry config virtualenvs.create false \
&& poetry install --no-interaction --no-ansi
&& poetry install --no-interaction --no-ansi --no-root

COPY cg ./cg

RUN poetry install --no-interaction --no-ansi

CMD gunicorn \

Check warning on line 36 in Dockerfile

View workflow job for this annotation

GitHub Actions / docker-image-push

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
--config gunicorn.conf.py \
cg.server.auto:app
2 changes: 1 addition & 1 deletion cg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__title__ = "cg"
__version__ = "64.5.29"
__version__ = "67.0.9"
3 changes: 2 additions & 1 deletion cg/apps/hermes/hermes_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def __init__(self, config: dict):
self.process = Process(
binary=config["hermes"]["binary_path"],
)
self.container_path: str = config["hermes"]["container_path"]
self.container_mount_volume = config["hermes"]["container_mount_volume"]

def convert_deliverables(
Expand All @@ -33,7 +34,7 @@ def convert_deliverables(
"run",
"--bind",
self.container_mount_volume,
"/home/proj/stage/singularity_containers/hermes_latest.sif",
self.container_path,
"convert",
"deliverables",
"--workflow",
Expand Down
12 changes: 2 additions & 10 deletions cg/apps/housekeeper/hk.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@

from housekeeper.include import checksum as hk_checksum
from housekeeper.include import include_version
from housekeeper.store.database import (
create_all_tables,
drop_all_tables,
initialize_database,
)
from housekeeper.store.database import create_all_tables, drop_all_tables, initialize_database
from housekeeper.store.models import Archive, Bundle, File, Tag, Version
from housekeeper.store.store import Store
from sqlalchemy.orm import Query
Expand All @@ -27,17 +23,13 @@


class HousekeeperAPI:
"""API to decouple cg code from Housekeeper"""
"""API to decouple cg code from Housekeeper."""

def __init__(self, config: dict) -> None:
initialize_database(config["housekeeper"]["database"])
self._store = Store(config["housekeeper"]["root"])
self.root_dir: str = config["housekeeper"]["root"]

def __getattr__(self, name):
LOG.warning(f"Called undefined {name} on {self.__class__.__name__}, please wrap")
return getattr(self._store, name)

def new_bundle(self, name: str, created_at: datetime = None) -> Bundle:
"""Create a new file bundle."""
return self._store.new_bundle(name, created_at)
Expand Down
8 changes: 8 additions & 0 deletions cg/apps/lims/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,3 +555,11 @@ def _get_negative_controls_from_list(samples: list[Sample]) -> list[Sample]:
):
negative_controls.append(sample)
return negative_controls

def get_sample_region_and_lab_code(self, sample_id: str) -> str:
"""Return the region code and lab code for a sample formatted as a prefix string."""
region_code: str = self.get_sample_attribute(lims_id=sample_id, key="region_code").split(
" "
)[0]
lab_code: str = self.get_sample_attribute(lims_id=sample_id, key="lab_code").split(" ")[0]
return f"{region_code}_{lab_code}_"
2 changes: 1 addition & 1 deletion cg/apps/orderform/excel_orderform_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from cg.constants import DataDelivery
from cg.constants.orderforms import Orderform
from cg.exc import OrderFormError
from cg.models.orders.constants import OrderType
from cg.models.orders.excel_sample import ExcelSample
from cg.models.orders.order import OrderType

LOG = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion cg/apps/orderform/json_orderform_parser.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from cg.apps.orderform.orderform_parser import OrderformParser
from cg.constants import DataDelivery, Workflow
from cg.exc import OrderFormError
from cg.models.orders.constants import OrderType
from cg.models.orders.json_sample import JsonSample
from cg.models.orders.order import OrderType


class JsonOrderformParser(OrderformParser):
Expand Down
2 changes: 1 addition & 1 deletion cg/apps/orderform/orderform_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from cg.apps.orderform.utils import ORDER_TYPES_WITH_CASES
from cg.constants import DataDelivery
from cg.exc import OrderFormError
from cg.models.orders.order import OrderType
from cg.models.orders.constants import OrderType
from cg.models.orders.orderform_schema import OrderCase, Orderform, OrderPool
from cg.models.orders.sample_base import OrderSample
from cg.store.models import Customer
Expand Down
14 changes: 8 additions & 6 deletions cg/apps/tb/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import logging
from typing import Any

from google.auth import jwt
from google.auth.crypt import RSASigner
from google.auth.transport.requests import Request
from google.oauth2 import service_account

from cg.apps.tb.dto.create_job_request import CreateJobRequest
from cg.apps.tb.dto.summary_response import AnalysisSummary, SummariesResponse
Expand Down Expand Up @@ -50,10 +50,12 @@ def __init__(self, config: dict):

@property
def auth_header(self) -> dict:
signer = RSASigner.from_service_account_file(self.service_account_auth_file)
payload = {"email": self.service_account}
jwt_token = jwt.encode(signer=signer, payload=payload).decode("ascii")
return {"Authorization": f"Bearer {jwt_token}"}
credentials = service_account.IDTokenCredentials.from_service_account_file(
filename=self.service_account_auth_file,
target_audience="trailblazer",
)
credentials.refresh(Request())
return {"Authorization": f"Bearer {credentials.token}"}

def query_trailblazer(
self, command: str, request_body: dict, method: str = APIMethods.POST
Expand Down
11 changes: 4 additions & 7 deletions cg/cli/deliver/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from cg.services.deliver_files.deliver_files_service.deliver_files_service import (
DeliverFilesService,
)
from cg.services.deliver_files.deliver_files_service.deliver_files_service_factory import (
from cg.services.deliver_files.factory import (
DeliveryServiceFactory,
)
from cg.services.deliver_files.rsync.service import DeliveryRsyncService
Expand Down Expand Up @@ -88,8 +88,7 @@ def deliver_case(
LOG.error(f"Could not find case with id {case_id}")
return
delivery_service: DeliverFilesService = service_builder.build_delivery_service(
case=case,
delivery_type=delivery_type,
case=case, delivery_type=delivery_type
)
delivery_service.deliver_files_for_case(
case=case, delivery_base_path=Path(inbox), dry_run=dry_run
Expand Down Expand Up @@ -124,8 +123,7 @@ def deliver_ticket(
LOG.error(f"Could not find case connected to ticket {ticket}")
return
delivery_service: DeliverFilesService = service_builder.build_delivery_service(
case=cases[0],
delivery_type=delivery_type,
case=cases[0], delivery_type=delivery_type
)
delivery_service.deliver_files_for_ticket(
ticket_id=ticket, delivery_base_path=Path(inbox), dry_run=dry_run
Expand Down Expand Up @@ -172,8 +170,7 @@ def deliver_sample_raw_data(
LOG.error(f"Could not find case with id {case_id}")
return
delivery_service: DeliverFilesService = service_builder.build_delivery_service(
case=case,
delivery_type=delivery_type,
case=case, delivery_type=delivery_type
)
delivery_service.deliver_files_for_sample(
case=case, sample_id=sample_id, delivery_base_path=Path(inbox), dry_run=dry_run
Expand Down
5 changes: 2 additions & 3 deletions cg/cli/deliver/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from cg.services.deliver_files.deliver_files_service.deliver_files_service import (
DeliverFilesService,
)
from cg.services.deliver_files.deliver_files_service.deliver_files_service_factory import (
from cg.services.deliver_files.factory import (
DeliveryServiceFactory,
)
from cg.store.models import Analysis, Case
Expand All @@ -26,8 +26,7 @@ def deliver_raw_data_for_analyses(
try:
case: Case = analysis.case
delivery_service: DeliverFilesService = service_builder.build_delivery_service(
case=case,
delivery_type=case.data_delivery,
case=case, delivery_type=case.data_delivery
)

delivery_service.deliver_files_for_case(
Expand Down
3 changes: 3 additions & 0 deletions cg/cli/upload/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from cg.meta.upload.microsalt.microsalt_upload_api import MicrosaltUploadAPI
from cg.meta.upload.mip.mip_dna import MipDNAUploadAPI
from cg.meta.upload.mip.mip_rna import MipRNAUploadAPI
from cg.meta.upload.mutant.mutant import MutantUploadAPI
from cg.meta.upload.nf_analysis import NfAnalysisUploadAPI
from cg.meta.upload.tomte.tomte import TomteUploadAPI
from cg.meta.upload.raredisease.raredisease import RarediseaseUploadAPI
Expand Down Expand Up @@ -94,6 +95,8 @@ def upload(context: click.Context, case_id: str | None, restart: bool):
Workflow.TAXPROFILER,
}:
upload_api = NfAnalysisUploadAPI(config_object, case.data_analysis)
elif case.data_analysis == Workflow.MUTANT:
upload_api = MutantUploadAPI(config_object)

context.obj.meta_apis["upload_api"] = upload_api
upload_api.upload(ctx=context, case=case, restart=restart)
Expand Down
30 changes: 25 additions & 5 deletions cg/cli/upload/fohm.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ def aggregate_delivery(
context: CGConfig, cases: list, dry_run: bool = False, datestr: str | None = None
):
"""Re-aggregates delivery files for FOHM and saves them to default working directory."""
fohm_api = FOHMUploadAPI(config=context, dry_run=dry_run, datestr=datestr)
fohm_api = FOHMUploadAPI(
config=context,
dry_run=dry_run,
datestr=datestr,
)
try:
fohm_api.aggregate_delivery(cases)
except (ValidationError, TypeError) as error:
Expand All @@ -57,7 +61,11 @@ def create_komplettering(
context: CGConfig, cases: list, dry_run: bool = False, datestr: str | None = None
):
"""Re-aggregates komplettering files for FOHM and saves them to default working directory."""
fohm_api = FOHMUploadAPI(config=context, dry_run=dry_run, datestr=datestr)
fohm_api = FOHMUploadAPI(
config=context,
dry_run=dry_run,
datestr=datestr,
)
try:
fohm_api.create_and_write_complementary_report(cases)
except ValidationError as error:
Expand All @@ -73,7 +81,11 @@ def preprocess_all(
context: CGConfig, cases: list, dry_run: bool = False, datestr: str | None = None
):
"""Create all FOHM upload files, upload to GISAID, sync SFTP and mail reports for all provided cases."""
fohm_api = FOHMUploadAPI(config=context, dry_run=dry_run, datestr=datestr)
fohm_api = FOHMUploadAPI(
config=context,
dry_run=dry_run,
datestr=datestr,
)
gisaid_api = GisaidAPI(config=context)
cases = list(cases)
upload_cases = []
Expand Down Expand Up @@ -105,7 +117,11 @@ def preprocess_all(
@click.pass_obj
def upload_rawdata(context: CGConfig, dry_run: bool = False, datestr: str | None = None):
"""Deliver files in daily upload directory via sftp."""
fohm_api = FOHMUploadAPI(config=context, dry_run=dry_run, datestr=datestr)
fohm_api = FOHMUploadAPI(
config=context,
dry_run=dry_run,
datestr=datestr,
)
fohm_api.sync_files_sftp()


Expand All @@ -115,5 +131,9 @@ def upload_rawdata(context: CGConfig, dry_run: bool = False, datestr: str | None
@click.pass_obj
def send_reports(context: CGConfig, dry_run: bool = False, datestr: str | None = None):
"""Send all komplettering reports found in the current daily directory to target recipients."""
fohm_api = FOHMUploadAPI(config=context, dry_run=dry_run, datestr=datestr)
fohm_api = FOHMUploadAPI(
config=context,
dry_run=dry_run,
datestr=datestr,
)
fohm_api.send_mail_reports()
10 changes: 6 additions & 4 deletions cg/cli/workflow/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from cg.cli.workflow.mip_dna.base import mip_dna
from cg.cli.workflow.mip_rna.base import mip_rna
from cg.cli.workflow.mutant.base import mutant
from cg.cli.workflow.nallo.base import nallo
from cg.cli.workflow.raredisease.base import raredisease
from cg.cli.workflow.rnafusion.base import rnafusion
from cg.cli.workflow.taxprofiler.base import taxprofiler
Expand All @@ -27,16 +28,17 @@ def workflow():

workflow.add_command(balsamic)
workflow.add_command(balsamic_qc)
workflow.add_command(balsamic_umi)
workflow.add_command(balsamic_pon)
workflow.add_command(balsamic_umi)
workflow.add_command(fluffy)
workflow.add_command(jasen)
workflow.add_command(microsalt)
workflow.add_command(mip_dna)
workflow.add_command(mip_rna)
workflow.add_command(fluffy)
workflow.add_command(jasen)
workflow.add_command(mutant)
workflow.add_command(nallo)
workflow.add_command(raredisease)
workflow.add_command(raw_data)
workflow.add_command(rnafusion)
workflow.add_command(taxprofiler)
workflow.add_command(tomte)
workflow.add_command(raw_data)
Loading

0 comments on commit b06f1d4

Please sign in to comment.