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 #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.
During the investigation on replacing the use of the deprecated
jsonschema.RefResolver
withreferencing.Registry
, the following conclusions were made:RefResolver
appears in the functionresolve_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._child_error_messages_display_string()
and_resolve_reference_in_schema()
was partially resolved in #879._child_error_messages_display_string
was updated so it now uses Registry’swith_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 theretrieve
argument being given a callable (function as a parameter) to configure the retrieval of resources dynamically. The callable passed into theretrieve
argument will be called if a URI not present in the registry is accessed. This should either return aResource
or aNoSuchResource
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.Registryhttps://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: https://github.com/GSS-Cogs/csvcubed/compare/main...%23854-jsonschema-deprecation-warning