LooseLab / readfish

CLI tool for flexible and fast adaptive sampling on ONT sequencers
https://looselab.github.io/readfish/
GNU General Public License v3.0
169 stars 33 forks source link

No module named 'minknow_api.basecaller_service' #187

Closed Nirmal2310 closed 2 years ago

Nirmal2310 commented 2 years ago

Hi @mattloose, I am getting this error while installing readfish using the conda solution. Can you please help me out?

Traceback (most recent call last):
  File "/home/fungel/miniconda3/envs/readfish/bin/readfish", line 8, in <module>
    sys.exit(main())
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/ru/cli.py", line 35, in main
    _module = importlib.import_module("ru.{}".format(module))
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/ru/ru_gen.py", line 15, in <module>
    from ru.read_until_client import RUClient
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/ru/read_until_client.py", line 13, in <module>
    from minknow_api.acquisition_pb2 import MinknowStatus
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/minknow_api/__init__.py", line 87, in <module>
    from minknow_api.manager import get_local_authentication_token_file
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/minknow_api/manager.py", line 21, in <module>
    import minknow_api.basecaller_service
ModuleNotFoundError: No module named 'minknow_api.basecaller_service'

Thank you in advance.

mattloose commented 2 years ago

Which conda solution did you use?

Nirmal2310 commented 2 years ago

I used the solution listed in this issue with changing dev to guppy_6. https://github.com/LooseLab/readfish/issues/124#issuecomment-759599319

mattloose commented 2 years ago

Could you please check the version of minknow_api and ont-pyguppy-client-lib you have installed in that environment?

You need to match ont-pyguppy-client-lib to your installed version of guppy. Minknow_api should also match your installed version of minknow - I note the API was updated three days ago and we may need to check for issues there. However - this will be tomorrow before we can check!

alexomics commented 2 years ago

Ah, a new version (v5.0.0) of the MinKNOW API was released last Friday.

What version of MinKNOW-core are you using? You can find this in:

Then you will need to use the following yaml for the conda environemnt file and re-build the environment, replacing the question marks at the end to match your MinKNOW-core version.

name: readfish
channels:
  - bioconda
  - conda-forge
  - defaults
dependencies:
  - python=3.7
  - pip
  - pip:
    - read-until==3.0.0
    - ont-pyguppy-client-lib==4.2.3
    - git+https://github.com/LooseLab/readfish@dev
    - minknow-api==4.?.?
mattloose commented 2 years ago

Just to add to alex's comment - you need to make sure you have the correct version of ont-pyguppy-client-lib as well.

Nirmal2310 commented 2 years ago

Hi, one doubt the ont-pyguppy-client-lib version should be matching with the guppy basecaller version right?

mattloose commented 2 years ago

yes - that's correct - match it with the guppy basecaller version

alexomics commented 2 years ago

That is right, you can find this version by running:

guppy_basecall_server --version
Nirmal2310 commented 2 years ago

Hi, so I tried this yml file and still got the same error:

name: readfish
channels:
  - bioconda
  - conda-forge
  - defaults
dependencies:
  - python=3.7
  - pip
  - pip:
    - read-until==3.0.0
    - ont-pyguppy-client-lib==6.0.6
    - git+https://github.com/LooseLab/readfish@guppy_6
    - minknow-api==5.0.0
alexomics commented 2 years ago

Do you know that you have MinKNOW-core v5.0.0 installed? What is the version that the MinKNOW user interface says is installed?

Nirmal2310 commented 2 years ago

So, I am attaching a picture from my MinKnow GUI hope it will help: Screenshot from 2022-03-29 02-13-56

alexomics commented 2 years ago

Can you try and downgrade the version of the MinKNOW API to 4.5.0?

It's late here now, so I'll have to pick this up tomorrow

Nirmal2310 commented 2 years ago

Yeah sure, its late here too so I will also try this tomorrow. Sorry for the delay and thank you for these quick responses.

Nirmal2310 commented 2 years ago

Hi, I went through nanopore community and all I found is that there is no way through which I can roll back to a previous MinKNOW version.

alexomics commented 2 years ago

Sorry, that wasn’t clear of me before. Could you try using the v4.5.0 of the MinKNOW API in the conda environment?

Nirmal2310 commented 2 years ago

On it.

Nirmal2310 commented 2 years ago

Hi, so I tried changing the api version to 4.5.0 and it worked. Thank you so much for all your help.

alexomics commented 2 years ago

Fantastic! I’ll check with ONT about this version number mismatch.

Nirmal2310 commented 2 years ago

Hi, sorry to bother you again but now when I am trying to run targets or unblock-all subcommand this is the error I am getting judging from the previously mentioned issue I think it has something to do with minknow-api:

Traceback (most recent call last):
  File "/home/fungel/miniconda3/envs/readfish/bin/readfish", line 8, in <module>
    sys.exit(main())
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/ru/cli.py", line 43, in main
    args.func(parser, args)
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/ru/unblock_all.py", line 127, in run
    position = get_device(args.device, host=args.host, port=args.port)
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/ru/utils.py", line 918, in get_device
    manager = Manager(host=host, port=port, use_tls=use_tls)
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/minknow_api/manager.py", line 156, in __init__
    version_info = self.rpc.get_version_info()
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/minknow_api/manager_service.py", line 418, in get_version_info
    "minknow_api.manager.ManagerService")
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/minknow_api/manager_service.py", line 78, in run_with_retry
    result = MessageWrapper(method(message, timeout=timeout), unwraps=unwraps)
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/grpc/_channel.py", line 946, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/grpc/_channel.py", line 849, in _end_unary_response_blocking
    raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.UNAVAILABLE
    details = "failed to connect to all addresses"
    debug_error_string = "{"created":"@1648533285.315601330","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":3128,"referenced_errors":[{"created":"@1648533285.315600712","description":"failed to connect to all addresses","file":"src/core/lib/transport/error_utils.cc","file_line":163,"grpc_status":14}]}"
alexomics commented 2 years ago

This is another MinKNOW API related issue. Might be a little harder to pin down 😅

Was the device running/sequencing when you tried starting readfish? What was the command you used to start readfish?

Nirmal2310 commented 2 years ago

Hi, yes the device was running and I used the following command:

readfish unblock-all --device MN37483 --experiment-name "Testing ReadFish Unblock All"
alexomics commented 2 years ago

Okay, with the readfish conda environment activated and the sequencer running, could you run:

python -c "from minknow_api.manager import Manager as M; mg=M('localhost', 9501, False); print([pos.name for pos in mg.flow_cell_positions()])

I’m just checking how we are connecting to MinKNOW.

Nirmal2310 commented 2 years ago

Ok I am trying

Nirmal2310 commented 2 years ago

Hi, according to this issue listed in minknow_api github page port 9501 is not working. You can have a look: https://github.com/nanoporetech/minknow_api/issues/16

alexomics commented 2 years ago

Yeah, port 9502 (secure/TLS) has been preferred for a while. This might need a small change to how we connect to MinKNOW to get running.

If I push a couple of changes could you test out another branch?

Nirmal2310 commented 2 years ago

Hi I got the following output:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/minknow_api/manager.py", line 156, in __init__
    version_info = self.rpc.get_version_info()
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/minknow_api/manager_service.py", line 418, in get_version_info
    "minknow_api.manager.ManagerService")
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/minknow_api/manager_service.py", line 78, in run_with_retry
    result = MessageWrapper(method(message, timeout=timeout), unwraps=unwraps)
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/grpc/_channel.py", line 946, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/home/fungel/miniconda3/envs/readfish/lib/python3.7/site-packages/grpc/_channel.py", line 849, in _end_unary_response_blocking
    raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.UNAVAILABLE
    details = "failed to connect to all addresses"
    debug_error_string = "{"created":"@1648535463.405529824","description":"Failed to pick subchannel","file":"src/core/ext/filters/client_channel/client_channel.cc","file_line":3128,"referenced_errors":[{"created":"@1648535463.405528733","description":"failed to connect to all addresses","file":"src/core/lib/transport/error_utils.cc","file_line":163,"grpc_status":14}]}"
>
Nirmal2310 commented 2 years ago

Yeah sure I would be happy to do so.

alexomics commented 2 years ago

Okay, one more quick test! Here we are trying the secure connection:

python -c "from minknow_api.manager import Manager as M; mg=M('localhost', 9502); print([pos.name for pos in mg.flow_cell_positions()])
Nirmal2310 commented 2 years ago

Hi, I got this output:

['MN37483']
alexomics commented 2 years ago

Nice, that's the output we are looking for!

I've pushed a small change to a new branch (issue187) that you can install into the readfish conda environment either by running:

python -m pip install --upgrade git+https://github.com/LooseLab/readfish@issue187

Or, changing the YAML file that you originally used to create the env, re-creating the conda environment entirely.

Then when running readfish you can use the following command to connect using the secure connection.

readfish unblock-all --device MN37483 --use-tls --port 9502 --experiment-name "Testing ReadFish Unblock All"
Nirmal2310 commented 2 years ago

Hi, I will try this in a bit and get back to you. Thank you so much for such a fast response.

mattloose commented 2 years ago

We have tracked the original minknow_api issue to the latest release of the minknow_api and have reported this there:

https://github.com/nanoporetech/minknow_api/issues/36

alexomics commented 2 years ago

As a temporary fix allowing the use of the minknow_api v5.0.0 you can install directly from the Git repo using the following conda environment:

name: readfish
channels:
  - bioconda
  - conda-forge
  - defaults
dependencies:
  - python=3.7
  - pip
  - pip:
    - git+https://github.com/nanoporetech/read_until_api@v3.0.0
    - ont-pyguppy-client-lib==6.0.6
    - git+https://github.com/LooseLab/readfish@issue187
    - git+https://github.com/nanoporetech/minknow_api@5.0.0#subdirectory=python
alexomics commented 2 years ago

@Nirmal2310 I've just removed the --use-tls option that I added earlier. If you re-generate the conda env as in https://github.com/LooseLab/readfish/issues/187#issuecomment-1081854776 you should be able to connect and run readfish.

Please let me know how it goes!

Nirmal2310 commented 2 years ago

Hi, yes I will try this out today and will let you know. Thank you so much for this.

Nirmal2310 commented 2 years ago

Hi, so I tried the above installation and now I can use all the functionality of readfish. Thank you so much for solving this error for me.

hasindu2008 commented 2 years ago

This was very helpful in fixing the --use-tls today I faced with the latest minknow update for fishing on LSK112-Q20