Skip to content

When using enterprise version the "save and edit plot in the cloud" should default to the enterprise domain #444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lucacerone opened this issue Feb 1, 2016 · 10 comments

Comments

@lucacerone
Copy link

In my company we are running a trial using Plotly Enterprise version.

I have created some HTML reports using Rmarkdown and plotly. They look very nice but they show a button "save and edit plot in the cloud" to share data through plot.ly website. I think in an enterprise environment the default behaviour should be to share plots through the company version of plotly, not on the public one (to avoid potential sharing of confidential data).

Other things I was looking for related to this which I couldn't find:

  1. disable the "save and edit plot in the cloud" (it would be great if it can be set as a variable to be applied always, like tokens, username etc)
  2. choose the domain where the "save and edit plot" button should share the data

They are probably not bugs, but I think they would make great enhancements for the enterprise version.

@cpsievert
Copy link
Collaborator

Hi @lucacerone, great points! For (1), you can now do something like:

config(plot_ly(), modeBarButtonsToRemove = list('sendDataToCloud'))

For (2), as long as you have the plotly_domain environment variable configured to your domain, that should be the default behavior. In fact, you can check this configuration with plotly:::get_domain(). I suppose another way to check is to "build" to the plot and check the base_url property:

p <- plot_ly() %>% plotly_build()
p$base_url
#> [1] "https://plot.ly"

And, if you wanted, you could override this property for a specific plot, and print:

p$base_url <- "https://plotly.your-company.com"
p

@cpsievert
Copy link
Collaborator

Closing for now, but feel free to reopen if you have further issues.

@lucacerone
Copy link
Author

Hi Carson,
thanks I'll try to apply your advices.
Mind however that I set plotly_user plotly_api_token and plotly_domain
using Sys.setenv as explained in the tutorial.
If I check for them using Sys.getenv they look fine (I'll try to use
get_domain but that should be only a wrapper around Sys.getenv or not?)
plotly_POST sends plots to my company domain with no issues (well the
privacy is not applied correctly but I already opened an issue for that).

However so far I only tried to use ggplotly to convert some ggplot2 plots I
already had; maybe is an issue with ggplotly?

I'll try to do some plots from scratch in the future and let you know!

Thanks for the help!
On Feb 1, 2016 5:59 PM, "Carson" [email protected] wrote:

Hi @lucacerone https://github.com/lucacerone, great points! For (1),
you can now do something like:

config(plot_ly(), modeBarButtonsToRemove = list('sendDataToCloud'))

For (2), as long as you have the plotly_domain environment variable
configured to your domain, that should be the default behavior. In fact,
you can check this configuration with plotly:::get_domain(). I suppose
another way to check is to "build" to the plot and check the base_url
property:

p <- plot_ly() %>% plotly_build()p$base_url#> [1] "https://plot.ly"

And, if you wanted, you could override this property for a specific plot,
and print:

p$base_url <- "https://plotly.your-company.com"p


Reply to this email directly or view it on GitHub
#444 (comment).

@cpsievert
Copy link
Collaborator

plotly_POST sends plots to my company domain with no issues (well the privacy is not applied correctly but I already opened an issue for that)

Try installing the latest version (devtools::install_github('ropensci/plotly')) and configuring plotly_api_domain

@lucacerone
Copy link
Author

Thanks, I'll do it first thing tomorrow!
On Feb 1, 2016 9:26 PM, "Carson" [email protected] wrote:

plotly_POST sends plots to my company domain with no issues (well the
privacy is not applied correctly but I already opened an issue for that)

Try installing the latest version (
devtools::install_github('ropensci/plotly')) and configuring
plotly_api_domain
#441 (comment)


Reply to this email directly or view it on GitHub
#444 (comment).

@lucacerone
Copy link
Author

Yep, it is a problem specific to ggplotly.
I installed v2.4.0 from github master (a few minutes ago)
I set the environment variables as you explained here and in #441.
If I do:

library(ggplot2)
library(plotly)
p <- plot_ly() %>% plotly_build()
p$base_url

p$base_url is correctly set to my company url.

However if I do:

p <- ggplot(iris, aes(x=Petal.Length, y=Petal.Width, color = Species)) +  geom_point(size = 2)
p <- ggplotly(p)
p$base_url

then p$base_url is NULL rather than being my company one (I think it doesn't exist at all the element base_url in p:

"base_url" %in% names(as.list(p))

returns FALSE.

If now I do

plotly_POST(x = p, filename = "r_tests/boh",fileopt = "overwrite", sharing = "hidden")

it fails with error:

No encoding supplied: defaulting to UTF-8.
Aw, snap! We don't have an account for 'myusername'. Want to try again? You can authenticate with your email address or username. Sign in is not case sensitive.

Don't have an account? plot.ly

Questions? [email protected]
Error in curl::curl_fetch_memory(url, handle = handle) : 
  Couldn't resolve host name
In addition: Warning message:
In plotly_POST(x = p, filename = "r_tests/boh", fileopt = "overwrite",  :
  world_readable is no longer supported. Instead, set the sharing
argument to "private" (you must be logged in to access),
"hidden" (anybody with the obscured URL can access) or "public"
(anybody can view).

Maybe it depends on how I set the API domain?

The company plotly domain is of the form:

https://plotly.<sub>.<company>.com

So I set "plotly_api_domain" to be:
https://api-plotly.<sub>.<company>.com
does that seem correct?

Also, if I try to manually set p$base_url:

p$base_url <- Sys.getenv("plotly_domain")
p$base_url

shows:

[1]"https://plotly.sub.company.com" "https://plotly.sub.company.com" "https://plotly.sub.company.com"
........
[149] "https://plotly.sub.company.com" "https://plotly.sub.company.com"

@cpsievert cpsievert reopened this Feb 2, 2016
@cpsievert
Copy link
Collaborator

Ah, thanks for the detailed report, try reinstalling (devtools::install_github("ropensci/plotly")) and let me know if you still have issues

@lucacerone
Copy link
Author

Hi, sorry for the late reply.

I have just finished installing the latest version v2.4.1 but unfortunately plotly_POST still does not work.

In my .Rprofile file I have added:

Sys.setenv("plotly_domain"="https://plotly.sub.domain.com")
Sys.setenv("plotly_api_domain"="https://api-plotly.sub.domain.com")
Sys.setenv("plotly_username"="my_username")
Sys.setenv("plotly_api_key"="the_api_key")

I then started R (all the environment variables are set and accessible using Sys.getenv("plotly_username") etc etc)

I try to follow the very simple example at https://plot.ly/r/ (Run Locally or Publish on the Web):

library(plotly)
p <- plot_ly(midwest, x = percollege, color = state, type = "box")
# plotly_POST publishes the figure to your plotly account on the web
plotly_POST(p, filename = "r-docs/midwest-boxplots", sharing = "public" )

(by the way the examples on the web are not update to the new sharing parameter)

and I get the following message:

No encoding supplied: defaulting to UTF-8.
Aw, snap! We don't have an account for 'luca.cerone'. Want to try again? You can authenticate with your email address or username. Sign in is not case sensitive.

Don't have an account? plot.ly

Questions? [email protected]
Success! Created a new plotly here -> 
Error in utils::browseURL(x$url) : 
  'url' must be a non-empty character string

@cpsievert
Copy link
Collaborator

No worries, @lucacerone, my apologizes for the headaches, and thanks for helping out!

I think I have a fix in #457, but before I merge it into master, it'd be great if you could confirm that it works on your end. You can install with devtools::install_github("ropensci/plotly@fix/domain")

@lucacerone
Copy link
Author

Hi @cpsievert I finally had the time to try the branch you said and it works (meaning I can upload plots to the enterprise version of plotly)

However I have noticed two things:

  1. now "p" doesn't have the base_url field any more, is this the expected behaviour?
  2. if I create a plot using plot_ly then plotly_POST works fine, if I use plotly_POST on a ggplot image converted to plotly using ggplotly the the post is uploaded, but I still receive a warning saying:
Success! Created a new plotly here -> https://plotly.sub.company.com/~user/178
Warning message:
In plotly_POST(p, filename = "r-docs/iris", sharing = "public") :
  world_readable is no longer supported. Instead, set the sharing
argument to "private" (you must be logged in to access),
"hidden" (anybody with the obscured URL can access) or "public"
(anybody can view).

Anyway thanks for the fix, can you let me know when it is merged in the main branch so that I can instll it?

Cheers,
Luca

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants