-
-
Notifications
You must be signed in to change notification settings - Fork 570
Improve Vega Lite to support validation #8215
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
base: main
Are you sure you want to change the base?
Conversation
panel/pane/vega.py
Outdated
| self._update_selections() | ||
|
|
||
| @cache | ||
| def _download_vega_lite_schema(self, schema_url: str | None = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about airgapped usage of panel? Are we not trying to support that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_download_vega_lite_schema is optional--only for validation.
try:
schema = self._download_vega_lite_schema(schema)
except Exception as e:
self.param.warning(f"Skipping validation because could not load Vega schema at {schema}: {e}")
returnAnd users have full flexibility on using a local schema, meaning it can do something like: requests.get("localhost:8000/schema")?
However, potentially I can do open("schema").read()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, open("schema").read() isn't feasible because I don't think the JS can access it, but if user exposes it as an endpoint, it's likely doable.
import json
import requests
with open("schema.json", "w") as f:
json_file = requests.get("https://vega.github.io/schema/vega-lite/v5.json").json()
json.dump(json_file, f)
import panel as pn
pn.extension('vega')
vegalite = {
"$schema": "schema.json",
"data": {"url": "https://raw.githubusercontent.com/vega/vega/master/docs/data/barley.json"},
"mark": "bar",
"encoding": {
"x": {"aggregate": "sum", "field": "yield", "type": "quantitative"},
"y": {"field": "variety", "type": "nominal"},
"color": {"field": "site", "type": "nominal"}
}
}
vgl_pane = pn.pane.Vega(vegalite, height=240)
vgl_pane.show()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At minimum this needs a timeout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind,
open("schema").read()isn't feasible because I don't think the JS can access it, but if user exposes it as an endpoint, it's likely doable.
Should a remark / example regarding air-gapped use be added to the Vega doc after this update?
Looks like that info is currently not part of the doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related regarding air-gapped use: #7429
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8215 +/- ##
===========================================
- Coverage 86.01% 70.24% -15.78%
===========================================
Files 348 347 -1
Lines 54378 54451 +73
===========================================
- Hits 46775 38249 -8526
- Misses 7603 16202 +8599 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
0d46a92 to
d92d4f8
Compare
Migrate Vega validation from Lumen https://github.com/holoviz/lumen/blob/main/lumen/ai/views.py#L245-L262 into Panel.
Also handles archaic error:
Closes #8201