Skip to content

Commit 867f670

Browse files
fix: get integration test working and support vega 6
1 parent c1c0883 commit 867f670

File tree

6 files changed

+75
-31
lines changed

6 files changed

+75
-31
lines changed

.github/workflows/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ jobs:
368368
# osx should work fine (and we test that locally often)
369369
os: [ubuntu, windows]
370370
# just 1 version, it's heavy
371-
python-version: [3.9]
371+
python-version: [3.9, 3.14]
372372
ipywidgets_major: ["7", "8"]
373373
include:
374374
- ipywidgets_major: "7"

packages/solara-enterprise/solara_enterprise/ssg.py

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import logging
33
import threading
44
import time
5+
import sys
56
import typing
67
import urllib
78
import weakref
@@ -65,26 +66,49 @@ def _worker_with_cleanup(*args, **kwargs):
6566

6667

6768
class CleanupThreadPoolExecutor(concurrent.futures.ThreadPoolExecutor):
68-
def _adjust_thread_count(self):
69-
# copy of the original code with _worker replaced
70-
# if idle threads are available, don't spin new threads
71-
if self._idle_semaphore.acquire(timeout=0):
72-
return
73-
74-
# When the executor gets lost, the weakref callback will wake up
75-
# the worker threads.
76-
def weakref_cb(_, q=self._work_queue):
77-
q.put(None)
78-
79-
num_threads = len(self._threads)
80-
if num_threads < self._max_workers:
81-
thread_name = "%s_%d" % (self._thread_name_prefix or self, num_threads)
82-
t = threading.Thread(
83-
name=thread_name, target=_worker_with_cleanup, args=(weakref.ref(self, weakref_cb), self._work_queue, self._initializer, self._initargs)
84-
)
85-
t.start()
86-
self._threads.add(t) # type: ignore
87-
concurrent.futures.thread._threads_queues[t] = self._work_queue # type: ignore
69+
if sys.version_info < (3, 14):
70+
71+
def _adjust_thread_count(self):
72+
# copy of the original code with _worker replaced
73+
# if idle threads are available, don't spin new threads
74+
if self._idle_semaphore.acquire(timeout=0):
75+
return
76+
77+
# When the executor gets lost, the weakref callback will wake up
78+
# the worker threads.
79+
def weakref_cb(_, q=self._work_queue):
80+
q.put(None)
81+
82+
num_threads = len(self._threads)
83+
if num_threads < self._max_workers:
84+
thread_name = "%s_%d" % (self._thread_name_prefix or self, num_threads)
85+
t = threading.Thread(
86+
name=thread_name, target=_worker_with_cleanup, args=(weakref.ref(self, weakref_cb), self._work_queue, self._initializer, self._initargs)
87+
)
88+
t.start()
89+
self._threads.add(t) # type: ignore
90+
concurrent.futures.thread._threads_queues[t] = self._work_queue # type: ignore
91+
else:
92+
93+
def _adjust_thread_count(self):
94+
# if idle threads are available, don't spin new threads
95+
if self._idle_semaphore.acquire(timeout=0):
96+
return
97+
98+
# When the executor gets lost, the weakref callback will wake up
99+
# the worker threads.
100+
def weakref_cb(_, q=self._work_queue):
101+
q.put(None)
102+
103+
num_threads = len(self._threads)
104+
if num_threads < self._max_workers:
105+
thread_name = "%s_%d" % (self._thread_name_prefix or self, num_threads)
106+
t = threading.Thread(
107+
name=thread_name, target=_worker_with_cleanup, args=(weakref.ref(self, weakref_cb), self._create_worker_context(), self._work_queue)
108+
)
109+
t.start()
110+
self._threads.add(t)
111+
concurrent.futures.thread._threads_queues[t] = self._work_queue # type: ignore
88112

89113

90114
def ssg_crawl(base_url: str):

packages/solara-meta/pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ assets = [
3838

3939
documentation = [
4040
"bqplot",
41-
"altair",
41+
"altair ; python_version < '3.14'",
42+
"altair @ git+https://github.com/vega/altair.git ; python_version >= '3.14'",
4243
"folium",
4344
"ipycanvas",
4445
"ipyleaflet",
@@ -90,6 +91,9 @@ dev = [
9091
"numpy<2",
9192
]
9293

94+
[tool.hatch.metadata]
95+
allow-direct-references = true
96+
9397
[tool.hatch.build.targets.wheel]
9498
include = ["LICENSE"]
9599

solara/components/figure_altair.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,27 @@ def FigureAltair(
2727
bundle = chart._repr_mimebundle_()[0]
2828
key4 = "application/vnd.vegalite.v4+json"
2929
key5 = "application/vnd.vegalite.v5+json"
30-
if key4 not in bundle and key5 not in bundle:
31-
raise KeyError(f"{key4} and {key5} not in mimebundle:\n\n{bundle}")
32-
spec = bundle.get(key5, bundle.get(key4))
33-
return solara.widgets.VegaLite.element(
34-
spec=spec, on_click=on_click, listen_to_click=on_click is not None, on_hover=on_hover, listen_to_hover=on_hover is not None
35-
)
30+
key6 = "application/vnd.vegalite.v6.json"
31+
if key6 in bundle:
32+
version = 6
33+
spec = bundle.get(key6)
34+
elif key5 in bundle:
35+
version = 5
36+
spec = bundle.get(key5)
37+
elif key4 in bundle:
38+
version = 4
39+
spec = bundle.get(key4)
40+
else:
41+
raise KeyError(f"{key4} and {key5} and {key6} not in mimebundle:\n\n{bundle}")
42+
43+
return solara.widgets.VegaLite.element(
44+
version=version,
45+
spec=spec,
46+
on_click=on_click,
47+
listen_to_click=on_click is not None,
48+
on_hover=on_hover,
49+
listen_to_hover=on_hover is not None,
50+
)
3651

3752

3853
# alias for backward compatibility

solara/widgets/vue/vegalite.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ module.exports = {
7474
require.config({
7575
map: {
7676
'*': {
77-
'vega': `${this.getCdn()}/vega@5/build/vega.min.js`,
78-
'vega-lite': `${this.getCdn()}/vega-lite@5/build/vega-lite.min.js`,
79-
'vega-embed': `${this.getCdn()}/vega-embed@6/build/vega-embed.min.js`,
77+
'vega': `${this.getCdn()}/vega@${this.version}/build/vega.min.js`,
78+
'vega-lite': `${this.getCdn()}/vega-lite@${this.version}/build/vega-lite.min.js`,
79+
'vega-embed': `${this.getCdn()}/vega-embed@${this.version}/build/vega-embed.min.js`,
8080
}
8181
}
8282
})

solara/widgets/widgets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class VegaLite(v.VuetifyTemplate):
2222
on_click = traitlets.traitlets.Callable(None, allow_none=True)
2323
on_hover = traitlets.traitlets.Callable(None, allow_none=True)
2424
cdn = traitlets.Unicode(None, allow_none=True).tag(sync=True)
25+
version = traitlets.Int(6).tag(sync=True)
2526

2627
def vue_altair_click(self, *args):
2728
if self.on_click is not None:

0 commit comments

Comments
 (0)