Skip to content

Commit

Permalink
Merge pull request #74 from jonmmease/jonmmease/verbose_logging
Browse files Browse the repository at this point in the history
Add optional verbose logging, bump to 0.0.5
  • Loading branch information
jonmmease authored May 1, 2024
2 parents 689fd79 + 2ce5877 commit 6c29440
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 40 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions avenger-python/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "avenger-python"
version = "0.0.4"
version = "0.0.5"
edition = "2021"
license = "BSD-3-Clause"
description = "Python API to Avenger visualization framework"
Expand All @@ -17,17 +17,17 @@ pollster = "0.3"
[dependencies.avenger]
path = "../avenger"
features = [ "pyo3",]
version = "0.0.4"
version = "0.0.5"

[dependencies.avenger-vega]
path = "../avenger-vega"
features = [ "pyo3",]
version = "0.0.4"
version = "0.0.5"

[dependencies.avenger-wgpu]
path = "../avenger-wgpu"
features = [ "pyo3",]
version = "0.0.4"
version = "0.0.5"

[dependencies.pyo3]
workspace = true
Expand Down
12 changes: 6 additions & 6 deletions avenger-python/avenger/altair_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ._avenger import SceneGraph
from . import __version__
import copy

def avenger_png_renderer(spec: dict, **kwargs) -> dict:
Expand Down Expand Up @@ -29,7 +30,7 @@ def avenger_png_renderer(spec: dict, **kwargs) -> dict:
return {"image/png": sg.to_png(scale=kwargs.get("scale", None))}


def avenger_html_renderer(spec: dict, **kwargs) -> dict:
def avenger_html_renderer(spec: dict, verbose=False, **kwargs) -> dict:
"""
Altair renderer plugin that uses Avenger to render interactive charts
Expand All @@ -46,8 +47,7 @@ def avenger_html_renderer(spec: dict, **kwargs) -> dict:
from altair import VEGA_VERSION, VEGALITE_VERSION, VEGAEMBED_VERSION
import jinja2

template = jinja2.Template(
"""\
template_str = """\
<!DOCTYPE html>
<html>
<head>
Expand All @@ -67,8 +67,8 @@ def avenger_html_renderer(spec: dict, **kwargs) -> dict:
<div class="vega-visualization" id="{{ output_div }}"></div>
<script type="module">
import vegaEmbed, { vega } from "https://esm.sh/vega-embed@6?deps=vega@5&[email protected]";
import { registerVegaRenderer } from "https://esm.sh/avenger-vega-renderer@0.0.4";
registerVegaRenderer(vega.renderModule);
import { registerVegaRenderer } from "https://esm.sh/avenger-vega-renderer@""" + __version__ + """";
registerVegaRenderer(vega.renderModule, """ + str(verbose).lower() + """);
const spec = {{ spec }};
const embedOpt = {{ embed_options }};
Expand All @@ -77,7 +77,7 @@ def avenger_html_renderer(spec: dict, **kwargs) -> dict:
</body>
</html>
"""
)
template = jinja2.Template(template_str)

embed_options = copy.deepcopy(kwargs.get("embed_options", {}))
embed_options["renderer"] = "avenger"
Expand Down
2 changes: 1 addition & 1 deletion avenger-python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "avenger"
version = "0.0.4"
version = "0.0.5"
readme = "README.md"
description = "A Visualization Engine and Renderer"

Expand Down
15 changes: 8 additions & 7 deletions avenger-vega-renderer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[package]
name = "avenger-vega-renderer"
version = "0.0.4"
version = "0.0.5"
edition = "2021"

[lib]
crate-type = [ "cdylib", "rlib",]

[features]
deno = [ "avenger-wgpu/deno", "wgpu/webgpu"]
default = [ "wgpu/webgl" ]
deno = [ "avenger-wgpu/deno", "wgpu/webgpu",]
default = [ "wgpu/webgl",]

[dependencies]
lazy_static = "1.4.0"
serde_json = "1.0.114"
Expand All @@ -25,21 +26,21 @@ version = "0.1.1"

[dependencies.avenger-vega]
path = "../avenger-vega"
version = "0.0.4"
version = "0.0.5"

[dependencies.avenger]
path = "../avenger"
version = "0.0.4"
version = "0.0.5"

[dependencies.avenger-wgpu]
path = "../avenger-wgpu"
default-features = false
version = "0.0.4"
version = "0.0.5"

[dependencies.wgpu]
version = "0.19.3"
default-features = false
features = [ "wgsl" ]
features = [ "wgsl",]

[dependencies.wasm-bindgen]
version = "=0.2.92"
Expand Down
15 changes: 12 additions & 3 deletions avenger-vega-renderer/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { importScenegraph } from "./marks/scenegraph.js"
// Load wasm
instantiate();

const AVENGER_OPTIONS = {}

function devicePixelRatio() {
return typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1;
}
Expand Down Expand Up @@ -102,7 +104,7 @@ inherits(AvengerRenderer, Renderer, {
},

_render(scene) {
console.log("scene graph construction time: " + (performance.now() - this._lastRenderFinishTime));
this.log("scene graph construction time: " + (performance.now() - this._lastRenderFinishTime))
this._avengerCanvasPromise.then((avengerCanvas) => {
var start = performance.now();
importScenegraph(
Expand All @@ -113,11 +115,17 @@ inherits(AvengerRenderer, Renderer, {
this._loader,
).then((sceneGraph) => {
avengerCanvas.set_scene(sceneGraph);
console.log("_render time: " + (performance.now() - start));
this.log("_render time: " + (performance.now() - start));
});
});
this._lastRenderFinishTime = performance.now();
return this;
},

log(msg) {
if (AVENGER_OPTIONS["verbose"]) {
console.log(msg);
}
}
})

Expand All @@ -132,7 +140,8 @@ inherits(AvengerHandler, CanvasHandler, {
}
});

export function registerVegaRenderer(renderModule) {
export function registerVegaRenderer(renderModule, verbose) {
AVENGER_OPTIONS['verbose'] = verbose ?? false;
// Call with renderModule function from 'vega-scenegraph'
renderModule('avenger', {
handler: AvengerHandler,
Expand Down
2 changes: 1 addition & 1 deletion avenger-vega-renderer/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion avenger-vega-renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "avenger-vega-renderer",
"version": "0.0.4",
"version": "0.0.5",
"description": "",
"main": "js/index.js",
"files": [
Expand Down
1 change: 0 additions & 1 deletion avenger-vega-renderer/src/marks/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub struct PathMark {

impl PathMark {
pub fn build(self) -> RsPathMark {
log(&format!("{:#?}", self.inner));
self.inner
}
}
Expand Down
2 changes: 1 addition & 1 deletion avenger-vega-renderer/test/test_server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const spec = {
};

// Make the "avenger" renderer available
registerVegaRenderer(renderModule);
registerVegaRenderer(renderModule, true);

// Make vega embed available globally so that we can call it using playwright
window.vegaEmbed = vegaEmbed;
Expand Down
2 changes: 1 addition & 1 deletion avenger-vega-renderer/test/test_server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion avenger-vega-test-data/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "avenger-vega-test-data"
version = "0.0.4"
version = "0.0.5"
edition = "2021"

[dependencies]
Expand Down
4 changes: 2 additions & 2 deletions avenger-vega/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "avenger-vega"
version = "0.0.4"
version = "0.0.5"
edition = "2021"
description = "Utilities for importing Vega scenegraphs into Avenger"
license = "BSD-3-Clause"
Expand Down Expand Up @@ -33,7 +33,7 @@ workspace = true

[dependencies.avenger]
path = "../avenger"
version = "0.0.4"
version = "0.0.5"

[dependencies.thiserror]
workspace = true
Expand Down
6 changes: 3 additions & 3 deletions avenger-wgpu/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "avenger-wgpu"
version = "0.0.4"
version = "0.0.5"
edition = "2021"
description = "WGPU rendering engine for the Avenger visualization framework"
license = "BSD-3-Clause"
Expand Down Expand Up @@ -33,7 +33,7 @@ rstest = "0.18.2"

[dependencies.avenger]
path = "../avenger"
version = "0.0.4"
version = "0.0.5"

[dependencies.rayon]
workspace = true
Expand Down Expand Up @@ -67,7 +67,7 @@ workspace = true
[dev-dependencies.avenger-vega]
path = "../avenger-vega"
features = [ "image-request", "svg",]
version = "0.0.4"
version = "0.0.5"

[dev-dependencies.serde_json]
version = "1.0.111"
Expand Down
2 changes: 1 addition & 1 deletion avenger/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "avenger"
version = "0.0.4"
version = "0.0.5"
edition = "2021"
description = "A visualization engine and renderer"
license = "BSD-3-Clause"
Expand Down
2 changes: 1 addition & 1 deletion examples/vega-renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ var spec = {
// ]
// };

registerVegaRenderer(renderModule);
registerVegaRenderer(renderModule, true);

vegaEmbed('#plot-container', spec, {
// renderer: "canvas",
Expand Down

0 comments on commit 6c29440

Please sign in to comment.