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

Module not found error #2

Closed
alexmunroclark opened this issue Feb 17, 2022 · 5 comments
Closed

Module not found error #2

alexmunroclark opened this issue Feb 17, 2022 · 5 comments

Comments

@alexmunroclark
Copy link

Hi there,

I've been trying to run your code on Spyder through Anaconda, but I've been having trouble running the following line:
>>run casanovo --mode=denovo --model_path='pretrained_excl_clambacteria.ckpt' --test_data_path='dark_control_1.mgf' --config_path='config' --output_path='test.csv'

The following error is reported back:
**Traceback (most recent call last):

File "F:\Applications\Noble\casanovo\casanovo.py", line 3, in
from casanovo.denovo import train, test_evaluate, test_denovo

ModuleNotFoundError: No module named 'casanovo.denovo'; 'casanovo' is not a package**

I've noticed that some of the files being called appear to have different names to their current version on GitHub.
E.g. in casanovo.py, it tries to import 'train', 'test_evaluate', and 'test_denovo' from casanovo/denovo.
However, in this directory the files are named 'train_test', 'evaluate', and 'model'.

Having played around changing the relevant lines in this file to get it to work, it brought forth more import errors from other files.
Eventually 'fixing' them produces a circular import so I don't think what I've done is correct.
Do you know what might be causing this error? Am I correct in thinking these files are currently mis-named?

Any help would be greatly appreciated.
Best wishes,
Alex

@wfondrie
Copy link
Collaborator

Hi Alex,

I'm not familiar with running command line tools within Spider, but this error seems to indicate that casanovo is not installed as a Python package in your current environment. What do you get when you run the following?

pip show casanovo

If casanovo was successfully installed, the output should look something like this:

Name: casanovo
Version: 0.1.dev13+gecf4884
Summary: De Novo Mass Spectrometry Peptide Sequencing with a Transformer Model
Home-page: https://github.com/Noble-Lab/casanovo
Author: Melih Yilmaz
Author-email: melih@cs.washington.edu
License: Apache 2.0
Location: /usr/local/anaconda3/lib/python3.8/site-packages
Requires: click, depthcharge-ms, numpy, pandas, pytorch-lightning, scikit-learn, spectrum-utils, torch
Required-by:

@alexmunroclark
Copy link
Author

Hi,

Yes running
pip show casanovo

is returning

Name: casanovo Version: 0.1.dev13+gecf4884 Summary: De Novo Mass Spectrometry Peptide Sequencing with a Transformer Model Home-page: https://github.com/Noble-Lab/casanovo Author: Melih Yilmaz Author-email: melih@cs.washington.edu License: Apache 2.0 Location: f:\applications\anaconda\lib\site-packages Requires: depthcharge-ms, click, numpy, torch, pytorch-lightning, scikit-learn, spectrum-utils, pandas Required-by:

@melihyilmaz
Copy link
Collaborator

Hi Alex,

run casanovo --mode=denovo --model_path='pretrained_excl_clambacteria.ckpt' --test_data_path='dark_control_1.mgf' --config_path='config' --output_path='test.csv'

You seem to have a run at the beginning of your command, did you try executing the command without it?

Also the imports you mention are actually consistent and you can confirm this by checking the imports in denovo/__init__.py, which we access when from casanovo.denovo import is called in casanovo.py.

@alexmunroclark
Copy link
Author

Hi Melih,

I think I have solved the install issue.
I was trying to install it with Python 3.10 and it appears torch is not fully supported on it yet and was going unreported when trying to install through Spyder.
Downgrading Python to 3.9 and installing through the command line correctly installed it and the packages are called perfectly.

I have however had issues trying to load in my datasets.
The example command is:
casanovo --mode=denovo --model_path='path/to/pretrained' --test_data_path='path/to/test' --config_path='path/to/config' --output_path='path/to/output'

I've tried different combinations of the following for the paths but have had no luck.

  • Specifying the paths as: path='path/to/file.mgf' and path='path/to/folder'
  • Writing the paths as: path='paths/specified/with/quotes' and path=paths/without/quotes.
  • Writing the paths with: path='paths/with/forward/slash' and path='paths\with\back\slash'.
    I've put a few examples at the end of this message.

Could you please give some guidance on the best way to call the script with the correct arguments on Windows?

Best wishes,
Alex

A couple of examples:

casanovo --mode=denovo --model_path='F:\PhD_Data\Casanovo_Data' --test_data_path='F:\PhD_Data\Casanovo_Data' --config_path=F:\PhD_Data\Casanovo_Data' --output_path='F:\PhD_Data\Casanovo_Data'
casanovo --mode=denovo --model_path='F:\PhD_Data\Casanovo_Data\pretrained_excl_clambacteria.ckpt' --test_data_path='F:\PhD_Data\Casanovo_Data\dark_control_1.mgf' --config_path='F:\PhD_Data\Casanovo_Data\config_params.py' --output_path='F:\PhD_Data\Casanovo_Data\Output.csv'
casanovo --mode=denovo --model_path=F:\PhD_Data\Casanovo_Data\pretrained_excl_clambacteria.ckpt --test_data_path=F:\PhD_Data\Casanovo_Data\dark_control_1.mgf --config_path=F:\PhD_Data\Casanovo_Data\config_params.py --output_path=F:\PhD_Data\Casanovo_Data\Output.csv
casanovo --mode=denovo --model_path=F:/PhD_Data/Casanovo_Data/pretrained_excl_clambacteria.ckpt --test_data_path=F:/PhD_Data/Casanovo_Data/dark_control_1.mgf --config_path=F:/PhD_Data/Casanovo_Data/config_params.py --output_path=F:/PhD_Data/Casanovo_Data/Output.csv

@melihyilmaz
Copy link
Collaborator

Hi Alex,

I just pushed a fix to solve the issue. You should provide paths with forward slash as shown in sample commands path/to/pretrained. More importantly, test_data_path, and other _data_path arguments as well, should point to a directory of mgf files, not a single mgf file.

Let me know if the issue is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants