nanoporetech / minknow_api

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

user provided name through api #9

Closed svennd closed 3 years ago

svennd commented 3 years ago

I have played a bit with the demo provided, but so far have not been successful; Is it possible to check on a remote machine if a run has started and if so, what the name the user has provided ?

My initial attempt is to connect to the manager to get all the positions, then connect to device to see if has_flow_cell is true; I then attempted to find through the protocol but beside the fact that its stored in /data I couldn't find the name the user has provided in the interface; I could find "acquisition_run_ids" so perhaps I should query those with something ?

I'm not familiar with gRPC but i'm happy to learn new stuff; if there is however a easier stable method I'm all ear !

Any help would be greatly appreciated :)

Edward-Knight commented 3 years ago

Hi svennd 👋

You can check if a run has started by calling list_protocol_runs: https://github.com/nanoporetech/minknow_api/blob/597d807897c44c804c49d33643b38aec04dc0531/proto/minknow_api/protocol.proto#L44-L49 I believe you're looking for the experiment name or sample ID? Both of which can be found here: https://github.com/nanoporetech/minknow_api/blob/597d807897c44c804c49d33643b38aec04dc0531/proto/minknow_api/protocol.proto#L106-L114 You can retrieve this information from the user_info attribute of the ProtocolRunInfo response: https://github.com/nanoporetech/minknow_api/blob/597d807897c44c804c49d33643b38aec04dc0531/proto/minknow_api/protocol.proto#L308-L311 Which is returned from the get_run_info request, amongst others: https://github.com/nanoporetech/minknow_api/blob/597d807897c44c804c49d33643b38aec04dc0531/proto/minknow_api/protocol.proto#L36-L42

I hope this helps!

svennd commented 3 years ago

Hey Edward-Knight,

Thanks for your help!

Ah I had overlooked that output ! Just below what you suggested is also the full path stored in "output_path"; both useful values :)

To see if a run is still going, I got a respond from list_protocol_runs, I get multiple run_ids reported while to my knowledge we only ran 1 protocol per flowcell, or are these all the runs for this position ? Anyway I tried to get more info on these run_ids with get_run_info(); But I assume I need to craft a GetRunInfoRequest() with the run id somehow ? Could you perhaps provide an example ? I tried and obv. failed due to lack of knowledge on the subject;

Changes to the demo : (after checking if there is a flow_cell in the position)

from minknow_api import protocol_pb2 as protgrpc

               instance = position_connection.protocol.list_protocol_runs()
               runs = instance.run_ids
               for run in runs:
                  req = protgrpc.GetRunInfoRequest(run)
                  info = position_connection.protocol.get_run_info(req)
                  pprint(info)
0x55555555 commented 3 years ago

Hi @svennd, in order to get more info from a protocol, try:

In minknow_api, the connection object automatically builds the request object for you - so just pass the named parameter run_id to the get_run_info command:

from minknow_api import protocol_pb2 as protgrpc

               instance = position_connection.protocol.list_protocol_runs()
               runs = instance.run_ids
               for run in runs:
                  info = position_connection.protocol.get_run_info(run_id=run)
                  pprint(info)
svennd commented 3 years ago

Thanks both, with your help I found what I was searching for ! I found acquisition_state which I was looking for; thanks for the support !