Skip to content

Commit

Permalink
type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
Karl-Svard committed Jan 19, 2024
1 parent 7413777 commit cca11bf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
19 changes: 11 additions & 8 deletions cg_lims/EPPs/udf/calculate/calculate_amount_ng.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import logging
import sys
from typing import List

import click
from cg_lims import options
from cg_lims.exceptions import LimsError, MissingUDFsError
from cg_lims.get.artifacts import get_artifacts
from genologics.entities import Artifact, Process

LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -32,16 +34,17 @@ def calculate_amount_ng(

LOG.info(f"Running {ctx.command_path} with params: {ctx.params}")

process = ctx.obj["process"]
lims = ctx.obj["lims"]
process: Process = ctx.obj["process"]

try:
artifacts = get_artifacts(process=process, measurement=measurement, input=input)
missing_udfs_count = 0
artifacts_with_missing_udf = []
artifacts: List[Artifact] = get_artifacts(
process=process, measurement=measurement, input=input
)
missing_udfs_count: int = 0
artifacts_with_missing_udf: List = []
for artifact in artifacts:
vol = artifact.udf.get(volume_udf)
conc = artifact.udf.get(concentration_udf)
vol: float = artifact.udf.get(volume_udf)
conc: float = artifact.udf.get(concentration_udf)
if None in [conc, vol]:
missing_udfs_count += 1
artifacts_with_missing_udf.append(artifact.id)
Expand All @@ -54,7 +57,7 @@ def calculate_amount_ng(
f"Udf missing for {missing_udfs_count} artifact(s): "
f"{','.join(artifacts_with_missing_udf)}. "
)
message = "Amounts have been calculated for all artifacts."
message: str = "Amounts have been calculated for all artifacts."
LOG.info(message)
click.echo(message)
except LimsError as e:
Expand Down
8 changes: 4 additions & 4 deletions cg_lims/EPPs/udf/copy/sample_to_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from cg_lims.exceptions import LimsError, MissingUDFsError
from cg_lims.get.artifacts import get_artifacts
from cg_lims.get.udfs import get_udf_type
from genologics.entities import Artifact, Process
from genologics.entities import Artifact, Process, Sample
from genologics.lims import Lims

LOG = logging.getLogger(__name__)
Expand All @@ -35,15 +35,15 @@ def udf_copy_sample_to_artifact(
sample_udf: sample udf to set
lims: genologics Lims object connected to the database
ignore_fail: bool option to mute warnings"""
failed_udfs = 0
passed_udfs = 0
failed_udfs: int = 0
passed_udfs: int = 0
udf_type = get_udf_type(
lims=lims, udf_name=artifact_udf, attach_to_name=artifacts[0].output_type
)
for artifact in artifacts:
if len(artifact.samples) > 1:
LOG.info("More than one sample per artifact, picking the first one")
sample = artifact.samples[0]
sample: Sample = artifact.samples[0]
udf = sample.udf.get(sample_udf)
if not isinstance(udf, udf_type):
try:
Expand Down

0 comments on commit cca11bf

Please sign in to comment.