sacdallago / bio_embeddings

Get protein embeddings from protein sequences
http://docs.bioembeddings.com
MIT License
460 stars 65 forks source link

Cannot Import Any Embedder "load()" has been removed, use yaml = YAML(typ='rt') yaml.load(...) #241

Open wijuliano opened 8 months ago

wijuliano commented 8 months ago

Hello everyone,

I tried to import both SeqVecEmbedder and ProtTransBertBFDEmbedder and it keeps giving the same error. I have tried uninstalling/installing again and changing Python versions. None solved my issue.

Let me know if anyone is facing the same issue and how to solve it.

`--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[2], line 1 ----> 1 from bio_embeddings.embed import ProtTransBertBFDEmbedder 2 from Bio import SeqIO

File ~/.local/lib/python3.8/site-packages/bio_embeddings/init.py:12 1 """ 2 The functionality of bio_embeddings is split into 5 different modules 3 (...) 9 bio_embeddings.visualize 10 """ ---> 12 import bio_embeddings.embed 13 import bio_embeddings.extract 14 import bio_embeddings.project

File ~/.local/lib/python3.8/site-packages/bio_embeddings/embed/init.py:67 64 import logging 65 from typing import Dict, Type ---> 67 from bio_embeddings.embed.embedder_interfaces import EmbedderInterface 68 from bio_embeddings.embed.fasttext_embedder import FastTextEmbedder 69 from bio_embeddings.embed.glove_embedder import GloveEmbedder

File ~/.local/lib/python3.8/site-packages/bio_embeddings/embed/embedder_interfaces.py:17 14 import torch 15 from numpy import ndarray ---> 17 from bio_embeddings.utilities import ( 18 get_model_file, 19 get_model_directories_from_zip, 20 get_device, 21 ) 23 logger = logging.getLogger(name) 26 class EmbedderInterface(abc.ABC):

File ~/.local/lib/python3.8/site-packages/bio_embeddings/utilities/init.py:12 8 from bio_embeddings.utilities.filemanagers.FileManagerInterface import ( 9 FileManagerInterface, 10 ) 11 from bio_embeddings.utilities.helpers import * ---> 12 from bio_embeddings.utilities.remote_file_retriever import ( 13 get_model_file, 14 get_model_directories_from_zip, 15 ) 17 all = [ 18 "FileManagerInterface", 19 "FileSystemFileManager", (...) 31 "write_fasta_file", 32 ]

File ~/.local/lib/python3.8/site-packages/bio_embeddings/utilities/remote_file_retriever.py:18 15 from bio_embeddings.utilities.config import read_config_file 17 _module_dir: Path = Path(os.path.dirname(os.path.abspath(file))) ---> 18 _defaults: Dict[str, Dict[str, str]] = read_config_file(_module_dir / "defaults.yml") 20 logger = logging.getLogger(name) 23 class TqdmUpTo(tqdm):

File ~/.local/lib/python3.8/site-packages/bio_embeddings/utilities/config.py:58, in read_config_file(config_path, preserve_order) 56 try: 57 if preserve_order: ---> 58 return yaml.load(fp, Loader=yaml.RoundTripLoader) 59 else: 60 return yaml.safe_load(fp)

File /opt/jupyterhub/lib/python3.8/site-packages/ruamel/yaml/main.py:1085, in load(stream, Loader, version, preserve_quotes) 1078 def load( 1079 stream: Any, Loader: Any = None, version: Any = None, preserve_quotes: Any = None, 1080 ) -> Any: 1081 """ 1082 Parse the first YAML document in a stream 1083 and produce the corresponding Python object. 1084 """ -> 1085 error_deprecation('load', 'load', arg=_error_dep_arg, comment=_error_dep_comment)

File /opt/jupyterhub/lib/python3.8/site-packages/ruamel/yaml/main.py:1037, in error_deprecation(fun, method, arg, comment) 1035 s += '\n' 1036 if sys.version_info < (3, 10): -> 1037 raise AttributeError(s) 1038 else: 1039 raise AttributeError(s, name=None)

AttributeError: "load()" has been removed, use

yaml = YAML(typ='rt') yaml.load(...)

and register any classes that you use, or check the tag attribute on the loaded data, instead of file "/home/juliano/.local/lib/python3.8/site-packages/bio_embeddings/utilities/config.py", line 58

            return yaml.load(fp, Loader=yaml.RoundTripLoader)