Skip to content

Commit

Permalink
add new EPP for checking process UDFs
Browse files Browse the repository at this point in the history
  • Loading branch information
Karl-Svard committed Nov 21, 2023
1 parent bd7efec commit aef24dd
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cg_lims/EPPs/udf/check/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# commands
from cg_lims.EPPs.udf.check.check_artifact_udfs import check_artifact_udfs
from cg_lims.EPPs.udf.check.check_process_udfs import check_process_udfs


@click.group(invoke_without_command=True)
Expand All @@ -14,3 +15,4 @@ def check(ctx):


check.add_command(check_artifact_udfs)
check.add_command(check_process_udfs)
40 changes: 40 additions & 0 deletions cg_lims/EPPs/udf/check/check_process_udfs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import logging
import sys
from typing import List
import click
from genologics.entities import Process
from cg_lims import options
from cg_lims.exceptions import LimsError, MissingUDFsError

LOG = logging.getLogger(__name__)


def check_udfs(process: Process, process_udfs: List[str]) -> None:
"""Check that process UDFs are set."""

warning = []
for udf in process_udfs:
if process.udf.get(udf) is None:
warning.append(f"UDF: '{udf}' is missing for the step.")
if warning:
LOG.warning(" ".join(warning))
raise MissingUDFsError(message=" ".join(warning))
LOG.info("Process UDFs were all set.")


@click.command()
@options.process_udfs()
@click.pass_context
def check_process_udfs(
ctx: click.Context,
process_udfs: List[str],
):
"""Script to check that process UDFs are set."""

LOG.info(f"Running {ctx.command_path} with params: {ctx.params}")
process: Process = ctx.obj["process"]
try:
check_udfs(process=process, process_udfs=process_udfs)
click.echo("Process UDFs were checked.")
except LimsError as e:
sys.exit(e.message)

0 comments on commit aef24dd

Please sign in to comment.