Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into dureuill/feature_with…
Browse files Browse the repository at this point in the history
…_axum

Signed-off-by: Andrei Gherghescu <[email protected]>
  • Loading branch information
andrei-ng committed May 10, 2024
2 parents 2340e36 + 1ce30f0 commit 8953f52
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 29 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2

updates:
- package-ecosystem: cargo
directory: /
schedule:
interval: daily
14 changes: 8 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: CI
on:
workflow_dispatch:
pull_request:
branches: [ master ]
branches: [ main ]
push:
branches: [ master ]
branches: [ main ]

# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
Expand All @@ -27,7 +27,7 @@ jobs:
components: rustfmt
- run: cargo fmt --all -- --check
- run: cd ${{ github.workspace }}/examples && cargo fmt --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
Expand Down Expand Up @@ -57,7 +57,9 @@ jobs:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cargo test --features plotly_ndarray,plotly_image,kaleido

- if: ${{ matrix.os == 'windows-latest' }}
run: gci -recurse -filter "*example*"

code-coverage:
name: Code Coverage
runs-on: ubuntu-latest
Expand All @@ -70,7 +72,7 @@ jobs:
# we are skipping anything to do with wasm here
- run: cargo llvm-cov --workspace --features plotly_ndarray,plotly_image,kaleido --lcov --output-path lcov.info
- uses: codecov/codecov-action@v3

build_examples:
name: Build Examples
strategy:
Expand All @@ -94,7 +96,7 @@ jobs:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- run: cd ${{ github.workspace }}/examples/${{ matrix.example }} && cargo build

build_wasm_examples:
name: Build Wasm Examples
strategy:
Expand Down
2 changes: 1 addition & 1 deletion examples/statistical_charts/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ fn fully_styled_box_plot() {
v
};

let x_data = vec![
let x_data = [
"Carmelo<br>Anthony",
"Dwyane<br>Wade",
"Deron<br>Williams",
Expand Down
10 changes: 5 additions & 5 deletions plotly/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ with-axum = ["askama/with-axum", "askama_axum"]
askama = { version = ">=0.11.0, <0.13.0", features = ["serde-json"] }
askama_axum = { version = "0.4.0", optional = true }
dyn-clone = "1"
erased-serde = "0.3"
erased-serde = "0.4"
getrandom = { version = "0.2", features = ["js"], optional = true }
image = { version = "0.24.2", optional = true }
image = { version = "0.24", optional = true }
js-sys = { version = "0.3", optional = true }
plotly_derive = { version = "0.8.4", path = "../plotly_derive" }
plotly_kaleido = { version = "0.8.4", path = "../plotly_kaleido", optional = true }
Expand All @@ -35,15 +35,15 @@ once_cell = "1"
serde = { version = "1.0.132", features = ["derive"] }
serde_json = "1.0.73"
serde_repr = "0.1"
serde_with = "2"
serde_with = ">=2, <4"
rand = "0.8"
wasm-bindgen = { version = "0.2", optional = true }
wasm-bindgen-futures = { version = "0.4", optional = true }

[dev-dependencies]
csv = "1.1.6"
image = "0.24.4"
itertools = "0.10.3"
image = "0.24"
itertools = ">=0.10, <0.13"
itertools-num = "0.1.3"
ndarray = "0.15.4"
plotly_kaleido = { version = "0.8.4", path = "../plotly_kaleido" }
Expand Down
7 changes: 6 additions & 1 deletion plotly/src/plot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl Traces {
///
/// let layout = Layout::new().title("<b>Line and Scatter Plot</b>".into());
/// plot.set_layout(layout);
///
///
/// # if false { // We don't actually want to try and display the plot in a browser when running a doctest.
/// plot.show();
/// # }
Expand Down Expand Up @@ -650,6 +650,7 @@ mod tests {
assert!(!dst.exists());
}

#[cfg(not(target_os = "windows"))]
#[test]
#[cfg(feature = "kaleido")]
fn test_save_to_png() {
Expand All @@ -661,6 +662,7 @@ mod tests {
assert!(!dst.exists());
}

#[cfg(not(target_os = "windows"))]
#[test]
#[cfg(feature = "kaleido")]
fn test_save_to_jpeg() {
Expand All @@ -672,6 +674,7 @@ mod tests {
assert!(!dst.exists());
}

#[cfg(not(target_os = "windows"))]
#[test]
#[cfg(feature = "kaleido")]
fn test_save_to_svg() {
Expand All @@ -695,6 +698,7 @@ mod tests {
assert!(!dst.exists());
}

#[cfg(not(target_os = "windows"))]
#[test]
#[cfg(feature = "kaleido")]
fn test_save_to_pdf() {
Expand All @@ -706,6 +710,7 @@ mod tests {
assert!(!dst.exists());
}

#[cfg(not(target_os = "windows"))]
#[test]
#[cfg(feature = "kaleido")]
fn test_save_to_webp() {
Expand Down
8 changes: 4 additions & 4 deletions plotly_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ edition = "2018"
keywords = ["plot", "chart", "plotly"]

[dependencies]
quote = "1.0"
syn = "1.0"
proc-macro2 = "1.0"
darling = "0.14.1"
quote = "1"
syn = "2"
proc-macro2 = "1"
darling = "0.20"

[lib]
proc-macro = true
2 changes: 1 addition & 1 deletion plotly_derive/src/field_setter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ impl FieldReceiver {
self.attrs
.iter()
.filter(|attr| {
attr.path
attr.path()
.segments
.first()
.map_or(false, |p| p.ident == name)
Expand Down
12 changes: 4 additions & 8 deletions plotly_kaleido/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@ exclude = ["target/*", "kaleido/*", "examples/*"]
[dependencies]
serde = { version = "1.0.132", features = ["derive"] }
serde_json = "1.0.73"
base64 = "0.13.0"
base64 = "0.22"
dunce = "1.0.2"
directories = "4.0.1"

[dev-dependencies]
zip = "0.5.13"
directories = ">=4, <6"

[build-dependencies]
zip = "0.5.13"
directories = "4.0.1"

zip = "1.1"
directories = ">=4, <6"
6 changes: 5 additions & 1 deletion plotly_kaleido/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ use std::process::Command;

use directories::ProjectDirs;

#[cfg(target_os = "linux")]
#[cfg(all(target_arch = "x86_64", target_os = "linux"))]
const KALEIDO_URL: &str =
"https://github.com/plotly/Kaleido/releases/download/v0.2.1/kaleido_linux_x64.zip";

#[cfg(all(target_arch = "aarch64", target_os = "linux"))]
const KALEIDO_URL: &str =
"https://github.com/plotly/Kaleido/releases/download/v0.2.1/kaleido_linux_arm64.zip";

#[cfg(target_os = "windows")]
const KALEIDO_URL: &str =
"https://github.com/plotly/Kaleido/releases/download/v0.2.1/kaleido_win_x64.zip";
Expand Down
10 changes: 8 additions & 2 deletions plotly_kaleido/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::io::BufReader;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};

use base64::{engine::general_purpose, Engine as _};
use directories::ProjectDirs;
use serde::{Deserialize, Serialize};
use serde_json::Value;
Expand Down Expand Up @@ -163,12 +164,12 @@ impl Kaleido {
}

let output_lines = BufReader::new(process.stdout.unwrap()).lines();
for line in output_lines.flatten() {
for line in output_lines.map_while(Result::ok) {
let res = KaleidoResult::from(line.as_str());
if let Some(image_data) = res.result {
let data: Vec<u8> = match format {
"svg" | "eps" => image_data.as_bytes().to_vec(),
_ => base64::decode(image_data).unwrap(),
_ => general_purpose::STANDARD.decode(image_data).unwrap(),
};
let mut file = File::create(dst.as_path())?;
file.write_all(&data)?;
Expand Down Expand Up @@ -237,6 +238,7 @@ mod tests {
assert_eq!(to_value(kaleido_data).unwrap(), expected);
}

#[cfg(not(target_os = "windows"))]
#[test]
fn test_save_png() {
let test_plot = create_test_plot();
Expand All @@ -247,6 +249,7 @@ mod tests {
assert!(std::fs::remove_file(dst.as_path()).is_ok());
}

#[cfg(not(target_os = "windows"))]
#[test]
fn test_save_jpeg() {
let test_plot = create_test_plot();
Expand All @@ -257,6 +260,7 @@ mod tests {
assert!(std::fs::remove_file(dst.as_path()).is_ok());
}

#[cfg(not(target_os = "windows"))]
#[test]
fn test_save_webp() {
let test_plot = create_test_plot();
Expand All @@ -267,6 +271,7 @@ mod tests {
assert!(std::fs::remove_file(dst.as_path()).is_ok());
}

#[cfg(not(target_os = "windows"))]
#[test]
fn test_save_svg() {
let test_plot = create_test_plot();
Expand All @@ -277,6 +282,7 @@ mod tests {
assert!(std::fs::remove_file(dst.as_path()).is_ok());
}

#[cfg(not(target_os = "windows"))]
#[test]
fn test_save_pdf() {
let test_plot = create_test_plot();
Expand Down

0 comments on commit 8953f52

Please sign in to comment.