Skip to content

AttributeError: module 'typing' has no attribute '_ClassVar' #8638

@HatterTheMad

Description

@HatterTheMad

Environment info

  • transformers version: 3.5.1
  • Platform: Linux
  • Python version: 3.8
  • PyTorch version (GPU?): 1.7.0+cpu
  • Using GPU in script?: No
  • Using distributed or parallel set-up in script?: Yes

Who can help @sgugger .... @LysandreJik ... mb?

Information

Model I am using: Distilbert

The problem arises when using:
Just this:

from transformers import AutoTokenizer, AutoModelForQuestionAnswering

The tasks I am working on is:

  • my own task or dataset:
    I am using default Distilbert for my flask API

To reproduce

Steps to reproduce the behavior:
That's a big part of the question. It works just fine on my local machine, but gives this error when run on my AWS server.

from flask import Flask, request, jsonify
from flask import Flask
from flask_restful import Api, Resource
from transformers import AutoTokenizer, AutoModelForQuestionAnswering
from transformers.pipelines import pipeline

tokenizer = AutoTokenizer.from_pretrained('./Dis_Save/')
model = AutoModelForQuestionAnswering.from_pretrained('./Dis_Save/')
nlp_qa = pipeline('question-answering', tokenizer=tokenizer,model=model)

app = Flask(__name__)

@app.route('/api/QandA', methods=['GET', 'POST'])

def QandA():
    content = request.json
    print(content['userMessages'])
    X = nlp_qa(context=content['userMessages'], question=content['question'])
    return(jsonify({"answer":X["answer"], "score":X["score"]}))

if __name__ == "__main__":
	app.run(debug=True)

#This is all the code that I have. Here is the full error that I get:

  File "access/main.py", line 4, in <module>
    from transformers import AutoTokenizer, AutoModelForQuestionAnswering
  File "/home/ubuntu/access/transformers/__init__.py", line 22, in <module>
    from .integrations import (  # isort:skip
  File "/home/ubuntu/access/transformers/integrations.py", line 82, in <module>
    from .trainer_callback import TrainerCallback  # noqa: E402
  File "/home/ubuntu/access/transformers/trainer_callback.py", line 27, in <module>
    from .training_args import TrainingArguments
  File "/home/ubuntu/access/transformers/training_args.py", line 36, in <module>
    class TrainingArguments:
  File "/home/ubuntu/access/dataclasses.py", line 958, in dataclass
    return wrap(_cls)
  File "/home/ubuntu/access/dataclasses.py", line 950, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
  File "/home/ubuntu/access/dataclasses.py", line 800, in _process_class
    cls_fields = [_get_field(cls, name, type)
  File "/home/ubuntu/access/dataclasses.py", line 800, in <listcomp>
    cls_fields = [_get_field(cls, name, type)
  File "/home/ubuntu/access/dataclasses.py", line 659, in _get_field
    if (_is_classvar(a_type, typing)
  File "/home/ubuntu/access/dataclasses.py", line 550, in _is_classvar
    return type(a_type) is typing._ClassVar
AttributeError: module 'typing' has no attribute '_ClassVar'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions