EdinburghGenomics / pyclarity-lims

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

Process creation #8

Closed tcezard closed 7 years ago

tcezard commented 7 years ago

This PR adds the ability to create, fill in and complete a step through the API. The usage is still a bit clunky and could be made cleaner but it all works. There are also a few bug fixes Here is how you create a Step

# Retrieve samples/artifact/workflow stage
samples = l.get_samples(projectname='T00001')
art = samples[0].artifact
stage = l.get_workflows(name='Email Test')[0].stages[0]

# Queue the artifacts to the stage
l.route_artifacts([art], stage_uri=stage.uri)

#Create a new step from that queued artifact (container_type_name is optional if only one container type is permitted)
s=Step.create(l, protocol_step=stage.step, inputs=[art], container_type_name='Tube')

# Create the output container
ct = l.get_container_types(name='Tube')[0]
c = Container.create(l, type=ct)

# Retrieve the output artifact that was generated automatically from the input/output map
output_art = s.details.input_output_maps[0][1]['uri']

# Place the output artifact in the container
output_placement_list=[[output_art, (c, '1:1')]]
s.set_placements([c], output_placement_list)

# Move from "Record detail" window to the "Next Step"
s.advance()

# Set the next step
actions = s.actions.next_actions
actions[0]['action'] = 'complete'
s.actions.next_actions = actions
s.actions.put()

# Complete the step
s.advance()
coveralls commented 7 years ago

Coverage Status

Coverage increased (+6.001%) to 73.813% when pulling 5446ee82c8a8cb3fa5632b86554b1e7b4b962acf on Process_creation into 14dae08ac127b86df96b326ce466d4c4854dff2c on master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+6.001%) to 73.813% when pulling 5446ee82c8a8cb3fa5632b86554b1e7b4b962acf on Process_creation into 14dae08ac127b86df96b326ce466d4c4854dff2c on master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+6.5%) to 74.307% when pulling f9af80d570ccf9b072ffc1fd957c230d4d8e3661 on Process_creation into 14dae08ac127b86df96b326ce466d4c4854dff2c on master.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+6.9%) to 74.672% when pulling 3540fe207514d91e317f89ed2a96934a8c3dd9e4 on Process_creation into 14dae08ac127b86df96b326ce466d4c4854dff2c on master.

tcezard commented 7 years ago

I've made some modification in the way the output placement and the next actions are handled.

# Retrieve samples/artifact/workflow stage
samples = l.get_samples(projectname='T00001')
art = samples[0].artifact
# Find workflow 'Email Test' and take its first stage
stage = l.get_workflows(name='Email Test')[0].stages[0]

# Queue the artifacts to the stage
l.route_artifacts([art], stage_uri=stage.uri)

# Create a new step from that queued artifact (container_type_name is optional if only one container type is permitted)
s = Step.create(l, protocol_step=stage.step, inputs=[art], container_type_name='Tube')

# Create the output container
ct = l.get_container_types(name='Tube')[0]
c = Container.create(l, type=ct)

# Retrieve the output artifact that was generated automatically from the input/output map
output_art = s.details.input_output_maps[0][1]['uri']

# Place the output artifact in the container
# Note that the placements is a list of tuple ( A, ( B, C ) )
# Where A is output artifact, B the output Container and C the location on this container
output_placement_list=[(output_art, (c, '1:1'))]
# set_placements creates the placement entity and "put" it  
s.set_placements([c], output_placement_list)

# Move from "Record detail" window to the "Next Step"
s.advance()

# Set the next step
actions = s.actions.next_actions[0]['action'] = 'complete'
s.actions.put()

# Complete the step
s.advance()

Hope this makes sense

coveralls commented 7 years ago

Coverage Status

Coverage increased (+6.8%) to 74.635% when pulling 5c0048e205544a2cd77674d4713c3749a0866e9e on Process_creation into 14dae08ac127b86df96b326ce466d4c4854dff2c on master.