Root cause Analysis: Facing issues when tried to compile YDK with augmented ietf_interface values. The issue is with the YDK parsing file. There were 2 issues,
1. The YDK parser file take the base ietf_interface.py file and our augmented ietf file. It then creates a new ietf_interfaces.py file in "_aug_patch" folder with both base ietf and augmented ietf content. While parsing the comment section, the code hits a logic of end of comment (""") in the generated augmented ietf_interfaces.py file. Ideally the logic should have ended comment parsing. But instead the data index is decremented.
file:- __init__.py in ietf folder
if '"""' in patch_lines[idx]):
This was causing the code to access the same index again and again which resulted in the looping. This was causing memory issue.
2. In addition to the looping issue, there was array index out of bound issue. Because of this issue the ietf_interfaces.py was not properly generated in the ietf/_aug_patch folder. IT was giving IndexError.
Have fixed both the issues. It is purely YDK issue. The issue should be fixed in the file ydk-gen/ydkgen/printer/python/init_file_printer.py..
you could do a couple of things:
- Raise an issue on the github issue tracker in the repo CiscoDevNet/ydk-gen
- Fork that same repository and apply your patch, and submit a pull request referencing the issue you raised.
Checked the init_file_priner.py in current ydk-gen repository this time and found the code causing this issue is being removed after this commit. I think it should be fine if YDK is upgraded to 0.5.4(pip install ydk --upgrade). Let me know if it helps.
The issue is about old Python package generated by YDK-GEN before 0.5.4 interfere with new Python package generated after 0.5.4. If you have old Python package generated and installed by YDK-GEN before 0.5.4, and facing similar issue above(error in "_aug_patch"), please uninstall them and regenerate the reinstall using YDK-GEN>=0.5.4:
$ pip list | grep ydk-models
# ^~~~ if you installed ydk-models-ietf through YDK-GEN<0.5.4,
# and generated then installed new custom package with YANG model augment models
# in this package(for example ietf-interfaces in this case), it might cause
# you trouble, please refresh your environment by removing all of them:
$ pip uninstall ydk-models-cisco-ios-xr ydk-models-ietf ydk-models-openconfig -y
# and regenerate/reinstall them:
ydk-gen $ ./generate.py --bundle profiles/bundles/ietf_0_1_1.json
ydk-gen $ ./generate.py --bundle custom.json
ydk-gen $ pip install gen-api/python/ietf-bundle/dist/ydk*.gz
ydk-gen $ pip install gen-api/python/custom-bundle/dist/ydk*.gz