<commit_before>#!/usr/bin/env python
from EPPs.common import StepEPP, step_argparser, get_workflow_stage


def get_parent_process_id(art):
    return art.parent_process.id


class AssignWorkflowPreSeqLab(StepEPP):

    def _run(self):
        artifact_to_route = set()
        for art in self.artifacts:
            sample = art.samples[0]
            if sample.udf.get("Proceed To SeqLab") and not sample.udf.get("2D Barcode"):
                # checks to see if sample is in plate or fluidX tube
                artifact_to_route.add(sample.artifact)

            elif sample.udf.get("Proceed To SeqLab") and sample.udf.get("2D Barcode"):
                print(2D Barcode)
                # if is a fluidX tube will need to find the derived artifact created by the FluidX Transfer step
                fluidX_artifacts = self.lims.get_artifacts(
                    process_type="FluidX Transfer From Rack Into Plate EG 1.0 ST",
                    sample_name=sample.name,
                    type='Analyte'
                )

                if len(fluidX_artifacts) >1:
                    # its possible that the FluidX Transfer has occurred more than once
                    # so must find the most recent occurrence of that step
                    fluidX_artifacts.sort(key=get_parent_process_id, reverse=True)
                    # sorts the artifacts returned to place the most recent artifact at position 0 in list

                artifact_to_route.add(fluidX_artifacts[0])

        if artifact_to_route:
            # Only route artifacts if there are any
            stage = get_workflow_stage(self.lims, "PreSeqLab EG 6.0", "Sequencing Plate Preparation EG 2.0")
            print(artifact_to_route)
            self.lims.route_artifacts(list(artifact_to_route), stage_uri=stage.uri)


def main():<commit_msg>Removed Print statements. Script seems to work now.<commit_after>#!/usr/bin/env python
from EPPs.common import StepEPP, step_argparser, get_workflow_stage


def get_parent_process_id(art):
    return art.parent_process.id


class AssignWorkflowPreSeqLab(StepEPP):

    def _run(self):
        artifact_to_route = set()
        for art in self.artifacts:
            sample = art.samples[0]
            if sample.udf.get("Proceed To SeqLab") and not sample.udf.get("2D Barcode"):
                # checks to see if sample is in plate or fluidX tube
                artifact_to_route.add(sample.artifact)

            elif sample.udf.get("Proceed To SeqLab") and sample.udf.get("2D Barcode"):
                # if is a fluidX tube will need to find the derived artifact created by the FluidX Transfer step
                fluidX_artifacts = self.lims.get_artifacts(
                    process_type="FluidX Transfer From Rack Into Plate EG 1.0 ST",
                    sample_name=sample.name,
                    type='Analyte'
                )

                if len(fluidX_artifacts) >1:
                    # its possible that the FluidX Transfer has occurred more than once
                    # so must find the most recent occurrence of that step
                    fluidX_artifacts.sort(key=get_parent_process_id, reverse=True)
                    # sorts the artifacts returned to place the most recent artifact at position 0 in list

                artifact_to_route.add(fluidX_artifacts[0])

        if artifact_to_route:
            # Only route artifacts if there are any
            stage = get_workflow_stage(self.lims, "PreSeqLab EG 6.0", "Sequencing Plate Preparation EG 2.0")
            self.lims.route_artifacts(list(artifact_to_route), stage_uri=stage.uri)


def main():
{'fraction_non_alphanumeric': 0.06963249516441006, 'fraction_numerical': 0.006907985631389887, 'mean_word_length': 2.1505657093124455, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1541662', 'n_tokens_mistral': 1089, 'n_tokens_neox': 991, 'n_words': 303}