Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new_client is failing to import from chembl_webresource_client #122

Open
parmidazamani opened this issue Sep 14, 2022 · 1 comment
Open

Comments

@parmidazamani
Copy link

parmidazamani commented Sep 14, 2022

I installed chembl-webresource-client from https://pypi.org/project/chembl-webresource-client/

but when I run

from chembl_webresource_client.new_client import new_client

I get this error:

TypeError Traceback (most recent call last)
Input In [7], in <cell line: 1>()
----> 1 from chembl_webresource_client.new_client import new_client

File ~\anaconda3\lib\site-packages\chembl_webresource_client\new_client.py:5, in
3 from urllib.parse import urlparse
4 import requests
----> 5 from chembl_webresource_client.query_set import QuerySet
6 from chembl_webresource_client.query_set import Model
7 from chembl_webresource_client.settings import Settings

File ~\anaconda3\lib\site-packages\chembl_webresource_client\query_set.py:7, in
5 from chembl_webresource_client import version
6 from chembl_webresource_client.settings import Settings
----> 7 from chembl_webresource_client.url_query import UrlQuery
9 #-----------------------------------------------------------------------------------------------------------------------
11 class Model(object):

File ~\anaconda3\lib\site-packages\chembl_webresource_client\url_query.py:4, in
1 author = 'mnowotka'
3 from chembl_webresource_client.settings import Settings
----> 4 from chembl_webresource_client.query import Query
5 from xml.dom.minidom import parseString
7 from urllib.parse import urlencode

File ~\anaconda3\lib\site-packages\chembl_webresource_client\query.py:4, in
2 import os, os.path
3 import requests
----> 4 import requests_cache
5 from chembl_webresource_client.cache import monkeypatch_requests_cache
6 from requests.packages.urllib3.util import Retry

File ~\anaconda3\lib\site-packages\requests_cache_init_.py:35, in
31 return Placeholder
34 try:
---> 35 from .backends import *
36 from .patcher import *
37 from .models import *

File ~\anaconda3\lib\site-packages\requests_cache\backends_init_.py:8, in
5 from typing import Callable, Dict, Iterable, Type, Union
7 from .. import get_placeholder_class
----> 8 from .base import BaseCache, BaseStorage
10 # Backend-specific keyword arguments equivalent to 'cache_name'
11 CACHE_NAME_KWARGS = ['db_path', 'db_name', 'namespace', 'table_name']

File ~\anaconda3\lib\site-packages\requests_cache\backends\base.py:13, in
11 from ..cache_keys import create_key, remove_ignored_params, remove_ignored_url_params, url_to_key
12 from ..models import AnyRequest, AnyResponse, CachedResponse
---> 13 from ..serializers import init_serializer
15 # Specific exceptions that may be raised during deserialization
16 DESERIALIZE_ERRORS = (AttributeError, ImportError, TypeError, ValueError, pickle.PickleError)

File ~\anaconda3\lib\site-packages\requests_cache\serializers_init_.py:25, in
23 try:
24 from .cattrs import CattrStage
---> 25 from .preconf import (
26 bson_serializer,
27 json_serializer,
28 pickle_serializer,
29 safe_pickle_serializer,
30 yaml_serializer,
31 )
32 except ImportError as e:
33 CattrStage = get_placeholder_class(e) # type: ignore

File ~\anaconda3\lib\site-packages\requests_cache\serializers\preconf.py:24, in
21 from .cattrs import CattrStage
22 from .pipeline import SerializerPipeline, Stage
---> 24 base_stage = CattrStage() #: Base stage for all serializer pipelines
25 bson_preconf_stage = CattrStage(bson_preconf.make_converter) #: Pre-configured stage for BSON
26 json_preconf_stage = CattrStage(json_preconf.make_converter) #: Pre-configured stage for JSON

File ~\anaconda3\lib\site-packages\requests_cache\serializers\cattrs.py:22, in CattrStage.init(self, factory)
21 def init(self, factory: Callable[..., GenConverter] = None):
---> 22 self.converter = init_converter(factory)

File ~\anaconda3\lib\site-packages\requests_cache\serializers\cattrs.py:57, in init_converter(factory)
54 converter.register_structure_hook(HTTPHeaderDict, lambda obj, cls: HTTPHeaderDict(obj))
56 # Tell cattrs that a 'CachedResponse' forward ref is equivalent to the CachedResponse class
---> 57 converter.register_structure_hook(
58 ForwardRef('CachedResponse'),
59 lambda obj, cls: converter.structure(obj, CachedResponse),
60 )
62 return converter

File ~\anaconda3\lib\site-packages\cattr\converters.py:269, in Converter.register_structure_hook(self, cl, func)
267 self._structure_func.clear_cache()
268 else:
--> 269 self._structure_func.register_cls_list([(cl, func)])

File ~\anaconda3\lib\site-packages\cattr\dispatch.py:57, in MultiStrategyDispatch.register_cls_list(self, cls_and_handler, direct)
55 self._direct_dispatch[cls] = handler
56 else:
---> 57 self._single_dispatch.register(cls, handler)
58 self.clear_direct()
59 self.dispatch.cache_clear()

File ~\anaconda3\lib\functools.py:855, in singledispatch..register(cls, func)
853 else:
854 if func is not None:
--> 855 raise TypeError(
856 f"Invalid first argument to register(). "
857 f"{cls!r} is not a class."
858 )
859 ann = getattr(cls, 'annotations', {})
860 if not ann:

TypeError: Invalid first argument to register(). ForwardRef('CachedResponse') is not a class.

@parmidazamani parmidazamani changed the title new_client is failing to import from chembl-webresource-client new_client is failing to import from chembl_webresource_client Sep 14, 2022
@elephantoid
Copy link

elephantoid commented Oct 24, 2023

same error here. my version is 0.10.8
Do you have any changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants