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

Context: adding ability to add custom load callback #103

Closed
wants to merge 1 commit into from

Conversation

steweg
Copy link
Contributor

@steweg steweg commented Feb 28, 2024

This patch adds ability to add custom load callback and also disable searchdirs options

libyang/context.py Outdated Show resolved Hide resolved
libyang/context.py Outdated Show resolved Hide resolved
@steweg steweg force-pushed the feature/custom_module_load_clb branch from 0ba20bc to 7f42a37 Compare February 28, 2024 12:13
@steweg
Copy link
Contributor Author

steweg commented Feb 28, 2024

On the testing level this is dependent on #104, so please take look on #104 first. thanks

@steweg steweg mentioned this pull request Feb 28, 2024
Copy link
Collaborator

@rjarry rjarry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please put the commit from #104 in this pull request? It will simplify testing.

Thanks.

libyang/context.py Outdated Show resolved Hide resolved
@rjarry
Copy link
Collaborator

rjarry commented Mar 26, 2024

Hi,

libyang-python only supports the master branch of C libyang (currently 2.x).

The lydevel check is only meant for informative purposes.

libyang-python/tox.ini

Lines 18 to 20 in f09ed11

[testenv:lydevel]
setenv =
LIBYANG_BRANCH=devel

If it fails (currently it should fail because libyang 3.x is under development) it is not a problem.

Could you remove all references to libyang 3 which was not released yet and only focus on the enhancements that you require?

Thank you.

@steweg steweg force-pushed the feature/custom_module_load_clb branch from 17d01a2 to 61dd1da Compare March 30, 2024 09:56
@steweg
Copy link
Contributor Author

steweg commented Mar 30, 2024

Hi,

libyang-python only supports the master branch of C libyang (currently 2.x).

The lydevel check is only meant for informative purposes.

libyang-python/tox.ini

Lines 18 to 20 in f09ed11

[testenv:lydevel]
setenv =
LIBYANG_BRANCH=devel

If it fails (currently it should fail because libyang 3.x is under development) it is not a problem.

Could you remove all references to libyang 3 which was not released yet and only focus on the enhancements that you require?

Thank you.

Done

@steweg steweg force-pushed the feature/custom_module_load_clb branch from 61dd1da to 506a1c0 Compare April 6, 2024 10:21
@samuel-gauthier
Copy link
Collaborator

Sorry for the delay on this... I pushed the first commit, but I don't understand what the second one does... Could you explain in more detail what you use it for, what it does exactly, and how it works?

@steweg
Copy link
Contributor Author

steweg commented Aug 2, 2024

It allows you to define your own callback functions to load YANG modules if they are not found on in standard path. This is considered as sort of last resort option, which allows you to store YANG modules in remote/central locations and download it using some HTTP(s) client etc... libyang just tells you what file & version you should get, and it is up to your callback implementation to try to get it.

libyang/context.py Outdated Show resolved Hide resolved
libyang/context.py Outdated Show resolved Hide resolved
libyang/context.py Outdated Show resolved Hide resolved
libyang/context.py Outdated Show resolved Hide resolved
libyang/context.py Outdated Show resolved Hide resolved
libyang/context.py Outdated Show resolved Hide resolved
@steweg steweg force-pushed the feature/custom_module_load_clb branch 2 times, most recently from 91db3bd to e89419d Compare August 4, 2024 07:07
@samuel-gauthier
Copy link
Collaborator

Pushed with minor changes, thanks!

@samuel-gauthier
Copy link
Collaborator

samuel-gauthier commented Aug 5, 2024

@steweg there is a problem with this pull request, can you look at this ignored exception? It can be reproduced by launching tox.

pypy3: commands[0] /home/runner/work/libyang-python/libyang-python/tests> python -Wd -m unittest discover -c
................Exception ignored from cffi callback <function libyang_c_module_imp_clb at 0x00007f523c4bfc40>:
Traceback (most recent call last):
  File "/home/runner/work/libyang-python/libyang-python/.tox/pypy3/lib/pypy3.9/site-packages/libyang/context.py", line 71, in libyang_c_module_imp_clb
    ret = instance.get_module_data(
  File "/home/runner/work/libyang-python/libyang-python/.tox/pypy3/lib/pypy3.9/site-packages/libyang/context.py", line 140, in get_module_data
    fmt_str, module_data = self._module_data_clb(
TypeError: cannot unpack non-iterable NoneType object
........................................................................................................................
----------------------------------------------------------------------
Ran 136 tests in 0.502s

Thanks!

@steweg steweg force-pushed the feature/custom_module_load_clb branch from e89419d to ebf1f1a Compare August 5, 2024 07:21
@steweg steweg force-pushed the feature/custom_module_load_clb branch from ebf1f1a to 2cdb2f6 Compare August 5, 2024 07:23
This patch fixes broken test related to get_module_data
function

Signed-off-by: Stefan Gula <[email protected]>
@steweg steweg force-pushed the feature/custom_module_load_clb branch from 2cdb2f6 to ca1848d Compare August 5, 2024 09:21
@steweg steweg deleted the feature/custom_module_load_clb branch August 5, 2024 09:47
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

Successfully merging this pull request may close these issues.

3 participants