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

Create new function to use as callable for Registry(retrieve = ) #901

Open
NickPapONS opened this issue Oct 17, 2023 · 0 comments
Open

Create new function to use as callable for Registry(retrieve = ) #901

NickPapONS opened this issue Oct 17, 2023 · 0 comments

Comments

@NickPapONS
Copy link
Contributor

NickPapONS commented Oct 17, 2023

During the investigation on replacing the use of the deprecated jsonschema.RefResolver with referencing.Registry, the following conclusions were made:

  • In the first instance of RefResolver’s use in utils/json.py, RefResolver appears in the function resolve_path, however, this function is not used anywhere at all in the code base. I recommend for this function to be removed since its code is now deprecated and it has no effect/use anywhere in csvcubed.

  • The second usage of RefResolver in jsonvalidationerrors.py’s two functions: _child_error_messages_display_string() and _resolve_reference_in_schema() was partially resolved in Replacing jsonschema.RefResolver with referencing.Registry #879. _child_error_messages_display_string was updated so it now uses Registry’s with_resource and should work fine.

  • The purpose of this ticket is to implement the replacement functionality for the RefResolver.resolve_from_url function used in _resolve_reference_in)_schema() which is more complicated. This requires calling referencing.Registry() with the retrieve argument being given a callable (function as a parameter) to configure the retrieval of resources dynamically. The callable passed into the retrieve argument will be called if a URI not present in the registry is accessed. This should either return a Resource or a NoSuchResource exception if the resource does not exist at all. Here are the resources/documentation pages found that describe the use of Registry and the retrieve argument since it is quite complicated compared to simply replacing a deprecated function:
    https://referencing.readthedocs.io/en/stable/api/#referencing.Registry

    https://readthedocs.org/projects/python-jsonschema/downloads/pdf/stable/
    see page 33-34 for use of Registry(retrieve) and an example of a callable function being defined, it could
    be used as inspiration for the structure of the functionality we want, but obviously it will need altering to match our
    application in csvcubed. Discuss with the team to further explore details on this using the documentation as a
    reference.

Some additional comments were pushed to the existing branch investigating the migration to referencing.Registry, showing where in the codebase the new functionality is needed:
main...#854-jsonschema-deprecation-warning

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

No branches or pull requests

1 participant