Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/update-jinja2' into update-jinja2
Browse files Browse the repository at this point in the history
henrikstranneheim committed Jan 14, 2025
2 parents c0a2128 + 5403c2d commit dde169e
Showing 15 changed files with 28 additions and 18 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 = 65.0.7
current_version = 65.0.10
commit = True
tag = True
tag_name = v{new_version}
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__ = "65.0.7"
__version__ = "65.0.10"
5 changes: 2 additions & 3 deletions cg/apps/tb/api.py
Original file line number Diff line number Diff line change
@@ -46,14 +46,13 @@ class TrailblazerAPI:
def __init__(self, config: dict):
self.service_account = config["trailblazer"]["service_account"]
self.service_account_auth_file = config["trailblazer"]["service_account_auth_file"]
self.google_client_id = config["trailblazer"]["google_client_id"]
self.host = config["trailblazer"]["host"]

@property
def auth_header(self) -> dict:
credentials = service_account.IDTokenCredentials.from_service_account_file(
self.service_account_auth_file,
target_audience=self.google_client_id,
filename=self.service_account_auth_file,
target_audience="trailblazer",
)
credentials.refresh(Request())
return {"Authorization": f"Bearer {credentials.token}"}
1 change: 0 additions & 1 deletion cg/models/cg_config.py
Original file line number Diff line number Diff line change
@@ -129,7 +129,6 @@ class ClientConfig(BaseModel):
class TrailblazerConfig(BaseModel):
service_account: str
service_account_auth_file: str
google_client_id: str
host: str


1 change: 0 additions & 1 deletion cg/server/app_config.py
Original file line number Diff line number Diff line change
@@ -21,7 +21,6 @@ class AppConfig(BaseSettings):
trailblazer_host: str = "trailblazer_host"
trailblazer_service_account: str = "service_account"
trailblazer_service_account_auth_file: str = "auth_file.json"
trailblazer_google_client_id: str = "google_client_id"
freshdesk_url: str = "https://company.freshdesk.com"
freshdesk_api_key: str = "freshdesk_api_key"
freshdesk_order_email_id: int = 10
2 changes: 0 additions & 2 deletions cg/server/ext.py
Original file line number Diff line number Diff line change
@@ -68,13 +68,11 @@ def __init__(self, app=None):
def init_app(self, app):
service_account: str = app.config["trailblazer_service_account"]
service_account_auth_file: str = app.config["trailblazer_service_account_auth_file"]
google_client_id: str = app.config["trailblazer_google_client_id"]
host: str = app.config["trailblazer_host"]
config = {
"trailblazer": {
"service_account": service_account,
"service_account_auth_file": service_account_auth_file,
"google_client_id": google_client_id,
"host": host,
}
}
2 changes: 2 additions & 0 deletions cg/services/orders/store_order_services/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Hardcoded constant for special order to assign MAF cases to
MAF_ORDER_ID: int = 12377
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
from cg.models.orders.order import OrderIn
from cg.models.orders.sample_base import StatusEnum
from cg.services.orders.order_lims_service.order_lims_service import OrderLimsService
from cg.services.orders.store_order_services.constants import MAF_ORDER_ID
from cg.services.orders.submitters.order_submitter import StoreOrderService
from cg.store.models import ApplicationVersion, Case, CaseSample, Customer, Order, Sample
from cg.store.store import Store
@@ -62,12 +63,14 @@ def order_to_status(order: OrderIn) -> dict:
}
return status_data

def create_maf_case(self, sample_obj: Sample, order: Order) -> None:
def create_maf_case(self, sample_obj: Sample, order: Order, case: Case) -> None:
"""Add a MAF case to the Status database."""
maf_order = self.status_db.get_order_by_id(MAF_ORDER_ID)
case: Case = self.status_db.add_case(
comment=f"MAF case for {case.internal_id} original order id {order.id}",
data_analysis=Workflow(Workflow.MIP_DNA),
data_delivery=DataDelivery(DataDelivery.NO_DELIVERY),
name="_".join([sample_obj.name, "MAF"]),
name="_".join([sample_obj.internal_id, "MAF"]),
panels=[GenePanelMasterList.OMIM_AUTO],
priority=Priority.research,
ticket=sample_obj.original_ticket,
@@ -78,7 +81,7 @@ def create_maf_case(self, sample_obj: Sample, order: Order) -> None:
relationship: CaseSample = self.status_db.relate_sample(
case=case, sample=sample_obj, status=StatusEnum.unknown
)
order.cases.append(case)
maf_order.cases.append(case)
self.status_db.session.add_all([case, relationship])

def store_items_in_status(
@@ -137,7 +140,7 @@ def store_items_in_status(
not new_sample.is_tumour
and new_sample.prep_category == SeqLibraryPrepCategory.WHOLE_GENOME_SEQUENCING
):
self.create_maf_case(sample_obj=new_sample, order=status_db_order)
self.create_maf_case(sample_obj=new_sample, order=status_db_order, case=case)
case.customer = customer
new_relationship = self.status_db.relate_sample(
case=case, sample=new_sample, status=StatusEnum.unknown
2 changes: 2 additions & 0 deletions cg/store/crud/create.py
Original file line number Diff line number Diff line change
@@ -246,11 +246,13 @@ def add_case(
priority: Priority | None = Priority.standard,
synopsis: str | None = None,
customer_id: int | None = None,
comment: str | None = None,
) -> Case:
"""Build a new Case record."""

internal_id: str = self.generate_readable_case_id()
return Case(
comment=comment,
cohorts=cohorts,
data_analysis=str(data_analysis),
data_delivery=str(data_delivery),
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[project]
name = "cg"
version = "65.0.8"
version = "65.0.10"
description = "Clinical Genomics command center"
readme = {file = "README.md", content-type = "text/markdown"}
homepage = "https://github.com/Clinical-Genomics/cg"
5 changes: 4 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@
from cg.services.deliver_files.rsync.service import DeliveryRsyncService
from cg.services.illumina.backup.encrypt_service import IlluminaRunEncryptionService
from cg.services.illumina.data_transfer.data_transfer_service import IlluminaDataTransferService
from cg.services.orders.store_order_services.constants import MAF_ORDER_ID
from cg.store.database import create_all_tables, drop_all_tables, initialize_database
from cg.store.models import (
Application,
@@ -1649,6 +1650,9 @@ def base_store(
store.session.add(organism)
store.session.commit()

order: Order = Order(customer_id=1, id=MAF_ORDER_ID, ticket_id="100000000")
store.add_multiple_items_to_store([order])

yield store


@@ -2185,7 +2189,6 @@ def context_config(
"host": "https://trailblazer.scilifelab.se/",
"service_account": "SERVICE",
"service_account_auth_file": "trailblazer-auth.json",
"google_client_id": "client_id",
},
"arnold": {"api_url": "https://arnold.scilifelab.se/"},
"janus": {"host": "https://janus.sys.scilifelab.se/"},
1 change: 1 addition & 0 deletions tests/meta/orders/conftest.py
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
OrderSubmitterRegistry,
setup_order_submitter_registry,
)
from cg.store.models import Order
from cg.store.store import Store
from tests.mocks.limsmock import MockLimsAPI

2 changes: 1 addition & 1 deletion tests/meta/orders/test_meta_orders_api.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
from cg.services.orders.validate_order_services.validate_case_order import (
ValidateCaseOrderService,
)
from cg.store.models import Case, Customer, Pool, Sample
from cg.store.models import Case, Customer, Pool, Sample, Order
from cg.store.store import Store
from tests.store_helpers import StoreHelpers

1 change: 0 additions & 1 deletion tests/server/conftest.py
Original file line number Diff line number Diff line change
@@ -25,7 +25,6 @@
os.environ["GOOGLE_OAUTH_CLIENT_SECRET"] = "dummy_value"
os.environ["TRAILBLAZER_SERVICE_ACCOUNT"] = "dummy_value"
os.environ["TRAILBLAZER_SERVICE_ACCOUNT_AUTH_FILE"] = "dummy_value"
os.environ["TRAILBLAZER_GOOGLE_CLIENT_ID"] = "dummy_value"
os.environ["TRAILBLAZER_HOST"] = "dummy_value"
os.environ["CG_SECRET_KEY"] = "dummy_value"
os.environ["GUNICORN_BIND"] = "0.0.0.0:8000"
Original file line number Diff line number Diff line change
@@ -6,8 +6,9 @@
from cg.constants.sequencing import SeqLibraryPrepCategory
from cg.exc import OrderError
from cg.models.orders.order import OrderIn, OrderType
from cg.services.orders.store_order_services.constants import MAF_ORDER_ID
from cg.services.orders.store_order_services.store_fastq_order_service import StoreFastqOrderService
from cg.store.models import Application, Case, Sample
from cg.store.models import Application, Case, Sample, Order
from cg.store.store import Store


@@ -63,6 +64,10 @@ def test_store_samples(
assert family_link.case.data_analysis
assert family_link.case.data_delivery in [DataDelivery.FASTQ, DataDelivery.NO_DELIVERY]

# THEN a MAF case should be added to the MAF orders
maf_order: Order = base_store.get_order_by_id(MAF_ORDER_ID)
assert len(maf_order.cases) == 1


def test_store_samples_sex_stored(
base_store: Store,

0 comments on commit dde169e

Please sign in to comment.