Skip to content

Commit e3b565e

Browse files
committed
Use import() for better namespacing
1 parent 5a12147 commit e3b565e

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

R/kaleido.R

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,14 @@ kaleido <- function(...) {
4444
if (!reticulate::py_available(initialize = TRUE)) {
4545
stop("`kaleido()` requires `reticulate::py_available()` to be `TRUE`. Do you need to install python?")
4646
}
47-
reticulate::py_run_string(
48-
"from kaleido.scopes.plotly import PlotlyScope",
49-
convert = FALSE
50-
)
47+
48+
py <- reticulate::py
5149
scope_name <- paste0("scope_", new_id())
52-
reticulate::py_run_string(
53-
sprintf("%s = PlotlyScope(plotlyjs='%s')", scope_name, plotlyMainBundlePath()),
54-
convert = FALSE
50+
py[[scope_name]] <- reticulate::import("kaleido")$scopes$plotly$PlotlyScope(
51+
plotlyjs = plotlyMainBundlePath()
5552
)
5653

57-
scope <- reticulate::py[[scope_name]]
54+
scope <- py[[scope_name]]
5855

5956
mapbox <- Sys.getenv("MAPBOX_TOKEN", NA)
6057
if (!is.na(mapbox)) {

0 commit comments

Comments
 (0)