Utils

Artifact Ancestry

s4.clarity.utils.artifact_ancestry.get_parent_artifacts(lims, artifacts)[source]

Helper method to get the parent artifacts keyed to the supplied artifacts

Parameters:
  • lims (LIMS) –
  • artifacts (list[Artifact]) – The artifacts to get parent artifacts for
Return type:

dict[Artifact, list[Artifact]]

s4.clarity.utils.artifact_ancestry.get_udfs_from_artifacts_or_ancestors(lims, artifacts_to_get_udf_from, required_udfs=None, optional_udfs=None)[source]

Walks the genealogy for each artifact in the artifacts_to_get_udf_from list and gets the value for udf_name from the supplied artifact, or its first available ancestor that has a value for the UDF. NOTE: The method will stop the search upon reaching any pooling step.

Parameters:
  • lims (LIMS) –
  • artifacts_to_get_udf_from (list[Artifact]) – the list of artifacts whose ancestors should be inspected for the udf. Passed down recursively until all artifacts have been satisfied.
  • required_udfs (list[str]) – The list of UDFs that must be found. Exception will be raised otherwise.
  • optional_udfs (list[str]) – The list of UDFs that can be found, but do not need to be.
Return type:

dict[s4.clarity.Artifact, dict[str, str]]

Raises:

UserMessageException – if values can not be retrieved for all required_udfs for all of the provided artifacts

Dates

s4.clarity.utils.date_to_str(dt)
Return type:str
s4.clarity.utils.datetime_to_str(dt)
Return type:str
s4.clarity.utils.str_to_date(string)
Return type:datetime.date
s4.clarity.utils.str_to_datetime(string)
Return type:datetime

Sorting

s4.clarity.utils.standard_sort_key(s)