Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue that sys stderr blocks a step to be completed #318

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions VERSIONLOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
17 changes: 13 additions & 4 deletions scripts/index_distance_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"] = (
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -439,8 +443,13 @@ 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)
17 changes: 13 additions & 4 deletions scripts/index_placement_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Loading