Not able to use NERModel due to import issue from SimpleTransformers

671 views Asked by At

I'm trying to use SimpleTransformers module for this competition.

After successfully installing the package SimpleTransformers in kernel , i'm trying to import NERModel and NERArgs packages from simpletransformers.ner. But i get error message as below.

**
!pip install SimpleTransformers
#(The above statement works fine.)
from simpletransformers.ner import NERModel,NERArgs
#(While executing the above statement , getting below error)
ImportError Traceback (most recent call last)
in
1 get_ipython().system('pip install --upgrade fsspec')
----> 2 from simpletransformers.ner import NERModel,NERArgs
/opt/conda/lib/python3.7/site-packages/simpletransformers/ner/init.py in
1 from simpletransformers.config.model_args import NERArgs
----> 2 from simpletransformers.ner.ner_model import NERModel
/opt/conda/lib/python3.7/site-packages/simpletransformers/ner/ner_model.py in
30 )
31 from transformers.optimization import AdamW, Adafactor
---> 32 from transformers import (
33 AlbertConfig,
34 AlbertForTokenClassification,
/opt/conda/lib/python3.7/site-packages/transformers/init.py in getattr(self, name)
2485 if name == "version":
2486 return version
-> 2487 return super().getattr(name)
2488
2489 sys.modules[name] = _LazyModule(name, _import_structure)
/opt/conda/lib/python3.7/site-packages/transformers/file_utils.py in getattr(self, name)
1698 elif name in self._class_to_module.keys():
1699 module = self._get_module(self._class_to_module[name])
-> 1700 value = getattr(module, name)
1701 else:
1702 raise AttributeError(f"module {self.name} has no attribute {name}")
/opt/conda/lib/python3.7/site-packages/transformers/file_utils.py in getattr(self, name)
1697 value = self._get_module(name)
1698 elif name in self._class_to_module.keys():
-> 1699 module = self._get_module(self._class_to_module[name])
1700 value = getattr(module, name)
1701 else:
/opt/conda/lib/python3.7/site-packages/transformers/models/auto/init.py in _get_module(self, module_name)
196
197 def _get_module(self, module_name: str):
--> 198 return importlib.import_module("." + module_name, self.name)
199
200 sys.modules[name] = _LazyModule(name, _import_structure)
/opt/conda/lib/python3.7/importlib/init.py in import_module(name, package)
125 break
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
128
129
/opt/conda/lib/python3.7/site-packages/transformers/models/auto/modeling_auto.py in
197 from ..pegasus.modeling_pegasus import PegasusForCausalLM, PegasusForConditionalGeneration, PegasusModel
198 from ..prophetnet.modeling_prophetnet import ProphetNetForCausalLM, ProphetNetForConditionalGeneration, ProphetNetModel
--> 199 from ..rag.modeling_rag import ( # noqa: F401 - need to import all RagModels to be in globals() function
200 RagModel,
201 RagSequenceForGeneration,
/opt/conda/lib/python3.7/site-packages/transformers/models/rag/modeling_rag.py in
27 from …utils import logging
28 from .configuration_rag import RagConfig
---> 29 from .retrieval_rag import RagRetriever
30
31
/opt/conda/lib/python3.7/site-packages/transformers/models/rag/retrieval_rag.py in
37
38 if is_datasets_available():
---> 39 from datasets import Dataset, load_dataset, load_from_disk
40
41 if is_faiss_available():
/opt/conda/lib/python3.7/site-packages/datasets/init.py in
31 )
32
---> 33 from .arrow_dataset import Dataset, concatenate_datasets
34 from .arrow_reader import ArrowReader, ReadInstruction
35 from .arrow_writer import ArrowWriter
/opt/conda/lib/python3.7/site-packages/datasets/arrow_dataset.py in
44 from .arrow_writer import ArrowWriter, OptimizedTypedSequence
45 from .features import ClassLabel, Features, Value, cast_to_python_objects
---> 46 from .filesystems import extract_path_from_uri, is_remote_filesystem
47 from .fingerprint import (
48 fingerprint_transform,
/opt/conda/lib/python3.7/site-packages/datasets/filesystems/init.py in
7
8 if _has_s3fs:
----> 9 from .s3filesystem import S3FileSystem # noqa: F401
10
11
/opt/conda/lib/python3.7/site-packages/datasets/filesystems/s3filesystem.py in
----> 1 import s3fs
2
3
4 class S3FileSystem(s3fs.S3FileSystem):
5 """
/opt/conda/lib/python3.7/site-packages/s3fs/init.py in
----> 1 from .core import S3FileSystem, S3File
2 from .mapping import S3Map
3
4 from ._version import get_versions
5
/opt/conda/lib/python3.7/site-packages/s3fs/core.py in
9
10 from fsspec.spec import AbstractBufferedFile
---> 11 from fsspec.utils import infer_storage_options, tokenize, setup_logging
12 from fsspec.asyn import AsyncFileSystem, sync, sync_wrapper
13
ImportError: cannot import name 'setup_logging' from 'fsspec.utils' (/opt/conda/lib/python3.7/site-packages/fsspec/utils.py)

This has become show stopper for me in kaggle.The same code works in Colab.Please advice.**

Thanks, Shyam.

1

There are 1 answers

0
Eduardo Morais On

fsspec==0.9.0 has the function fsspec.utils.setup_logging but earlier versions do not

Try pip install fsspec==0.9.0

see: https://githubmemory.com/repo/dask/s3fs/activity?page=3