cisco-en-programmability/dnacentersdk

Change requests-toolbelt minimum version

Closed this issue · 10 comments

Prerequisites

  • Have you tested the operation in the API directly?
  • Do you have the latest SDK version?
  • Review the compatibility matrix before opening an issue.

Describe the bug
Currently, the SDK has the following limit: dnacentersdk 2.6.3 depends on requests-toolbelt<0.11.0 and >=0.10.1

However, if my understanding is correct there is a recent bug (ImportError: cannot import name 'appengine' from 'urllib3.contrib' (/.../Downloads/venv/lib/python3.9/site-packages/urllib3/contrib/__init__.py) present in requests-toolbet <1.0.0.

The ask is to change the dependency (requests-toolbet>=1.0.0) on the SDK to avoid hitting this error.

Screenshots
This is a sample output of the a script that uses the SDK that is broke:

(venv) xcc@asdad Downloads % python3 client_detail_report.py 
Traceback (most recent call last):
  File ".../venv/lib/python3.9/site-packages/requests_toolbelt/_compat.py", line 48, in <module>
    from requests.packages.urllib3.contrib import appengine as gaecontrib
ImportError: cannot import name 'appengine' from 'requests.packages.urllib3.contrib' (/.../Downloads/venv/lib/python3.9/site-packages/urllib3/contrib/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/.../Downloads/client_detail_report.py", line 36, in <module>
    from dnacentersdk import DNACenterAPI, ApiError, api
  File "/...Downloads/venv/lib/python3.9/site-packages/dnacentersdk/__init__.py", line 30, in <module>
    from .api import DNACenterAPI
  File "/.../Downloads/venv/lib/python3.9/site-packages/dnacentersdk/api/__init__.py", line 39, in <module>
    from dnacentersdk.restsession import RestSession
  File "/.../Downloads/venv/lib/python3.9/site-packages/dnacentersdk/restsession.py", line 44, in <module>
    from requests_toolbelt.multipart import encoder
  File "/.../Downloads/venv/lib/python3.9/site-packages/requests_toolbelt/__init__.py", line 12, in <module>
    from .adapters import SSLAdapter, SourceAddressAdapter
  File "/.../Downloads/venv/lib/python3.9/site-packages/requests_toolbelt/adapters/__init__.py", line 12, in <module>
    from .ssl import SSLAdapter
  File "/.../Downloads/venv/lib/python3.9/site-packages/requests_toolbelt/adapters/ssl.py", line 16, in <module>
    from .._compat import poolmanager
  File "/.../Downloads/venv/lib/python3.9/site-packages/requests_toolbelt/_compat.py", line 50, in <module>
    from urllib3.contrib import appengine as gaecontrib
ImportError: cannot import name 'appengine' from 'urllib3.contrib' (/.../Downloads/venv/lib/python3.9/site-packages/urllib3/contrib/__init__.py)

Environment (please complete the following information):

  • Cisco DNA Center Version and patch: 2.3.3.7-72328
  • Python version: 3.9
  • SDK version: 2.6.3
  • OS Version: macOS 13.3.1 (a)

@fmunozmiranda hello Fernando, did you have a chance to review the above? @zapodeanu can share that this issue is coming up for other people (as we have seen it in other forums).

Sorry if you're not the right one, trying to help :).

@gigiogigo, Sorry for the delay, the change is applied in develop, for the next version, it will be reflected, thanks for the report.

@fmunozmiranda hey I have been waiting for a while for the new version with this fix, is it coming soon? This bug is quite annoying, thanks :)

Hi Team, I've also ran into this issue recently.

It can certainly be annoying.

Maybe a couple of additions to what @gigiogigo have already commented to benefit of the community.

  1. Use virtual environments whenever possible/applicable. This will give you the required flexibility to play with different packages and versions of those packages without affecting you main system.
  2. To overcome this bug, you can uninstall the urllib3 package (issue still present on the latest release which as of this date is 2.0.3) and install (or just downgrade) to a version previous to 2.x.x, like 1.26.16:

List packages installed using pip

pip freeze

Uninstall urllib3

python3 -m pip uninstall urllib3

Install version without the bug

python3 -m pip install urllib3==1.26.16

Save known working packages list for installation in other environments

pip freeze > requirements.txt

The previous is just a workaround. I guess best approach is to validate the dependencies and just keep the ones that are required for the SDK to work properly.

@gigiogigo sorry for delay, changes are included in new version

Hi @fmunozmiranda , can you elaborate a little bit on the changes? what is being implemented?

@fmunozmiranda I'm sorry to keep asking but the latest version 2.6.5 from May 29 doesn't have the fix. Would it be possible to release a new one? Thanks

@gigiogigo could you please pass me functions are you using on you're client_detail_report.py just to try to replicate you're fail. Thanks

Here is sample app to create a new client report. https://github.com/cisco-en-programmability/dnacenter_reports_operations. You may find there a payload request that you may use with the SDK.

@gigiogigo could you please pass me functions are you using on you're client_detail_report.py just to try to replicate you're fail. Thanks

This commit 9419fc2 fixed it, I was just asking for you to officially release 2.6.6, it seems that you only created the tag.
image

Thanks!