nanoporetech / minknow_api

Protobuf and gRPC specifications for the MinKNOW API
Other
50 stars 12 forks source link

Stopping a run #24

Closed JudoWill closed 3 years ago

JudoWill commented 3 years ago

Hello, I'm trying to stop a run using the api and I'm having some trouble.

I'm trying:

from minknow_api.manager import Manager
from minknow_api.acquisition_service import AcquisitionService

manager = Manager(host='localhost', port=None, use_tls=False)
aqs = AcquisitionService(manager.channel)

aqs.stop()

Which gets me an error:

_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.UNIMPLEMENTED
    details = ""
    debug_error_string = "{"created":"@1624894312.205359526","description":"Error received from peer ipv6:[::1]:9501","file":"src/core/lib/surface/call.cc","file_line":1066,"grpc_message":"","grpc_status":12}"

Am I doing something wrong in my code, do I not have something setup on the machine correctly, or something else?

Thanks for the help!

JudoWill commented 3 years ago

Running the extract_run_statistics.py hangs indefinitely but list_sequencing_positions.py runs fine. I'm not sure if that means anything.

0x55555555 commented 3 years ago

Hi @JudoWill,

For your first issue, you need to connect to a sequencing position once creating the manager position.

Please see: https://github.com/nanoporetech/minknow_api/blob/master/python/examples/list_sequencing_positions.py, where the code first connects to the manager, then enumerates positions and connects to a position:

    # Find which positions we are going to start protocol on:
    positions = list(manager.flow_cell_positions())
    filtered_positions = list(filter(lambda pos: pos.name == args.position, positions))

    # Find the position we were asked to interrogate:
    if not filtered_positions:
        print(
            "Failed to find position %s in available positions '%s'"
            % (args.position, ", ".join([p.name for p in positions]))
        )
        sys.exit(1)

    # Connect to the grpc port for the position:
    connection = filtered_positions[0].connect()

you can then use the connection object to call protocol API:

connection.protocol.stop_protocol()

Additionally, I would recommend you stop the protocol, not the acquisition as the protocol script will be confused if its acquisition period ends randomly.

JudoWill commented 3 years ago

Thanks for the reply. It wasn't as clear that I need to use the Manager to create the connections. And thanks for clearing up that its the protocol that I want to stop and not the acquisition. I'm still wrapping my head around the class structure.

I'm trying to make some automation around stopping the protocol when we have "enough" sequence. Which often happens in the middle of the night when nobody is watching. Thanks for the help!