Open ranjan-sumit opened 2 years ago
Yup, still waiting for an update to fastcore.
Anywhere you see AttributeError: 'method-wrapper' object has no attribute 'annotations'
... its due to a bug in the current version of fastcore. I know this is resolved in github, but I have yet to see a release.
Hi ,
I am getting issue with below block, my code was running fine a week back, I am getting this issue from last 3 days, I think it is due to fastcore update please check it once : dblock = DataBlock( blocks=blocks, get_x=ColReader("text"), get_y=ColReader("label"), splitter=ColSplitter() )
Below error triggered
AttributeError Traceback (most recent call last) in
8 get_x=ColReader("text"),
9 get_y=ColReader("label"),
---> 10 splitter=ColSplitter()
11 )
12
2 frames /usr/local/lib/python3.7/dist-packages/fastcore/meta.py in _init(self, *args, *kwargs) 148 if isinstance(arg,MethodType): arg = MethodType(arg.func, self) 149 setattr(self, k, arg) --> 150 old_init(self, args, **kwargs) 151 functools.update_wrapper(_init, old_init) 152 cls.init = use_kwargs(cls._methods)(_init)
/usr/local/lib/python3.7/dist-packages/fastai/data/block.py in init(self, blocks, dl_type, getters, n_inp, item_tfms, batch_tfms, *kwargs) 97 if getattr(b, 'dl_type', None) is not None: self.dl_type = b.dl_type 98 if dl_type is not None: self.dl_type = dl_type ---> 99 self.dataloaders = delegates(self.dl_type.init)(self.dataloaders) 100 self.dls_kwargs = merge(blocks.attrgot('dls_kwargs', {})) 101
/usr/local/lib/python3.7/dist-packages/fastcore/meta.py in _f(f) 123 s2 = {k:v.replace(kind=inspect.Parameter.KEYWORD_ONLY) for k,v in inspect.signature(to_f).parameters.items() 124 if v.default != inspect.Parameter.empty and k not in sigd and k not in but} --> 125 anno = {k:v for k,v in to_f.annotations.items() if k not in sigd and k not in but} 126 sigd.update(s2) 127 if keep: sigd['kwargs'] = k
AttributeError: 'method-wrapper' object has no attribute 'annotations'
I am just running the code https://pypi.org/project/ohmeow-blurr/0.0.7/. It is giving the same error: Here is code snip as well:
import os, warnings
import torch from transformers import from transformers.utils import logging as hf_logging from fastai.text.all import
from blurr.text.data.all import from blurr.text.modeling.all import
path = untar_data(URLs.IMDB_SAMPLE)
model_path = Path("models") imdb_df = pd.read_csv(path / "texts.csv")
n_labels = len(imdb_df["label"].unique())
model_cls = AutoModelForSequenceClassification
pretrained_model_name = "bert-base-uncased"
config = AutoConfig.from_pretrained(pretrained_model_name) config.num_labels = n_labels
hf_arch, hf_config, hf_tokenizer, hf_model = get_hf_objects( pretrained_model_name, model_cls=model_cls, config=config )
single input
blocks = ( TextBlock(hf_arch, hf_config, hf_tokenizer, hf_model), CategoryBlock ) dblock = DataBlock( blocks=blocks, get_x=ColReader("text"), get_y=ColReader("label"), splitter=ColSplitter() )
dls = dblock.dataloaders(imdb_df, bs=4)
Note: dblock is giving error here