Skip to content

Commit

Permalink
Merge branch 'master' into balsamic_v16
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasbio committed Sep 19, 2024
2 parents 9be524f + 4e86ce5 commit 6ca040c
Show file tree
Hide file tree
Showing 141 changed files with 3,822 additions and 890 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 = 63.0.1
current_version = 63.2.11
commit = True
tag = True
tag_name = v{new_version}
Expand Down
26 changes: 17 additions & 9 deletions .github/ISSUE_TEMPLATE/user-story.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,22 @@ As a [type of user],
I want [an action or feature],
So that [benefit or reason].

# Work impact
<!--
Filled in by the Product Owner or the Stakeholders.
-->

Answer the following questions:
- Is there currently a workaround for this issue? If so, what is it?
-
- How much time would be saved by implementing this feature on a weekly basis?
-
- How many users are affected by this issue?
-
- Are customers affected by this issue?
-


# Acceptance Criteria
<!--
Filled in by the Product Owner or the Stakeholders.
Expand All @@ -32,12 +48,4 @@ Filled in by the Product Owner or the Stakeholders.

- Additional information.
- Dependencies.
- Related user stories.

# Implementation plan
<!--
This section will be populated by the developers during their technical refinements.
-->

- [ ] Work item 1
- [ ] Work item 2
- Related user stories.
50 changes: 50 additions & 0 deletions alembic/versions/2024_08_09_7770dcad8bde_rename_order_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""Rename order status
Revision ID: 7770dcad8bde
Revises: bb4c6dbad991
Create Date: 2024-08-09 09:47:47.814700
"""

import sqlalchemy as sa
from sqlalchemy import orm
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column

from alembic import op

# revision identifiers, used by Alembic.
revision = "7770dcad8bde"
down_revision = "bb4c6dbad991"
branch_labels = None
depends_on = None


class Base(DeclarativeBase):
pass


class Order(Base):
__tablename__ = "order"

id: Mapped[int] = mapped_column(primary_key=True)
is_open: Mapped[str]


def upgrade():
op.alter_column(
table_name="order", column_name="is_delivered", type_=sa.Boolean, new_column_name="is_open"
)
bind = op.get_bind()
session = orm.Session(bind=bind)
for order in session.query(Order).all():
order.is_open = not order.is_open
session.commit()


def downgrade():
bind = op.get_bind()
session = orm.Session(bind=bind)
for order in session.query(Order).all():
order.is_open = not order.is_open
session.commit()
op.alter_column(
table_name="order", new_column_name="is_delivered", type_=sa.Boolean, column_name="is_open"
)
169 changes: 169 additions & 0 deletions alembic/versions/2024_09_11_18dbadd8c436_rename_fastq_to_raw_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
"""rename_fastq_to_raw_data
Revision ID: 18dbadd8c436
Revises: bb4c6dbad991
Create Date: 2024-09-11 13:15:11.876822
"""

from enum import StrEnum

from sqlalchemy import orm
from sqlalchemy.dialects import mysql
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column

from alembic import op

# revision identifiers, used by Alembic.
revision = "18dbadd8c436"
down_revision = "7770dcad8bde"
branch_labels = None
depends_on = None


base_options = (
"balsamic",
"balsamic-pon",
"balsamic-qc",
"balsamic-umi",
"demultiplex",
"fluffy",
"jasen",
"microsalt",
"mip-dna",
"mip-rna",
"mutant",
"raredisease",
"rnafusion",
"rsync",
"spring",
"taxprofiler",
"tomte",
)
old_options = sorted(base_options + ("fastq",))
new_options = sorted(base_options + ("raw-data",))

old_enum = mysql.ENUM(*old_options)
new_enum = mysql.ENUM(*new_options)


class Workflow(StrEnum):
BALSAMIC: str = "balsamic"
BALSAMIC_PON: str = "balsamic-pon"
BALSAMIC_QC: str = "balsamic-qc"
BALSAMIC_UMI: str = "balsamic-umi"
DEMULTIPLEX: str = "demultiplex"
FLUFFY: str = "fluffy"
JASEN: str = "jasen"
MICROSALT: str = "microsalt"
MIP_DNA: str = "mip-dna"
MIP_RNA: str = "mip-rna"
MUTANT: str = "mutant"
RAREDISEASE: str = "raredisease"
RAW_DATA: str = "raw-data"
RNAFUSION: str = "rnafusion"
RSYNC: str = "rsync"
SPRING: str = "spring"
TAXPROFILER: str = "taxprofiler"
TOMTE: str = "tomte"


class Base(DeclarativeBase):
pass


class Case(Base):
__tablename__ = "case"
id: Mapped[int] = mapped_column(primary_key=True)
data_analysis: Mapped[str | None]


class Analysis(Base):
__tablename__ = "analysis"

id: Mapped[int] = mapped_column(primary_key=True)
workflow: Mapped[str | None]


class Order(Base):
__tablename__ = "order"
id: Mapped[int] = mapped_column(primary_key=True)
workflow: Mapped[str | None]


class ApplicationLimitations(Base):
__tablename__ = "application_limitations"
id: Mapped[int] = mapped_column(primary_key=True)
workflow: Mapped[str | None]


def upgrade():
bind = op.get_bind()
session = orm.Session(bind=bind)
try:
# Case
op.alter_column("case", "data_analysis", type_=mysql.VARCHAR(64), existing_nullable=True)
session.query(Case).filter(Case.data_analysis == "fastq").update(
{"data_analysis": Workflow.RAW_DATA}, synchronize_session="evaluate"
)
op.alter_column("case", "data_analysis", type_=new_enum, existing_nullable=True)
# Analysis
op.alter_column("analysis", "workflow", type_=mysql.VARCHAR(64), existing_nullable=True)
session.query(Analysis).filter(Analysis.workflow == "fastq").update(
{"workflow": Workflow.RAW_DATA}, synchronize_session="evaluate"
)
op.alter_column("analysis", "workflow", type_=new_enum, existing_nullable=True)
# Order
op.alter_column("order", "workflow", type_=mysql.VARCHAR(64), existing_nullable=True)
session.query(Order).filter(Order.workflow == "fastq").update(
{"workflow": Workflow.RAW_DATA}, synchronize_session="evaluate"
)
op.alter_column("order", "workflow", type_=new_enum, existing_nullable=True)
# Application Limitation
op.alter_column(
"application_limitations", "workflow", type_=mysql.VARCHAR(64), existing_nullable=True
)
session.query(ApplicationLimitations).filter(
ApplicationLimitations.workflow == "fastq"
).update({"workflow": Workflow.RAW_DATA}, synchronize_session="evaluate")
op.alter_column(
"application_limitations", "workflow", type_=new_enum, existing_nullable=True
)
session.commit()
finally:
session.close()


def downgrade():
bind = op.get_bind()
session = orm.Session(bind=bind)
try:
# Case
op.alter_column("case", "data_analysis", type_=mysql.VARCHAR(64), existing_nullable=True)
session.query(Case).filter(Case.data_analysis == Workflow.RAW_DATA).update(
{"data_analysis": "fastq"}, synchronize_session="evaluate"
)
op.alter_column("case", "data_analysis", type_=old_enum, existing_nullable=True)
# Analysis
op.alter_column("analysis", "workflow", type_=mysql.VARCHAR(64), existing_nullable=True)
session.query(Analysis).filter(Analysis.workflow == Workflow.RAW_DATA).update(
{"workflow": "fastq"}, synchronize_session="evaluate"
)
op.alter_column("analysis", "workflow", type_=old_enum, existing_nullable=True)
# Order
op.alter_column("order", "workflow", type_=mysql.VARCHAR(64), existing_nullable=True)
session.query(Order).filter(Order.workflow == Workflow.RAW_DATA).update(
{"workflow": "fastq"}, synchronize_session="evaluate"
)
op.alter_column("order", "workflow", type_=old_enum, existing_nullable=True)
# Application Limitation
op.alter_column(
"application_limitations", "workflow", type_=mysql.VARCHAR(64), existing_nullable=True
)
session.query(ApplicationLimitations).filter(
ApplicationLimitations.workflow == Workflow.RAW_DATA
).update({"workflow": "fastq"}, synchronize_session="evaluate")
op.alter_column(
"application_limitations", "workflow", type_=old_enum, existing_nullable=True
)
session.commit()
finally:
session.close()
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__ = "63.0.1"
__version__ = "63.2.11"
2 changes: 0 additions & 2 deletions cg/cli/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from cg.cli.transfer import transfer_group
from cg.cli.upload.base import upload
from cg.cli.utils import CLICK_CONTEXT_SETTINGS
from cg.cli.validate import validate
from cg.cli.workflow.base import workflow as workflow_cmd
from cg.constants.cli_options import FORCE
from cg.constants.constants import FileFormat
Expand Down Expand Up @@ -121,5 +120,4 @@ def init(context: CGConfig, reset: bool, force: bool):
base.add_command(generate_cmd)
base.add_command(downsample)
base.add_command(post_processing)
base.add_command(validate)
base.add_command(sequencing_qc)
10 changes: 5 additions & 5 deletions cg/cli/deliver/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
from cg.constants import Workflow
from cg.constants.cli_options import DRY_RUN
from cg.constants.delivery import FileDeliveryOption
from cg.services.deliver_files.delivery_rsync_service.delivery_rsync_service import (
DeliveryRsyncService,
)
from cg.models.cg_config import CGConfig
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 (
DeliveryServiceFactory,
)
from cg.store.models import Case, Analysis
from cg.services.deliver_files.delivery_rsync_service.delivery_rsync_service import (
DeliveryRsyncService,
)
from cg.store.models import Analysis, Case

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -148,7 +148,7 @@ def deliver_auto_raw_data(context: CGConfig, dry_run: bool):
clinical-delivery."""
service_builder: DeliveryServiceFactory = context.delivery_service_factory
analyses: list[Analysis] = context.analysis_service.get_analyses_to_upload_for_workflow(
workflow=Workflow.FASTQ
workflow=Workflow.RAW_DATA
)
deliver_raw_data_for_analyses(
analyses=analyses,
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 @@ -9,10 +9,9 @@
from cg.services.deliver_files.deliver_files_service.deliver_files_service_factory import (
DeliveryServiceFactory,
)
from cg.store.models import Case, Analysis
from cg.store.models import Analysis, Case
from cg.store.store import Store


LOG = logging.getLogger(__name__)


Expand All @@ -29,7 +28,7 @@ def deliver_raw_data_for_analyses(
case: Case = analysis.case
delivery_service: DeliverFilesService = service_builder.build_delivery_service(
delivery_type=case.data_delivery,
workflow=Workflow.FASTQ,
workflow=Workflow.RAW_DATA,
)

delivery_service.deliver_files_for_case(
Expand Down
25 changes: 0 additions & 25 deletions cg/cli/validate.py

This file was deleted.

2 changes: 1 addition & 1 deletion cg/cli/workflow/fastq/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ def store_fastq_analysis(context: click.Context, case_id: str, dry_run: bool = F
def store_available_fastq_analysis(context: click.Context, dry_run: bool = False):
"""Creates an analysis object in status-db for all fastq cases to be delivered."""
status_db: Store = context.obj.status_db
for case in status_db.cases_to_analyse(workflow=Workflow.FASTQ):
for case in status_db.cases_to_analyse(workflow=Workflow.RAW_DATA):
if SequencingQCService.case_pass_sequencing_qc(case):
context.invoke(store_fastq_analysis, case_id=case.internal_id, dry_run=dry_run)
4 changes: 2 additions & 2 deletions cg/cli/workflow/fastq/fastq_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _get_case(self, case_id: str) -> Case:

def _add_analysis_to_store(self, case: Case) -> None:
new_analysis: Analysis = self.store.add_analysis(
workflow=Workflow.FASTQ,
workflow=Workflow.RAW_DATA,
completed_at=dt.datetime.now(),
primary=True,
started_at=dt.datetime.now(),
Expand All @@ -42,7 +42,7 @@ def _add_analysis_to_trailblazer(self, case: Case) -> None:
order_id=case.latest_order.id,
out_dir="",
slurm_quality_of_service=case.slurm_priority,
workflow=Workflow.FASTQ,
workflow=Workflow.RAW_DATA,
ticket=case.latest_ticket,
)
self.trailblazer_api.set_analysis_status(
Expand Down
1 change: 1 addition & 0 deletions cg/cli/workflow/nf_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from cg.constants.constants import MetaApis
from cg.exc import AnalysisNotReadyError, CgError, HousekeeperStoreError
from cg.meta.workflow.nf_analysis import NfAnalysisAPI

from cg.models.cg_config import CGConfig

LOG = logging.getLogger(__name__)
Expand Down
Loading

0 comments on commit 6ca040c

Please sign in to comment.