Skip to content

Commit 45a7e14

Browse files
authored
Update Vega-Lite to 5.21, remove 5.13, add Python functions to retrieve library versions (#194)
* Add vega-lite 5.21, remove 5.13 * update tests * Add Python methods to retrieve the bundled library versions * py-fmt * fmt-rs * clipy fix * fmt * fix cli tests * run cli tests with pixi
1 parent fb0080c commit 45a7e14

39 files changed

+183
-3986
lines changed

.github/workflows/CI.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ jobs:
134134
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections
135135
sudo apt-get install ttf-mscorefonts-installer
136136
- name: Run tests
137-
run: pixi run test-rs
137+
run: |
138+
pixi run test-rs
139+
pixi run test-cli
138140
- name: Upload test failures
139141
uses: actions/upload-artifact@v3
140142
if: always()

vl-convert-python/src/lib.rs

+50-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ use std::str::FromStr;
99
use std::sync::Mutex;
1010
use vl_convert_rs::converter::{FormatLocale, Renderer, TimeFormatLocale, VgOpts, VlOpts};
1111
use vl_convert_rs::html::bundle_vega_snippet;
12-
use vl_convert_rs::module_loader::import_map::VlVersion;
12+
use vl_convert_rs::module_loader::import_map::{
13+
VlVersion, VEGA_EMBED_VERSION, VEGA_THEMES_VERSION, VEGA_VERSION, VL_VERSIONS,
14+
};
1315
use vl_convert_rs::module_loader::{FORMATE_LOCALE_MAP, TIME_FORMATE_LOCALE_MAP};
1416
use vl_convert_rs::serde_json;
1517
use vl_convert_rs::text::register_font_directory as register_font_directory_rs;
@@ -1145,6 +1147,49 @@ fn javascript_bundle(snippet: Option<String>, vl_version: Option<&str>) -> PyRes
11451147
}
11461148
}
11471149

1150+
/// Get the bundled version of Vega
1151+
///
1152+
/// Returns:
1153+
/// str: Vega version string (e.g. "5.30.0")
1154+
#[pyfunction]
1155+
#[pyo3(signature = ())]
1156+
fn get_vega_version() -> String {
1157+
VEGA_VERSION.to_string()
1158+
}
1159+
1160+
/// Get the bundled version of Vega-Themes
1161+
///
1162+
/// Returns:
1163+
/// str: Vega-Themes version string (e.g. "2.14.0")
1164+
#[pyfunction]
1165+
#[pyo3(signature = ())]
1166+
fn get_vega_themes_version() -> String {
1167+
VEGA_THEMES_VERSION.to_string()
1168+
}
1169+
1170+
/// Get the bundled version of Vega-Embed
1171+
///
1172+
/// Returns:
1173+
/// str: Vega-Embed version string (e.g. "6.26.0")
1174+
#[pyfunction]
1175+
#[pyo3(signature = ())]
1176+
fn get_vega_embed_version() -> String {
1177+
VEGA_EMBED_VERSION.to_string()
1178+
}
1179+
1180+
/// Get the bundled versions of Vega-Lite
1181+
///
1182+
/// Returns:
1183+
/// list: Vega-Lite version strings (e.g. ["5.8", "5.9", ..., "5.21"])
1184+
#[pyfunction]
1185+
#[pyo3(signature = ())]
1186+
fn get_vegalite_versions() -> Vec<String> {
1187+
VL_VERSIONS
1188+
.iter()
1189+
.map(|v| v.to_semver().to_string())
1190+
.collect()
1191+
}
1192+
11481193
/// Convert Vega-Lite specifications to other formats
11491194
#[pymodule]
11501195
fn vl_convert(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
@@ -1172,6 +1217,10 @@ fn vl_convert(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
11721217
m.add_function(wrap_pyfunction!(get_format_locale, m)?)?;
11731218
m.add_function(wrap_pyfunction!(get_time_format_locale, m)?)?;
11741219
m.add_function(wrap_pyfunction!(javascript_bundle, m)?)?;
1220+
m.add_function(wrap_pyfunction!(get_vega_version, m)?)?;
1221+
m.add_function(wrap_pyfunction!(get_vega_themes_version, m)?)?;
1222+
m.add_function(wrap_pyfunction!(get_vega_embed_version, m)?)?;
1223+
m.add_function(wrap_pyfunction!(get_vegalite_versions, m)?)?;
11751224
m.add("__version__", env!("CARGO_PKG_VERSION"))?;
11761225
Ok(())
11771226
}

vl-convert-python/tests/test_specs.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def load_expected_png(name, vl_version, theme=None):
7272
@pytest.mark.parametrize("name", ["circle_binned", "seattle-weather", "stacked_bar_h"])
7373
@pytest.mark.parametrize(
7474
"vl_version",
75-
["v5_8", "v5_13", "v5_14", "v5_15", "v5_16", "v5_17", "v5_18", "v5_19", "v5_20"],
75+
["v5_8", "v5_14", "v5_15", "v5_16", "v5_17", "v5_18", "v5_19", "v5_20", "v5_21"],
7676
)
7777
@pytest.mark.parametrize("as_dict", [False, True])
7878
def test_vega(name, vl_version, as_dict):
@@ -96,14 +96,14 @@ def test_vega(name, vl_version, as_dict):
9696
"vl_version",
9797
[
9898
"5.8",
99-
"5.13",
10099
"5.14",
101100
"5.15",
102101
"5.16",
103102
"5.17",
104103
"5.18",
105104
"5.19",
106105
"5.20",
106+
"5.21",
107107
],
108108
)
109109
def test_vegalite_to_html_no_bundle(name, vl_version):
@@ -132,14 +132,14 @@ def test_vegalite_to_html_no_bundle(name, vl_version):
132132
"vl_version",
133133
[
134134
"5.8",
135-
"5.13",
136135
"5.14",
137136
"5.15",
138137
"5.16",
139138
"5.17",
140139
"5.18",
141140
"5.19",
142141
"5.20",
142+
"5.21",
143143
],
144144
)
145145
def test_vegalite_to_html_bundle(name, vl_version):

vl-convert-python/vl_convert.pyi

+44
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,10 @@ __all__ = [
153153
"vegalite_to_svg",
154154
"vegalite_to_url",
155155
"vegalite_to_vega",
156+
"get_vega_version",
157+
"get_vega_themes_version",
158+
"get_vega_embed_version",
159+
"get_vegalite_versions",
156160
]
157161

158162
def get_format_locale(name: FormatLocaleName) -> dict[str, Any]:
@@ -807,3 +811,43 @@ def vegalite_to_vega(
807811
Vega JSON specification dict.
808812
"""
809813
...
814+
815+
def get_vega_version() -> str:
816+
"""
817+
Get the bundled version of Vega
818+
819+
Returns
820+
-------
821+
Vega version string (e.g. "5.30.0")
822+
"""
823+
...
824+
825+
def get_vega_themes_version() -> str:
826+
"""
827+
Get the bundled version of Vega-Themes
828+
829+
Returns
830+
-------
831+
Vega-Themes version string (e.g. "2.14.0")
832+
"""
833+
...
834+
835+
def get_vega_embed_version() -> str:
836+
"""
837+
Get the bundled version of Vega-Embed
838+
839+
Returns
840+
-------
841+
Vega-Embed version string (e.g. "6.26.0")
842+
"""
843+
...
844+
845+
def get_vegalite_versions() -> list[str]:
846+
"""
847+
Get the bundled versions of Vega-Lite
848+
849+
Returns
850+
-------
851+
Vega-Lite version strings (e.g. ["5.8", "5.9", ..., "5.21"])
852+
"""
853+
...

vl-convert-rs/src/module_loader/import_map.rs

+13-9
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ pub const VEGA_EMBED_PATH: &str =
1515
"/pin/[email protected]/mode=imports,min/optimized/vega-embed.js";
1616
pub const DEBOUNCE_PATH: &str = "/pin/[email protected]/mode=imports,min/optimized/lodash.debounce.js";
1717

18+
pub const VEGA_VERSION: &str = "5.30.0";
19+
pub const VEGA_THEMES_VERSION: &str = "2.15.0";
20+
pub const VEGA_EMBED_VERSION: &str = "6.26.0";
21+
1822
pub fn url_for_path(path: &str) -> String {
1923
format!("{}{}", SKYPACK_URL, path)
2024
}
@@ -31,29 +35,29 @@ pub fn vega_themes_url() -> String {
3135
#[allow(non_camel_case_types)]
3236
pub enum VlVersion {
3337
v5_8,
34-
v5_13,
3538
v5_14,
3639
v5_15,
3740
v5_16,
3841
v5_17,
3942
v5_18,
4043
v5_19,
4144
v5_20,
45+
v5_21,
4246
}
4347

4448
impl VlVersion {
4549
pub fn to_path(self) -> String {
4650
use VlVersion::*;
4751
let path = match self {
4852
v5_8 => "/pin/[email protected]/mode=imports,min/optimized/vega-lite.js",
49-
v5_13 => "/pin/[email protected]/mode=imports,min/optimized/vega-lite.js",
5053
v5_14 => "/pin/[email protected]/mode=imports,min/optimized/vega-lite.js",
5154
v5_15 => "/pin/[email protected]/mode=imports,min/optimized/vega-lite.js",
5255
v5_16 => "/pin/[email protected]/mode=imports,min/optimized/vega-lite.js",
5356
v5_17 => "/pin/[email protected]/mode=imports,min/optimized/vega-lite.js",
5457
v5_18 => "/pin/[email protected]/mode=imports,min/optimized/vega-lite.js",
5558
v5_19 => "/pin/[email protected]/mode=imports,min/optimized/vega-lite.js",
56-
v5_20 => "/pin/[email protected]/mode=imports,min/optimized/vega-lite.js"
59+
v5_20 => "/pin/[email protected]/mode=imports,min/optimized/vega-lite.js",
60+
v5_21 => "/pin/[email protected]/mode=imports,min/optimized/vega-lite.js"
5761
};
5862
path.to_string()
5963
}
@@ -66,21 +70,21 @@ impl VlVersion {
6670
use VlVersion::*;
6771
match self {
6872
v5_8 => "5.8",
69-
v5_13 => "5.13",
7073
v5_14 => "5.14",
7174
v5_15 => "5.15",
7275
v5_16 => "5.16",
7376
v5_17 => "5.17",
7477
v5_18 => "5.18",
7578
v5_19 => "5.19",
7679
v5_20 => "5.20",
80+
v5_21 => "5.21",
7781
}
7882
}
7983
}
8084

8185
impl Default for VlVersion {
8286
fn default() -> Self {
83-
VlVersion::from_str("5.20").unwrap()
87+
VlVersion::from_str("5.21").unwrap()
8488
}
8589
}
8690

@@ -90,29 +94,29 @@ impl FromStr for VlVersion {
9094
fn from_str(s: &str) -> Result<Self, Self::Err> {
9195
Ok(match s {
9296
"5.8" | "v5.8" | "5_8" | "v5_8" => Self::v5_8,
93-
"5.13" | "v5.13" | "5_13" | "v5_13" => Self::v5_13,
9497
"5.14" | "v5.14" | "5_14" | "v5_14" => Self::v5_14,
9598
"5.15" | "v5.15" | "5_15" | "v5_15" => Self::v5_15,
9699
"5.16" | "v5.16" | "5_16" | "v5_16" => Self::v5_16,
97100
"5.17" | "v5.17" | "5_17" | "v5_17" => Self::v5_17,
98101
"5.18" | "v5.18" | "5_18" | "v5_18" => Self::v5_18,
99102
"5.19" | "v5.19" | "5_19" | "v5_19" => Self::v5_19,
100103
"5.20" | "v5.20" | "5_20" | "v5_20" => Self::v5_20,
104+
"5.21" | "v5.21" | "5_21" | "v5_21" => Self::v5_21,
101105
_ => bail!("Unsupported Vega-Lite version string {}", s),
102106
})
103107
}
104108
}
105109

106110
pub const VL_VERSIONS: &[VlVersion] = &[
107111
VlVersion::v5_8,
108-
VlVersion::v5_13,
109112
VlVersion::v5_14,
110113
VlVersion::v5_15,
111114
VlVersion::v5_16,
112115
VlVersion::v5_17,
113116
VlVersion::v5_18,
114117
VlVersion::v5_19,
115118
VlVersion::v5_20,
119+
VlVersion::v5_21,
116120
];
117121

118122
pub fn build_import_map() -> HashMap<String, String> {
@@ -160,14 +164,14 @@ pub fn build_import_map() -> HashMap<String, String> {
160164
m.insert("/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-hierarchy.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-hierarchy.js").to_string());
161165
m.insert("/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-interpreter.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-interpreter.js").to_string());
162166
m.insert("/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-label.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-label.js").to_string());
163-
m.insert("/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js").to_string());
164167
m.insert("/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js").to_string());
165168
m.insert("/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js").to_string());
166169
m.insert("/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js").to_string());
167170
m.insert("/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js").to_string());
168171
m.insert("/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js").to_string());
169172
m.insert("/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js").to_string());
170173
m.insert("/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js").to_string());
174+
m.insert("/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js").to_string());
171175
m.insert("/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-lite.js").to_string());
172176
m.insert("/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-loader.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-loader.js").to_string());
173177
m.insert("/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-parser.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega-parser.js").to_string());
@@ -191,14 +195,14 @@ pub fn build_import_map() -> HashMap<String, String> {
191195
m.insert("/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/-/[email protected]/dist=es2020,mode=imports,min/optimized/vega.js").to_string());
192196
m.insert("/pin/[email protected]/mode=imports,min/optimized/lodash.debounce.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/pin/[email protected]/mode=imports,min/optimized/lodash.debounce.js").to_string());
193197
m.insert("/pin/[email protected]/mode=imports,min/optimized/vega-embed.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/pin/[email protected]/mode=imports,min/optimized/vega-embed.js").to_string());
194-
m.insert("/pin/[email protected]/mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/pin/[email protected]/mode=imports,min/optimized/vega-lite.js").to_string());
195198
m.insert("/pin/[email protected]/mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/pin/[email protected]/mode=imports,min/optimized/vega-lite.js").to_string());
196199
m.insert("/pin/[email protected]/mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/pin/[email protected]/mode=imports,min/optimized/vega-lite.js").to_string());
197200
m.insert("/pin/[email protected]/mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/pin/[email protected]/mode=imports,min/optimized/vega-lite.js").to_string());
198201
m.insert("/pin/[email protected]/mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/pin/[email protected]/mode=imports,min/optimized/vega-lite.js").to_string());
199202
m.insert("/pin/[email protected]/mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/pin/[email protected]/mode=imports,min/optimized/vega-lite.js").to_string());
200203
m.insert("/pin/[email protected]/mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/pin/[email protected]/mode=imports,min/optimized/vega-lite.js").to_string());
201204
m.insert("/pin/[email protected]/mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/pin/[email protected]/mode=imports,min/optimized/vega-lite.js").to_string());
205+
m.insert("/pin/[email protected]/mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/pin/[email protected]/mode=imports,min/optimized/vega-lite.js").to_string());
202206
m.insert("/pin/[email protected]/mode=imports,min/optimized/vega-lite.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/pin/[email protected]/mode=imports,min/optimized/vega-lite.js").to_string());
203207
m.insert("/pin/[email protected]/mode=imports,min/optimized/vega-themes.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/pin/[email protected]/mode=imports,min/optimized/vega-themes.js").to_string());
204208
m.insert("/pin/[email protected]/mode=imports,min/optimized/vega.js".to_string(), include_str!("../../vendor/cdn.skypack.dev/pin/[email protected]/mode=imports,min/optimized/vega.js").to_string());

vl-convert-rs/tests/test_specs.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,14 @@ mod test_vegalite_to_vega {
316316
fn test(
317317
#[values(
318318
VlVersion::v5_8,
319-
VlVersion::v5_13,
320319
VlVersion::v5_14,
321320
VlVersion::v5_15,
322321
VlVersion::v5_16,
323322
VlVersion::v5_17,
324323
VlVersion::v5_18,
325324
VlVersion::v5_19,
326325
VlVersion::v5_20,
326+
VlVersion::v5_21,
327327
)]
328328
vl_version: VlVersion,
329329

@@ -361,14 +361,14 @@ mod test_vegalite_to_html_no_bundle {
361361
fn test(
362362
#[values(
363363
VlVersion::v5_8,
364-
VlVersion::v5_13,
365364
VlVersion::v5_14,
366365
VlVersion::v5_15,
367366
VlVersion::v5_16,
368367
VlVersion::v5_17,
369368
VlVersion::v5_18,
370369
VlVersion::v5_19,
371370
VlVersion::v5_20,
371+
VlVersion::v5_21,
372372
)]
373373
vl_version: VlVersion,
374374

@@ -409,14 +409,14 @@ mod test_vegalite_to_html_bundle {
409409
fn test(
410410
#[values(
411411
VlVersion::v5_8,
412-
VlVersion::v5_13,
413412
VlVersion::v5_14,
414413
VlVersion::v5_15,
415414
VlVersion::v5_16,
416415
VlVersion::v5_17,
417416
VlVersion::v5_18,
418417
VlVersion::v5_19,
419418
VlVersion::v5_20,
419+
VlVersion::v5_21,
420420
)]
421421
vl_version: VlVersion,
422422

0 commit comments

Comments
 (0)