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

jsonschema.validators.SchemaError when Compound Charts #2845

Closed
Cecily123 opened this issue Jan 21, 2023 · 3 comments
Closed

jsonschema.validators.SchemaError when Compound Charts #2845

Cecily123 opened this issue Jan 21, 2023 · 3 comments
Labels

Comments

@Cecily123
Copy link

Hi, I'm using latest version of altair(4.2.0) and my python version is 3.9.5. Codes worked before now breaks with SchemaError.

Please see below codes and Stacktrace:

import altair as alt
from vega_datasets import data

source = data.cars()

brush = alt.selection(type='interval', resolve='global')

base = alt.Chart(source).mark_point().encode(
    y='Miles_per_Gallon',
    color=alt.condition(brush, 'Origin', alt.ColorValue('gray')),
).add_selection(
    brush
).properties(
    width=250,
    height=250
)

base.encode(x='Horsepower') | base.encode(x='Acceleration')
---------------------------------------------------------------------------
SchemaError                               Traceback (most recent call last)
/usr/local/lib/python3.9/site-packages/altair/vegalite/v4/api.py in TopLevelMixin.to_dict(self, *args, **kwargs)
    381 kwargs["context"] = context
    383 try:
--> 384     dct = super(TopLevelMixin, copy).to_dict(*args, **kwargs)
    385 except jsonschema.ValidationError:
    386     dct = None

/usr/local/lib/python3.9/site-packages/altair/utils/schemapi.py in SchemaBase.to_dict(self, validate, ignore, context)
    336 if validate:
    337     try:
--> 338         self.validate(result)
    339     except jsonschema.ValidationError as err:
    340         raise SchemaValidationError(self, err)

/usr/local/lib/python3.9/site-packages/altair/utils/schemapi.py in SchemaBase.validate(cls, instance, schema)
    441     schema = cls._schema
    442 resolver = jsonschema.RefResolver.from_schema(cls._rootschema or cls._schema)
--> 443 return jsonschema.validate(
    444     instance, schema, cls=cls._validator, resolver=resolver
    445 )

/usr/local/lib/python3.9/site-packages/jsonschema/validators.py in validate(instance, schema, cls, *args, **kwargs)
   1114 if cls is None:
   1115     cls = validator_for(schema)
-> 1117 cls.check_schema(schema)
   1118 validator = cls(schema, *args, **kwargs)
   1119 error = exceptions.best_match(validator.iter_errors(instance))

/usr/local/lib/python3.9/site-packages/jsonschema/validators.py in create.<locals>.Validator.check_schema(cls, schema, format_checker)
    226 validator = Validator(
    227     schema=cls.META_SCHEMA,
    228     format_checker=format_checker,
    229 )
    230 for error in validator.iter_errors(schema):
--> 231     raise exceptions.SchemaError.create_from(error)

SchemaError: '#/definitions/TopLevelNormalizedHConcatSpec<GenericSpec>' is not a 'uri-reference'

Failed validating 'format' in metaschema['properties']['$ref']:
    {'format': 'uri-reference', 'type': 'string'}

On schema['$ref']:
    '#/definitions/TopLevelNormalizedHConcatSpec<GenericSpec>'

alt.HConcatChart(...)
@Cecily123 Cecily123 added the bug label Jan 21, 2023
@binste
Copy link
Contributor

binste commented Jan 21, 2023

Thanks for reporting the issue. The root cause is further described in #2794 and the next release of Altair will contain a fix for this (#2771). In the meantime, I suggest that you uninstall the package rfc3986-validator which should solve the issue for you:

pip uninstall rfc3986-validator

@Cecily123
Copy link
Author

Cecily123 commented Jan 23, 2023 via email

@joelostblom
Copy link
Contributor

@Cecily123 There is now a release candidate of Altair 5, which supports Vega-Lite 5 and has a fix for this issue! Details and info on how to install can be found in #2937

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

No branches or pull requests

3 participants