frictionlessdata / frictionless-py

Data management framework for Python that provides functionality to describe, extract, validate, and transform tabular data
https://framework.frictionlessdata.io
MIT License
686 stars 142 forks source link

Validation fails for jsonschema version 4.18 #1569

Open shashigharti opened 11 months ago

shashigharti commented 11 months ago

Overview

This fails in jsonschema version 4.18

schema = {
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Camera Trap Data Package Profile",
    "type": "object",
    "allOf": [
        {
         "$ref": "https://frictionlessdata.io/schemas/data-package.json"
        },
        {
          "required": [
            "multimedia_access",
            "project",
            "spatial",
            "temporal",
            "taxonomic"
          ]
        }
    ]  
}
descriptor = {'profile': 'camtrap.json', 'resources': [{'name': 'table', 'type': 'table', 'path': 'table.csv', 'scheme': 'file', 'format': 'csv', 'mediatype': 'text/csv'}]}
validator_class = jsonschema.validators.validator_for(schema)
validator = validator_class(schema)
for error in validator.iter_errors(descriptor):
    print(error)

# jsonschema.exceptions._WrappedReferencingError: Unresolvable: https://frictionlessdata.io/schemas/data-package.json

Due to that the following code fails:

from frictionless import Package, Resource, FrictionlessException
import pytest

profile = "camtrap.json"
resource = Resource(name="table", path="table.csv")
package = Package(resources=[resource], profile=profile)
with pytest.raises(FrictionlessException) as excinfo:
    package.to_descriptor(validate=True)
pschumm commented 10 months ago

I would just point out that jupyter_events has now moved to jsonschema v4.18.0, so this creates a problem for those using Frictionless within JupyterLab (for the moment, one can get around this by pinning jupyter_events<v0.7.0). My sense (based on a quick read) is that this is going to require some code changes to frictionless-py to make it compatible with the new API implemented in jsonschema>=4.18.0. Unfortunately I don't have time to work on this right now.

johentsch commented 6 months ago

so this creates a problem for those using Frictionless within JupyterLab

Yes I second that. Frictionless is a core dependency to our library, which is also designed for working well in Jupyter, so there is a dependency clash

frictionless 5.16.0 requires jsonschema<4.18

johentsch commented 5 months ago

Any prospects of this being addressed in the near future?

zaneselvans commented 2 months ago

I finally updated our project to use frictionless v5 rather than v4 and was also surprised to see jsonschema get downgraded to a version that's almost a year and a half old with the attendant downgrades of multiple Jupyter packages.

It would be great to get this updated!

pschumm commented 2 months ago

FYI, the latest JupyterLab releases (4.1.8 and 4.2.0rc0) now require jupyterlab_server 2.27.1, which itself requires jsonschema 4.18.0. So this is the end of the road for JupyterLab updates with Frictionless until this issue is addressed.