bentoml / BentoML

The easiest way to serve AI apps and models - Build Model Inference APIs, Job queues, LLM apps, Multi-model pipelines, and more!
https://bentoml.com
Apache License 2.0
7.15k stars 791 forks source link

'ModelInfo' object has no attribute '__attrs_init__' #2609

Closed ebbunnim closed 2 years ago

ebbunnim commented 2 years ago

Describe the bug

AttributeError occurs when executing the sample code below. (1.0.0-rc1 version) Please tell me how to solve it.

import bentoml
from sklearn import svm
from sklearn import datasets

iris = datasets.load_iris()
X, y = iris.data, iris.target

clf = svm.SVC(gamma='scale')
clf.fit(X, y)
bentoml.sklearn.save_model("iris_clf", clf)

To Reproduce

Expected behavior

save model normally

Screenshots/Logs

2022/06/17 11시 20분 00초 INFO     [cli] Using the default model signature for sklearn ({'predict': {'batchable': False}}) for model iris_clf.                                                                 
Traceback (most recent call last):
  File "pipeline.py", line 57, in <module>
    bentoml.sklearn.save_model("iris_clf", clf)
  File "/Users/jaylene/opt/anaconda3/envs/py38_pre/lib/python3.8/site-packages/bentoml/_internal/frameworks/sklearn.py", line 156, in save_model
    with bentoml.models.create(
  File "/Users/jaylene/opt/anaconda3/envs/py38_pre/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/Users/jaylene/opt/anaconda3/envs/py38_pre/lib/python3.8/site-packages/bentoml/models.py", line 239, in create
    res = Model.create(
  File "/Users/jaylene/opt/anaconda3/envs/py38_pre/lib/python3.8/site-packages/bentoml/_internal/models/model.py", line 191, in create
    ModelInfo(
  File "/Users/jaylene/opt/anaconda3/envs/py38_pre/lib/python3.8/site-packages/bentoml/_internal/models/model.py", line 497, in __init__
    self.__attrs_init__(  # type: ignore
AttributeError: 'ModelInfo' object has no attribute '__attrs_init__'

Environment:

Additional context

bojiang commented 2 years ago

@ebbunnim Hi. I can not reproduce it. Could you please run the command pip freeze and paste the result here?

ebbunnim commented 2 years ago

@bojiang here is the result

aiofiles==0.8.0
aiohttp==3.8.1
aiohttp-cors==0.7.0
aiosignal==1.2.0
alembic==1.8.0
antlr4-python3-runtime==4.8
anyio==3.6.1
apache-airflow==2.3.2
apache-airflow-providers-ftp==3.0.0
apache-airflow-providers-http==3.0.0
apache-airflow-providers-imap==3.0.0
apache-airflow-providers-sqlite==3.0.0
apispec==3.3.2
appdirs==1.4.4
argcomplete==2.0.0
asgiref==3.5.2
async-timeout==4.0.2
attrs==20.3.0
Babel==2.10.2
bentoml==1.0.0rc1
bitarray==2.5.1
blinker==1.4
boto3==1.24.10
botocore==1.27.10
cachelib==0.8.0
cattrs==1.10.0
Cerberus==1.3.4
certifi==2022.5.18.1
cffi==1.15.0
chardet==3.0.4
charset-normalizer==2.0.12
circus==0.17.1
click==8.1.3
clickclick==20.10.2
cloudpickle==2.1.0
colorama==0.4.4
colorlog==4.8.0
commonmark==0.9.1
configparser==5.2.0
connexion==2.13.1
contextlib2==21.6.0
cron-descriptor==1.2.24
croniter==1.3.5
cryptography==37.0.2
Cython==0.29.30
datasets==2.1.0
deepmerge==1.0.1
defusedxml==0.7.1
Deprecated==1.2.13
dill==0.3.5.1
Distance==0.1.3
dnspython==2.2.1
docker==5.0.3
docker-pycreds==0.4.0
docutils==0.18.1
easydict==1.9
email-validator==1.2.1
emoji==1.7.0
fairseq==0.12.1
faiss-cpu==1.7.2
fastapi==0.75.2
fasttext==0.9.2
filelock==3.7.1
Flask==2.1.2
Flask-AppBuilder==3.4.5
Flask-Babel==2.0.0
Flask-Caching==1.11.1
Flask-JWT-Extended==3.25.1
Flask-Login==0.4.1
Flask-OpenID==1.3.0
Flask-Session==0.4.0
Flask-SQLAlchemy==2.5.1
Flask-WTF==0.14.3
frozenlist==1.3.0
fs==2.4.16
fsspec==2022.5.0
future==0.18.2
g2p-en==2.1.0
gitdb==4.0.9
GitPython==3.1.27
graphviz==0.20
grpcio==1.46.3
gunicorn==20.1.0
h11==0.13.0
httpcore==0.15.0
httpx==0.23.0
huggingface-hub==0.7.0
humanfriendly==10.0
hydra-core==1.0.7
idna==2.10
importlib-metadata==4.11.4
importlib-resources==5.8.0
inflect==5.6.0
inflection==0.5.1
itsdangerous==2.1.2
Jinja2==3.0.3
jmespath==1.0.0
joblib==1.1.0
JPype1==1.4.0
jsonschema==4.6.0
konlpy==0.6.0
kss==3.4.2
lazy-object-proxy==1.7.1
lockfile==0.12.2
lxml==4.9.0
Mako==1.2.0
marisa-trie==0.7.7
Markdown==3.3.7
MarkupSafe==2.0.1
marshmallow==3.16.0
marshmallow-enum==1.5.1
marshmallow-oneofschema==3.0.1
marshmallow-sqlalchemy==0.26.1
more-itertools==8.13.0
multidict==6.0.2
multiprocess==0.70.13
nest-asyncio==1.5.5
nltk==3.7
numpy==1.22.4
omegaconf==2.0.6
opentelemetry-api==1.9.0
opentelemetry-instrumentation==0.28b0
opentelemetry-instrumentation-aiohttp-client==0.28b0
opentelemetry-instrumentation-asgi==0.28b0
opentelemetry-sdk==1.9.0
opentelemetry-semantic-conventions==0.28b0
opentelemetry-util-http==0.28b0
packaging==21.3
pandas==1.4.2
pathspec==0.9.0
pathtools==0.1.2
pendulum==2.1.2
pep517==0.12.0
Pillow==9.1.1
pip-tools==6.6.2
pluggy==1.0.0
pororo==0.4.1
portalocker==2.4.0
prison==0.2.1
prometheus-client==0.13.1
promise==2.3
protobuf==4.21.1
psutil==5.9.1
pyarrow==8.0.0
pybind11==2.9.2
pycparser==2.21
pydantic==1.9.1
Pygments==2.12.0
PyJWT==1.7.1
pyngrok==5.1.0
pynvml==11.4.1
pyparsing==3.0.9
pyrsistent==0.18.1
python-daemon==2.3.0
python-dateutil==2.8.2
python-dotenv==0.20.0
python-json-logger==2.0.2
python-multipart==0.0.5
python-nvd3==0.15.0
python-slugify==6.1.2
python3-openid==3.2.0
pytz==2022.1
pytzdata==2020.1
PyYAML==6.0
pyzmq==23.1.0
regex==2022.6.2
requests==2.23.0
responses==0.18.0
rfc3986==1.5.0
rich==12.4.4
ruamel.yaml==0.17.21
ruamel.yaml.clib==0.2.6
s3transfer==0.6.0
sacrebleu==2.1.0
sacremoses==0.0.53
schema==0.7.5
scikit-learn==1.1.1
scipy==1.8.1
sentence-transformers==2.2.0
sentencepiece==0.1.96
sentry-sdk==1.5.12
setproctitle==1.2.3
shortuuid==1.0.9
simple-di==0.1.5
six==1.16.0
smmap==5.0.0
sniffio==1.2.0
SQLAlchemy==1.3.24
SQLAlchemy-JSONField==1.0.0
SQLAlchemy-Utils==0.36.5
starlette==0.17.1
swagger-ui-bundle==0.0.9
tabulate==0.8.9
tenacity==8.0.1
termcolor==1.1.0
text-unidecode==1.3
threadpoolctl==3.1.0
tokenizers==0.12.1
tomli==2.0.1
torch==1.6.0
torchaudio==0.11.0
torchvision==0.7.0
tornado==6.2b1
tqdm==4.64.0
transformers==4.16.0
typing_extensions==4.2.0
unicodecsv==0.14.1
urllib3==1.25.11
uvicorn==0.17.6
wandb==0.12.16
websocket-client==1.3.2
Werkzeug==2.1.2
wget==3.2
Whoosh==2.7.4
word2word==1.0.0
wrapt==1.14.1
WTForms==2.3.3
xxhash==3.0.0
yarl==1.7.2
zipp==3.8.0
bojiang commented 2 years ago

Thanks a lot! I reproduced it. That attrs API is added in 21.1.0, so just upgrading attrs to versions later should fix it.

I will also draft a PR to bentoml's requirements.

ebbunnim commented 2 years ago

@bojiang The problem was resolved after the package upgrade. Thank you so much! 👍 👍