CiscoDevNet / ydk-gen

Generate model-driven APIs from YANG models
http://ciscodevnet.github.io/ydk-gen/
Apache License 2.0
135 stars 74 forks source link

Recent changes to pybind11 (2.6) might cause errors on ydk python #1041

Closed rinhomdf closed 2 years ago

rinhomdf commented 3 years ago

Found as recent as I'm writing this issue, that building a container of the same version of ydk 0.8.5, compared to the same version one built a few months ago my acl self test routine is seems to be failing working (details on it below). The build of ydk itself seems succesful but the at python level seems to cause some errors. The one outstanding element (I might be wrong) that i could find is the different version pybind11 library in my pip list

Expected Behavior

This previously containerised version runs my acl script w/o any error (0.8.5) (python 3.8.5) pip list

Package                 Version
----------------------- -----------
alabaster               0.7.12
appdirs                 1.4.4
Babel                   2.8.0
black                   20.8b1
bleach                  3.1.5
certifi                 2020.6.20
cffi                    1.14.2
chardet                 3.0.4
click                   7.1.2
colorama                0.4.3
cryptography            3.1
docutils                0.16
gitdb2                  2.0.6
GitPython               2.1.15
idna                    2.10
imagesize               1.2.0
jeepney                 0.4.3
Jinja2                  2.11.2
keyring                 21.4.0
MarkupSafe              1.1.1
mccabe                  0.6.1
mypy                    0.782
mypy-extensions         0.4.3
packaging               20.4
pathspec                0.8.0
pip                     20.2.3
pkginfo                 1.5.0.1
pyang                   1.6
pybind11                2.5.0
pycodestyle             2.6.0
pycparser               2.20
pydocstyle              5.1.1
pyflakes                2.2.0
Pygments                2.6.1
pylama                  7.7.1
pyparsing               2.4.7
pytz                    2020.1
readme-renderer         26.0
regex                   2020.7.14
requests                2.24.0
requests-toolbelt       0.9.1
rfc3986                 1.4.0
rstr                    2.2.6
SecretStorage           3.1.2
setuptools              50.3.0
six                     1.15.0
smmap                   3.0.4
smmap2                  3.0.1
snowballstemmer         2.0.0
Sphinx                  1.4a1
sphinx-rtd-theme        0.1.9
toml                    0.10.1
tqdm                    4.48.2
twine                   3.2.0
typed-ast               1.4.1
typing-extensions       3.7.4.3
urllib3                 1.25.10
webencodings            0.5.1
wheel                   0.34.2
ydk                     0.8.5
ydk-models-cisco-ios-xr 6.6.3
ydk-models-ietf         0.1.5.post2
ydk-models-openconfig   0.1.8

Current Behavior

This recently containarised version causes the following error on the script

>>> acl.acl_sets.acl_set.append(acl_set)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/ydk/types/py_types.py", line 784, in append
    self._cache_dict[key] = entities
TypeError: unhashable type: 'ACLIPV4'

details: (0.8.5)(python 3.8.7) pip list

Package                 Version
----------------------- -----------
alabaster               0.7.12
appdirs                 1.4.4
Babel                   2.9.0
black                   20.8b1
bleach                  3.2.3
certifi                 2020.12.5
cffi                    1.14.4
chardet                 4.0.0
click                   7.1.2
colorama                0.4.4
cryptography            3.3.1
docutils                0.16
gitdb2                  2.0.6
GitPython               2.1.15
idna                    2.10
imagesize               1.2.0
jeepney                 0.6.0
Jinja2                  2.11.2
keyring                 22.0.1
MarkupSafe              1.1.1
mccabe                  0.6.1
mypy                    0.800
mypy-extensions         0.4.3
packaging               20.8
pathspec                0.8.1
pip                     21.0
pkginfo                 1.7.0
pyang                   1.6
pybind11                2.6.2
pycodestyle             2.6.0
pycparser               2.20
pydocstyle              5.1.1
pyflakes                2.2.0
Pygments                2.7.4
pylama                  7.7.1
pyparsing               2.4.7
pytz                    2020.5
readme-renderer         28.0
regex                   2020.11.13
requests                2.25.1
requests-toolbelt       0.9.1
rfc3986                 1.4.0
rstr                    2.2.6
SecretStorage           3.3.0
setuptools              52.0.0
six                     1.15.0
smmap                   4.0.0
smmap2                  3.0.1
snowballstemmer         2.1.0
Sphinx                  1.4a1
sphinx-rtd-theme        0.1.9
toml                    0.10.2
tqdm                    4.56.0
twine                   3.3.0
typed-ast               1.4.2
typing-extensions       3.7.4.3
urllib3                 1.26.3
webencodings            0.5.1
wheel                   0.36.2
ydk                     0.8.5
ydk-models-cisco-ios-xr 6.6.3
ydk-models-ietf         0.1.5.post2
ydk-models-junos        0.0.1
ydk-models-openconfig   0.1.8

Your Script

>>> from ydk.providers import NetconfServiceProvider
>>> from ydk.models.openconfig import openconfig_packet_match_types as oc_pkt_match_types
>>> from ydk.models.openconfig import openconfig_acl as oc_acl
>>>
>>> import logging
>>>
>>> logger = logging.getLogger("ydk")
>>> logger.setLevel(logging.DEBUG)
>>> handler = logging.StreamHandler()
>>> formatter = logging.Formatter(("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
>>> handler.setFormatter(formatter)
>>> logger.addHandler(handler)
>>>
>>> acl = oc_acl.Acl()
>>>
>>> acl_set = acl.acl_sets.AclSet()
>>> type = oc_acl.ACLIPV4()
>>> name = "BLOCK_ALL_UDP"
>>> seq_id = 10
>>> action= oc_acl.REJECT()
>>>
>>>
>>> acl_set.name = name
>>> acl_set.type = type
>>> acl_set.config.name = name
>>> acl_set.config.type = type
>>> acl_entry = acl_set.acl_entries.AclEntry()
>>> acl_entry.sequence_id = seq_id
>>> acl_entry.config.sequence_id = seq_id
>>> acl_entry.actions.config.forwarding_action = action
>>>
>>> acl_set.acl_entries.acl_entry.append(acl_entry)
>>> acl.acl_sets.acl_set.append(acl_set)
ygorelik commented 2 years ago

This issue is not reproducible with pybind11 2.6.2, which is used by default in 0.8.6.

rinhomdf commented 2 years ago

thanks for this info Yan, at the moment this repo is still in master under 0.8.5. I understand you have a private fork, is this getting merged into this repo?