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 EPP log message duplication and missing log entries in Clarity 6+ when combining Python automations with LLTK/LITKs #51

Merged
merged 2 commits into from
Jul 19, 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
31 changes: 31 additions & 0 deletions s4/clarity/lims.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
import logging
import re
import time

try:
import urllib.parse as urlparse # Python 3
except ImportError:
import urlparse # Python 2

from xml.etree import cElementTree as ETree

import requests
Expand Down Expand Up @@ -247,6 +253,31 @@ def properties(self):
properties = root.findall("property")
return dict( (property.get("name"), property.get("value")) for property in properties )

@lazy_property
def versions(self):
"""
:type: list[dict]
"""
root = self.request("get", self.root_uri + "/..")
versions = root.findall("version")
return list({
"uri": version.get("uri"),
"major": version.get("major"),
"minor": version.get("minor")
} for version in versions)

@lazy_property
def current_minor_version(self):
"""
:type: str
"""
path = urlparse.urlparse(self.root_uri).path
current_major_version = [x for x in path.split("/") if x][-1]
root = self.request("get", self.root_uri + "/..")
xpath = "version[@major='%s']" % current_major_version
version = root.findall(xpath)[0]
return version.get("minor")

def raw_request(self, method, uri, **kwargs):
"""
:type method: str
Expand Down
17 changes: 15 additions & 2 deletions s4/clarity/scripts/stepepp.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,24 @@ def open_log_output_stream(self):
Use step's logfile.
"""
if self.options.logfile:

# Log files that are shared by Python and LLTK/LITKs on a step must
# use the same file name in order to prevent bugs. In Clarity 5 and
# earlier, the file name used by LLTK/LITKs is simply the limsid of
# the ResultFile. But in Clarity 6 and later it has "LogFile"
# appended to the name, and so we need to check the active Clarity
# version and adjust our behaviour accordingly.

filename = self.options.logfile
revision = int(self.lims.current_minor_version[1:])
if revision >= 31: # Clarity 6.0 has an API minor version of 31
filename = "%s-LogFile" % filename

if self.options.log_type == 'html':
filename = "%s.html" % self.options.logfile
filename = "%s.html" % filename
content_type = 'text/html'
elif self.options.log_type == 'text':
filename = "%s.log" % self.options.logfile
filename = "%s.log" % filename
content_type = 'text/plain'
else:
raise Exception("Unrecognized log type %s", self.options.log_type)
Expand Down