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

bug: protocol.set_rail_lights() is not working from OT2 Jupyter notebook #7179

Closed
kasuskasus1 opened this issue Jan 6, 2021 · 3 comments
Closed
Labels
support Ticket requires support team follow-up

Comments

@kasuskasus1
Copy link

Overview

protocol.set_rail_lights() is not working from OT2 Jupyter notebook

Steps to reproduce

  • Create Jupyter network at <ROBOT_IP>:48888
  • Add the following code:
import opentrons.execute
from time import sleep
protocol = opentrons.execute.get_protocol_api('2.8')

def run(protocol):
    protocol.set_rail_lights(True)
    print(protocol.rail_lights_on)
    sleep(5)
    protocol.set_rail_lights(False)
    print(protocol.rail_lights_on)

run(protocol)

Current behavior

Produced output:

True

after 5 sec:

True

Lights are not turning on and then off.

Expected behavior

Expect lights to turn on and then turn off after 5 sec.

@kasuskasus1 kasuskasus1 added the bug label Jan 6, 2021
@chazmanc
Copy link
Contributor

@kasuskasus1 instead of using pause(5), you can use protocol.delay(seconds=5) - this should give you the expected behavior in the meantime

@alexjoel42
Copy link
Contributor

alexjoel42 commented Jan 21, 2021

Hi there!
Thank you for your patience on this one.

In appreciation of your patience, I have made a sample protocol that should help you with this task:

Note the OT-2's circuitboard that controls the lights, rail lights, etc. can only take one connection and has to chose between the App and Jupyter Notebook.

That is why we need to run:
import os
os.system("systemctl stop opentrons-robot-server")
in the protocol to make sure that the OT-2 only recognizes the Jupyter Notebook Connection (Theo makes a good point of this here #6164 (comment) )

My recommendation is to divide the protocol into three cells:

  1. Stoping the robot server so Jupyter Notebook can control lights
  2. controlling lights for a protocol
  3. restarting the server so that you can use the app

Cell One, before you manipulate lights

import opentrons.execute
import os

os.system("systemctl stop opentrons-robot-server")

Cell Two Manipulating Lights

import opentrons.execute
import os

protocol = opentrons.execute.get_protocol_api('2.8') 
protocol.home()
protocol.set_rail_lights(False)
protocol.set_rail_lights(True)
protocol.comment('light is on')
protocol.delay(seconds = 20)
protocol.set_rail_lights(False)
protocol.comment('light is off')
#resetting the server 
for line in protocol.commands():
    print(line)

Cell Three Restarting the Server so that the App can connect

os.system("systemctl start opentrons-robot-server")

For Reference

Screen Shot 2021-01-21 at 4 48 52 PM

Here are some resources to make your own code based on the example above.

  1. Our Jupyter Notebook code is a bit differently organized than our normal def run() protocols so you would have to adjust it.
  2. We also have a resource for how to make Jupyter Notebook work with the rail lights

Important Note

Unless there is a really compelling reason, I wouldn't normally recommend Jupyter notebook to run protocols. Regardless of whether you use Jupyter Notebook, all labware calibration still need to be done on the app before running.

There are also some "Out of Bounds Errors" that don't really mean it is going to cause an issue but are pretty alarming. If there are any collisions that occur, then you can do a Calibration Health Check and if that doesn't help resolve the issue you can contact Opentrons Support at [email protected]
Screen Shot 2021-01-21 at 4 54 50 PM

Second Note:

Sometimes stopping the robot server can cause weird issues. If you run

os.system("systemctl start opentrons-robot-server")
It should respond with zero. If it doesn't you can do the following steps:

  1. Go to the "Running" tab
  2. Shut down all kernels
  3. open a new file with
import os 
os.system("systemctl start opentrons-robot-server")
  1. If that doesn't work. Restart your OT-2, see if your Ot-2 connects, and if it doesn't contact Opentrons Support at [email protected].

@mcous mcous added support Ticket requires support team follow-up and removed bug labels Jan 21, 2021
@mcous
Copy link
Contributor

mcous commented Jan 21, 2021

This is expected behavior if you do not, stop the opentrons-robot-server first. @alexjoel42's solution should work.

Since this is expected behavior and the system prints a warning to stop opentrons-robot-server before trying to interact with the rail lights in Jupyter, I'm going to close this issue. Please feel free to continue posting in this thread with questions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Ticket requires support team follow-up
Projects
None yet
Development

No branches or pull requests

4 participants