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

alt.Chart.from_json slow after upgrading jsonschema from 3.x to 4.x #2501

Closed
the21st opened this issue Oct 13, 2021 · 2 comments
Closed

alt.Chart.from_json slow after upgrading jsonschema from 3.x to 4.x #2501

the21st opened this issue Oct 13, 2021 · 2 comments
Labels

Comments

@the21st
Copy link

the21st commented Oct 13, 2021

I tested all of the below with altair version 4.1.0.

I recently upgraded my jupyter stack to the following versions:
notebook==6.4.4
ipython==7.28.0
ipykernel==6.4.1

Update: The culprit downstream dependency is jsonschema==4.1.0

Since then, alt.Chart.from_json(spec) takes 2.6 seconds on my machine. Code to reproduce:

import time
import altair as alt

spec = """
{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "mark": {
    "type": "bar",
    "tooltip": {
      "content": "data"
    }
  },
  "height": 220,
  "autosize": {
    "type": "fit"
  },
  "data": {
    "name": "placeholder"
  },
  "encoding": {
    "x": {
      "field": "bookID",
      "type": "quantitative",
      "sort": null,
      "scale": {
        "type": "linear",
        "zero": false
      }
    },
    "y": {
      "field": "title",
      "type": "nominal",
      "sort": null,
      "scale": {
        "type": "linear",
        "zero": true
      }
    },
    "color": {
      "field": "",
      "type": "nominal",
      "sort": null,
      "scale": {
        "type": "linear",
        "zero": false
      }
    }
  }
}
"""

start = time.time()
chart = alt.Chart.from_json(spec)
end = time.time()
print(end - start)

Running the same code on an older version jsonschema==3.2.0 executes in 0.03 seconds.

Note that I am not yet passing any data to altair, just a data-less vega-lite spec.

@the21st the21st added the bug label Oct 13, 2021
@the21st the21st changed the title alt.Chart.from_json slow after jupyter upgrade alt.Chart.from_json slow after upgrading jsonschema from 3.x to 4.x Oct 13, 2021
@jakevdp
Copy link
Collaborator

jakevdp commented Oct 13, 2021

Thanks for the report: this seems to be due to python-jsonschema/jsonschema#853

For now, I'd suggest using jsonschema version 3.2 with Altair.

@joelostblom
Copy link
Contributor

closing as there is nothing to do on the altair side of things and there are newer versions of jsonschema to use

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