-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add new EPP for checking process UDFs
- Loading branch information
1 parent
bd7efec
commit aef24dd
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |