From 464246d78f97d2d30c838e6c51420dcbeca469bc Mon Sep 17 00:00:00 2001 From: chuan-wang Date: Tue, 9 Apr 2024 14:50:09 +0200 Subject: [PATCH 1/3] Fix issue that sys stderr blocks a step to be completed --- VERSIONLOG.md | 4 ++++ scripts/index_distance_checker.py | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/VERSIONLOG.md b/VERSIONLOG.md index fa18dabd..4da93cc1 100644 --- a/VERSIONLOG.md +++ b/VERSIONLOG.md @@ -1,5 +1,9 @@ # Scilifelab_epps Version Log +## 20240409.1 + +Fix issue that sys stderr blocks a step to be completed + ## 20240407.1 Add lane yield threshold for NovaSeqXPlus 25B FC diff --git a/scripts/index_distance_checker.py b/scripts/index_distance_checker.py index c3021bc1..48aaa0b2 100644 --- a/scripts/index_distance_checker.py +++ b/scripts/index_distance_checker.py @@ -354,7 +354,7 @@ def find_barcode(sample_idxs, sample, process): find_barcode(sample_idxs, sample, art.parent_process) -def main(lims, pid): +def main(lims, pid, auto): process = Process(lims, id=pid) tech_username = process.technician.username data, message = prepare_index_table(process) @@ -367,7 +367,10 @@ def main(lims, pid): warning_start = "**Warnings from Verify Indexes and Placement EPP: **\n" warning_end = "== End of Verify Indexes and Placement EPP warnings ==" if message: - sys.stderr.write("; ".join(message)) + if auto: + print("; ".join(message), file=sys.stderr) + else: + sys.stderr.write("; ".join(message)) if process.type.name == "Library Pooling (Finished Libraries) 4.0": if not process.udf.get("Comments"): process.udf["Comments"] = ( @@ -405,7 +408,8 @@ def main(lims, pid): process.udf["Comments"] += f"\n@{tech_username}\n" process.udf["Comments"] += warning_end process.put() - sys.exit(2) + if not auto: + sys.exit(2) else: print("No issue detected with indexes or placement", file=sys.stderr) message.append("No issue detected with indexes or placement") @@ -439,8 +443,15 @@ def main(lims, pid): "File name for standard log file, " "for runtime information and problems." ), ) + parser.add_argument( + "--auto", + action='store_true', + help=( + "Used when the script is running automatically in LIMS." + ), + ) args = parser.parse_args() lims = Lims(BASEURI, USERNAME, PASSWORD) lims.check_version() - main(lims, args.pid) + main(lims, args.pid, args.auto) From 3909ba0a2a68616e18f5192523495dd73387d116 Mon Sep 17 00:00:00 2001 From: chuan-wang Date: Tue, 9 Apr 2024 14:52:13 +0200 Subject: [PATCH 2/3] ruff format --- scripts/index_distance_checker.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/index_distance_checker.py b/scripts/index_distance_checker.py index 48aaa0b2..4288ec42 100644 --- a/scripts/index_distance_checker.py +++ b/scripts/index_distance_checker.py @@ -445,10 +445,8 @@ def main(lims, pid, auto): ) parser.add_argument( "--auto", - action='store_true', - help=( - "Used when the script is running automatically in LIMS." - ), + action="store_true", + help=("Used when the script is running automatically in LIMS."), ) args = parser.parse_args() From 39c3168a4833e3f5854670606a5a03f1abcd1c7e Mon Sep 17 00:00:00 2001 From: chuan-wang Date: Tue, 9 Apr 2024 15:00:13 +0200 Subject: [PATCH 3/3] Fix the other EPP script with the same issue --- scripts/index_placement_checker.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/scripts/index_placement_checker.py b/scripts/index_placement_checker.py index 229fff6f..2955bee1 100644 --- a/scripts/index_placement_checker.py +++ b/scripts/index_placement_checker.py @@ -106,7 +106,7 @@ def verify_index_placement(lims, process, data): return message -def main(lims, pid): +def main(lims, pid, auto): process = Process(lims, id=pid) tech_username = process.technician.username data = get_index_layout(process) @@ -115,7 +115,10 @@ def main(lims, pid): warning_end = "== End of Indexes Placement checker EPP warnings ==" if message: - sys.stderr.write("; ".join(message)) + if auto: + print("; ".join(message), file=sys.stderr) + else: + sys.stderr.write("; ".join(message)) if not process.udf.get("Comments"): process.udf["Comments"] = ( warning_start @@ -152,7 +155,8 @@ def main(lims, pid): process.udf["Comments"] += f"\n@{tech_username}\n" process.udf["Comments"] += warning_end process.put() - sys.exit(2) + if not auto: + sys.exit(2) else: print("No issue detected with indexes or placement", file=sys.stderr) # Clear previous warning messages if the error has been corrected @@ -169,8 +173,13 @@ def main(lims, pid): if __name__ == "__main__": parser = ArgumentParser(description=DESC) parser.add_argument("--pid", help="Lims id for current Process") + parser.add_argument( + "--auto", + action="store_true", + help=("Used when the script is running automatically in LIMS."), + ) args = parser.parse_args() lims = Lims(BASEURI, USERNAME, PASSWORD) lims.check_version() - main(lims, args.pid) + main(lims, args.pid, args.auto)