EdinburghGenomics / pyclarity-lims

Python interface to the GenoLogics LIMS server via its REST API.
MIT License
11 stars 4 forks source link

next_actions only if condition #36

Closed dbarrell closed 6 years ago

dbarrell commented 6 years ago

Hi, I'd like to 'Mark protocol as complete' for each sample ONLY IF 'Samples that passed Aggregate_QC...' is true:

clarity_complete_if_passed_aggregate

I can manually mark as complete using something like:

# TODO: this currently doesn't check the status of the QC flags.
step_actions = step.actions
for artifact in step_actions.next_actions:
    actions = artifact['action'] = 'complete'
step.actions.put()

However, I'd like the code to emulate the check that is performed when hitting 'Apply' in the screenshot. Is it just a matter of checking the QC flag for each sample or is there functionality in pyclarity-lims to do this in one easy step as one would do in the web interface?

Thanks

Dan

tcezard commented 6 years ago

Hi Dan, I think you should have access to the QC flag in the artifact entity. Just be carefull in your code the variable you called artifact is a dictionary that contains the Artifact. I would probably do something like that (code is not tested)

step_actions = step.actions
for next_action in step_actions.next_actions:
    if next_action['artifact'].qc_flag == 'PASSED':
        next_action['action'] = 'complete'
    else:
        # probably requeue ? 
step.actions.put()

Checkout the next action and qc_flag doc

dbarrell commented 6 years ago

Thanks, that was just what was needed.