From 0522799caa15355df1b84abd2ca249aff87de58d Mon Sep 17 00:00:00 2001 From: Devin Smith Date: Wed, 13 Dec 2023 11:28:32 -0800 Subject: [PATCH] Update to_j_js_plugin --- py/server/deephaven_internal/plugin/js/__init__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/py/server/deephaven_internal/plugin/js/__init__.py b/py/server/deephaven_internal/plugin/js/__init__.py index 2ce5fca3d81..b0f18f3a8da 100644 --- a/py/server/deephaven_internal/plugin/js/__init__.py +++ b/py/server/deephaven_internal/plugin/js/__init__.py @@ -3,6 +3,8 @@ # import jpy +import pathlib + from deephaven.plugin.js import JsPlugin _JJsPlugin = jpy.get_type("io.deephaven.plugin.js.JsPlugin") @@ -10,11 +12,18 @@ def to_j_js_plugin(js_plugin: JsPlugin) -> jpy.JType: - j_path = _JPath.of(str(js_plugin.path)) + path = js_plugin.path() + if not isinstance(path, pathlib.Path): + # Adding a little bit of extra safety for this version of the server. + # There's potential that the return type of JsPlugin.path expands in the future. + raise Exception( + f"Expecting pathlib.Path, is type(js_plugin.path())={type(path)}, js_plugin={js_plugin}" + ) + j_path = _JPath.of(str(path)) main_path = j_path.relativize(j_path.resolve(js_plugin.main)) builder = _JJsPlugin.builder() builder.name(js_plugin.name) builder.version(js_plugin.version) builder.main(main_path) - builder.path(path) + builder.path(j_path) return builder.build()