Skip to content

Commit

Permalink
Test dev release of Bokeh 3.5 (#6883)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Jun 4, 2024
1 parent 59c2be2 commit 2efb591
Show file tree
Hide file tree
Showing 25 changed files with 267 additions and 340 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ jobs:
run: |
MATRIX=$(jq -nsc '{
"os": ["ubuntu-latest", "macos-latest", "windows-latest"],
"environment": ["test-39", "test-312"]
"environment": ["test-310", "test-312"]
}')
echo "MATRIX=$MATRIX" >> $GITHUB_ENV
- name: Set test matrix with 'full' option
if: env.MATRIX_OPTION == 'full'
run: |
MATRIX=$(jq -nsc '{
"os": ["ubuntu-latest", "macos-latest", "windows-latest"],
"environment": ["test-39", "test-310", "test-311", "test-312"]
"environment": ["test-310", "test-311", "test-312"]
}')
echo "MATRIX=$MATRIX" >> $GITHUB_ENV
- name: Set test matrix with 'downstream' option
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ repos:
rev: v9.3.0
hooks:
- id: eslint
args: ['-c', 'panel/.eslintrc.js', 'panel/*.ts', 'panel/models/**/*.ts']
args: ['-c', 'panel/.eslintrc.js', 'panel/*.ts', 'panel/models/**/*.ts', '--fix']
additional_dependencies:
- '[email protected]'
- '@stylistic/[email protected]'
Expand Down
17 changes: 2 additions & 15 deletions panel/io/mime_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
import base64
import copy
import io
import pathlib
import pkgutil
import sys
import traceback

Expand All @@ -31,18 +29,7 @@
# Import API
#---------------------------------------------------------------------

def _stdlibs():
if sys.version_info[:2] >= (3, 10):
return sys.stdlib_module_names
env_dir = str(pathlib.Path(sys.executable).parent.parent)
modules = list(sys.builtin_module_names)
for m in pkgutil.iter_modules():
mpath = getattr(m.module_finder, 'path', '')
if mpath.startswith(env_dir) and 'site-packages' not in mpath:
modules.append(m.name)
return modules

_STDLIBS = _stdlibs()
_STDLIBS = sys.stdlib_module_names
_PACKAGE_MAP = {
'sklearn': 'scikit-learn',
'transformers_js': 'transformers-js-py',
Expand Down Expand Up @@ -219,7 +206,7 @@ def render_svg(value, meta, mime):

def render_image(value, meta, mime):
data = f"data:{mime};charset=utf-8;base64,{value}"
attrs = " ".join(['{k}="{v}"' for k, v in meta.items()])
attrs = " ".join([f'{k}="{v}"' for k, v in meta.items()])
return f'<img src="{data}" {attrs}</img>', 'text/html'

def render_javascript(value, meta, mime):
Expand Down
32 changes: 0 additions & 32 deletions panel/io/pyodide.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import asyncio
import functools
import hashlib
import io
import json
import os
import pathlib
import sys
import uuid

Expand All @@ -29,9 +27,6 @@
from bokeh.io.doc import set_curdoc
from bokeh.model import Model
from bokeh.settings import settings as bk_settings
from bokeh.util.sampledata import (
__file__ as _bk_util_dir, _download_file, external_data_dir, splitext,
)
from js import JSON, XMLHttpRequest

from ..config import config
Expand Down Expand Up @@ -385,33 +380,6 @@ def _get_pyscript_target():
elif not _IN_WORKER:
raise ValueError("Could not determine target node to write to.")

def _download_sampledata(progress: bool = False) -> None:
"""
Download bokeh sampledata
"""
data_dir = external_data_dir(create=True)
s3 = 'https://sampledata.bokeh.org'
with open(pathlib.Path(_bk_util_dir).parent / "sampledata.json") as f:
files = json.load(f)
for filename, md5 in files:
real_name, ext = splitext(filename)
if ext == '.zip':
if not splitext(real_name)[1]:
real_name += ".csv"
else:
real_name += ext
real_path = data_dir / real_name
if real_path.exists():
with open(real_path, "rb") as file:
data = file.read()
local_md5 = hashlib.md5(data).hexdigest()
if local_md5 == md5:
continue
_download_file(s3, filename, data_dir, progress=progress)

bokeh.sampledata.download = _download_sampledata
bokeh.util.sampledata.download = _download_sampledata

#---------------------------------------------------------------------
# Public API
#---------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion panel/models/ace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class AcePlotView extends HTMLBoxView {
style: {
width: "100%",
height: "100%",
zIndex: 0,
zIndex: "0",
},
})
this.shadow_el.append(this._container)
Expand Down
10 changes: 5 additions & 5 deletions panel/models/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ export class CardView extends ColumnView {

let header_el
if (this.model.collapsible) {
this.button_el = DOM.createElement("button", {type: "button", class: header_css_classes})
const icon = DOM.createElement("div", {class: button_css_classes})
this.button_el = DOM.button({class: header_css_classes})
const icon = DOM.div({class: button_css_classes})
icon.innerHTML = this.model.collapsed ? CHEVRON_RIGHT : CHEVRON_DOWN
this.button_el.appendChild(icon)
this.button_el.style.backgroundColor = header_background != null ? header_background : ""
Expand All @@ -90,7 +90,7 @@ export class CardView extends ColumnView {
this.button_el.onclick = () => this._toggle_button()
header_el = this.button_el
} else {
header_el = DOM.createElement((header_tag as any), {class: header_css_classes})
header_el = DOM.create_element((header_tag as any), {class: header_css_classes})
header_el.style.backgroundColor = header_background != null ? header_background : ""
header_el.appendChild(header.el)
}
Expand Down Expand Up @@ -148,8 +148,8 @@ export class CardView extends ColumnView {
this.invalidate_layout()
}

protected override _createElement(): HTMLElement {
return DOM.createElement((this.model.tag as any), {class: this.css_classes()})
protected override _create_element(): HTMLElement {
return DOM.create_element((this.model.tag as any), {class: this.css_classes()})
}
}

Expand Down
4 changes: 2 additions & 2 deletions panel/models/column.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Column as BkColumn, ColumnView as BkColumnView} from "@bokehjs/models/layouts/column"
import * as DOM from "@bokehjs/core/dom"
import {div} from "@bokehjs/core/dom"
import type * as p from "@bokehjs/core/properties"

export class ColumnView extends BkColumnView {
Expand Down Expand Up @@ -62,7 +62,7 @@ export class ColumnView extends BkColumnView {

override render(): void {
super.render()
this.scroll_down_button_el = DOM.createElement("div", {class: "scroll-button"})
this.scroll_down_button_el = div({class: "scroll-button"})
this.shadow_el.appendChild(this.scroll_down_button_el)
this.el.addEventListener("scroll", () => {
this.record_scroll_position()
Expand Down
2 changes: 1 addition & 1 deletion panel/models/echarts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class EChartsView extends HTMLBoxView {
(window as any).echarts.dispose(this._chart)
}
super.render()
this.container = div({style: "height: 100%; width: 100%;"})
this.container = div({style: {height: "100%", width: "100%"}})
const config = {width: this.model.width, height: this.model.height, renderer: this.model.renderer}
this._chart = (window as any).echarts.init(
this.container,
Expand Down
2 changes: 1 addition & 1 deletion panel/models/perspective.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class PerspectiveView extends HTMLBoxView {
const container = div({
class: "pnx-perspective-viewer",
style: {
zIndex: 0,
zIndex: "0",
},
})
this._current_plugin = this.model.plugin
Expand Down
2 changes: 1 addition & 1 deletion panel/models/quill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class QuillInputView extends HTMLBoxView {

override render(): void {
super.render()
this.container = div({style: "visibility: hidden;"})
this.container = div({style: {visibility: "hidden"}})
this.shadow_el.appendChild(this.container)
const theme = (this.model.mode === "bubble") ? "bubble" : "snow"
this.watch_stylesheets()
Expand Down
2 changes: 1 addition & 1 deletion panel/models/reactive_html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class ReactiveHTMLView extends HTMLBoxView {
this._apply_styles()
this._apply_visible()

this.container = div({style: "display: contents;"})
this.container = div({style: {display: "contents"}})
this.shadow_el.append(this.container)
this._update()
this._render_children()
Expand Down
6 changes: 3 additions & 3 deletions panel/models/tabulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,8 @@ export class DataTabulatorView extends HTMLBoxView {
}
super.render()
this._initializing = true
const container = div({style: "display: contents;"})
const el = div({style: "width: 100%; height: 100%; visibility: hidden;"})
const container = div({style: {display: "contents"}})
const el = div({style: {width: "100%", height: "100%", visibility: "hidden"}})
this.container = el
this.setCSSClasses(el)
container.appendChild(el)
Expand Down Expand Up @@ -736,7 +736,7 @@ export class DataTabulatorView extends HTMLBoxView {
const style = getComputedStyle(this.tabulator.element.children[1].children[0])
const bg = style.backgroundColor
const neg_margin = rowEl.style.paddingLeft ? `-${rowEl.style.paddingLeft}` : "0"
const viewEl = div({style: `background-color: ${bg}; margin-left:${neg_margin}; max-width: 100%; overflow-x: hidden;`})
const viewEl = div({style: {background_color: bg, margin_left: neg_margin, max_width: "100%", overflow_x: "hidden"}})
viewEl.appendChild(view.el)
rowEl.appendChild(viewEl)
if (!view.has_finished()) {
Expand Down
12 changes: 6 additions & 6 deletions panel/models/trend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export class TrendIndicatorView extends HTMLBoxView {

override initialize(): void {
super.initialize()
this.containerDiv = div({style: "height:100%; width:100%;"})
this.titleDiv = div({style: "font-size: 1em; word-wrap: break-word;"})
this.valueDiv = div({style: "font-size: 2em"})
this.value2Div = div({style: "font-size: 1em; opacity: 0.5; display: inline"})
this.changeDiv = div({style: "font-size: 1em; opacity: 0.5; display: inline"})
this.containerDiv = div({style: {height: "100%", width: "100%"}})
this.titleDiv = div({style: {font_size: "1em", word_wrap: "break-word"}})
this.valueDiv = div({style: {font_size: "2em"}})
this.value2Div = div({style: {font_size: "1em", opacity: "0.5", display: "inline"}})
this.changeDiv = div({style: {font_size: "1em", opacity: "0.5", display: "inline"}})
this.textDiv = div({}, this.titleDiv, this.valueDiv, div({}, this.changeDiv, this.value2Div))

this.updateTitle()
Expand All @@ -41,7 +41,7 @@ export class TrendIndicatorView extends HTMLBoxView {
this.updateTextFontSize()

this.plotDiv = div({})
this.containerDiv = div({style: "height:100%; width:100%"}, this.textDiv, this.plotDiv)
this.containerDiv = div({style: {height: "100%", width: "100%"}}, this.textDiv, this.plotDiv)
this.updateLayout()
}

Expand Down
2 changes: 1 addition & 1 deletion panel/models/vizzu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export class VizzuChartView extends HTMLBoxView {

override render(): void {
super.render()
this.container = div({style: "display: contents;"})
this.container = div({style: {display: "contents"}})
this.shadow_el.append(this.container)
const state = {config: this.config(), data: this.data(), style: this.model.style}
this.vizzu_view = new (window as any).Vizzu(this.container, state)
Expand Down
2 changes: 1 addition & 1 deletion panel/models/vtk/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ export function data2VTKImageData(data: VolumeType): any {
const dataArray = vtkns.DataArray.newInstance({
name: "scalars",
numberOfComponents: 1,
values: new ARRAY_TYPES[data.dtype as DType](utf8ToAB(atob(data.buffer))),
values: new ARRAY_TYPES[data.dtype](utf8ToAB(atob(data.buffer))),
})
source.getPointData().setScalars(dataArray)
return source
Expand Down
2 changes: 1 addition & 1 deletion panel/models/vtk/vtkvolume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class VTKVolumePlotView extends AbstractVTKView {
this._create_orientation_widget()
this._set_axes()
this._vtk_renwin.getRenderer().resetCamera()
if (Object.keys(this.model.camera).length) {
if (Object.keys(this.model.camera).length > 0) {
this._set_camera_state()
}
this._get_camera_state()
Expand Down
Loading

0 comments on commit 2efb591

Please sign in to comment.