Message Boards Message Boards

1
|
17838 Views
|
13 Replies
|
11 Total Likes
View groups...
Share
Share this post:

Deploy a dynamic notebook to the Wolfram Cloud?

How can I deploy a dynamic notebook (nb file) in the cloud without the user can modify it and see the code?
I did the following:
1.- upload the nb file to the cloud
2.- deploy it as a dynamic object
3.- double click to the resulting URL
As a result I got an editable website

POSTED BY: Jorge Manrique
13 Replies

Hi Rolf, Thanks very much for the hint! First of all, your reply reminded me that I forgot about the

SaveDefinitions -> True

option, this is why I had to re-run the notebook when it appeared in the Cloud. Including the above will generate the figure without the need of evaluating the notebook first (this refers to my own original version).

But your solution is much more elegant, because in my version above I do not only get the interactive figure, but also the part

CloudDeploy[EvaluationNotebook[],CloudObject["dynamic.nb"],Permissions->{All->{"Read","Interact","Evaluate"}}]
CloudObject[https://www.wolframcloud.com/objects/user-ae5ba858-01fd-4f89-98bf-039fb8a98aca/dynamic.nb]

In your solution these are absent, so one only gets the output, as I wanted.

There is only one minor thing: your suggestion only works when I run the above in the Development Platform. If I write a notebook and run it, then I still get the figure in the Cloud, but only as a static one, interactivity is lost. Is this how it should be? Thanks.

POSTED BY: Imre Pazsit

Hello Imre, I would do something like this (where you might want to be careful with the additional trick "?_view=frameless" in order to get more interactivity, since it also needs more cloud credits). Rolf

Clear[f1, f2, q1, q2, \[Beta], \[Nu], m]; \[Nu] = 2.42; m = 5; 
f1[z_, \[Beta]_] := (1 - (1/5)*(\[Nu]*(1 - \[Beta]))*(1 - z))^5; 
f2[z_, \[Beta]_] := 1 - \[Nu]*\[Beta]*(1 - z); 
q1[z_, \[Beta]_, \[Rho]_] := f1[z, \[Beta]]/(\[Nu]*(1 - \[Rho])) + 1 - 1/(\[Nu]*(1 - \[Rho])); 
q2[z_, \[Beta]_, \[Rho]_] := f2[z, \[Beta]]/(\[Nu]*(1 - \[Rho])) + 1 - 1/(\[Nu]*(1 - \[Rho])); 
dyn = Manipulate[Plot[{y, q1[y, \[Beta], \[Rho]]*q2[y, \[Beta], \[Rho]]}, {y, 0, 1}, 
    BaseStyle -> {FontFamily -> "Helvetica", FontSize -> 16, 
      FontWeight -> "Plain"}], {\[Beta], 0., 100*0.0065}, 
   {\[Rho], 0, 1 - 1/\[Nu]}, SaveDefinitions -> True]
CloudDeploy[dyn, CloudObject["dynamic.nb?_view=frameless"], 
  Permissions -> {All -> {"Read", "Interact", "Evaluate"}}]
POSTED BY: Rolf Mertig

This was useful information - I am also looking for a possibility of putting interactive figures on the net so that everyone can see it without logging in to the net, and being able to manipulate as it was possible with the net-embedded cdf files before. I also want only the output to be seen as a default; but this is only for aesthetics, and I do not mind if people can open the cell containing the code and watch it. What I could not find out is how does one do if he CloudDeploy is written at the end of a notebook, which is longer than just one command, and hence the same format cannot be used as in the example above? If I only write at the end

CloudDeploy[EvaluationNotebook[], CloudObject["dynamic.nb"], 
 Permissions -> {All -> {"Read", "Interact", "Evaluate"}}]

then one must run the notebook manually first before the interactive graphics appears. I enclose the very short notebook to show what figure I want to be available on the net so that only the figure is seen, and the manipulations work immediately. I would appreciate help with putting this right.

Attachments:
POSTED BY: Imre Pazsit

One option is to create a duplicate version of the notebook that will be for other users. In that notebook, you can delete the input cell (click on the cell bracket, then delete key), leaving only the output cell.

Programmatically, you can deploy just the output cell by doing something like this:

CloudDeploy[Notebook[{Cell[ToBoxes@Manipulate[Plot[Sin[k x],{x,-Pi,Pi}],{k,1,2}],"Output"]}], CloudObject["dyn.nb"], Permissions-> {All->{"Read","Interact"}}]
POSTED BY: Jorge Manrique

One option is to create a duplicate version of the notebook that will be for other users. In that notebook, you can delete the input cell (click on the cell bracket, then delete key), leaving only the output cell.

Programmatically, you can deploy just the output cell by doing something like this:

CloudDeploy[Notebook[{Cell[ToBoxes@Manipulate[Plot[Sin[k x],{x,-Pi,Pi}],{k,1,2}],"Output"]}], CloudObject["dyn.nb"], Permissions-> {All->{"Read","Interact"}}]
POSTED BY: Chad Knutson

I did not know that I can delete the input without affecting the output.
That's the solution, thanks agai

POSTED BY: Jorge Manrique

Permissions are flexible. In my example above, I used 'All' for the list of users. This means everybody, whether they have an account or not (or are not logged in to the Wolfram Cloud). Here is an example of a deployed nb that can be viewed by everyone. They are also allowed to interact with the manipulate and evaluate the input cell [However, there appears to be a bug preventing this from working. I will investigate that further]:

CloudDeploy[
   Notebook[{Cell[ToBoxes@Manipulate[Plot[Sin[k x],{x,-Pi,Pi}],{k,1,2}],"Input"], Cell["10+10","Input"]}], 
   CloudObject["dynamic.nb"], 
   Permissions->{All->{"Read","Interact","Evaluate"}}
]

If you have already deployed the notebook, you could use SetPermissions on the CloudObject:

SetPermissions[CloudObject["dynamic.nb"],{All->{"Read","Interact","Evaluate","CellCreate"}}]

If you want a list of users to view the nb, try something like this:

SetPermissions[CloudObject["dynamic.nb"], {{"boo@foo.com", "foo@foo.com"} -> {"Read", "Interact", "Evaluate"}}]
POSTED BY: Chad Knutson

Hello Chad, now it works without entering any userid.
I still wish that the dynamic code (Manipulate, DynamicModule, etc,) can not be seen.
I hide it (only the output can be seen) but it can be opened with double click on the cell right bracket.
I can not find how to avoid it with "Permissions", can it be avoided?

POSTED BY: Jorge Manrique

Hello Chad, now it works without entering any userid.
I still wish that the dynamic code (Manipulate, DynamicModule, etc,) can not be seen.
I hide it (only the output can be seen) but it can be opened with double click on the cell right bracket.
I can not find how to avoid it with "Permissions", can it be avoided?

POSTED BY: Jorge Manrique

The 'Home' folder in the cloud interface is misleading. That folder is actually your root directory ($CloudRootDirectory). I suspect that your notebook can be found with this evaluation:

CloudObject["mynb.nb"]

You can get a list of the files in your current cloud directory (default is $CloudRootDirectory, and it can be changed with the SetCloudDirectory function) by evaluating

objs=CloudObjects[];
CloudObjectInformation /@ objs
POSTED BY: Chad Knutson

Thanks Chad, now it works.
Another question: can my nb file only be seen and / or executed by another cloud user?
I ask because when I use the URL requires entering userid and password
What I want is to make it public to anyone who has the URL, is it possible?

POSTED BY: Jorge Manrique

You can edit the deployed notebook because you are its owner. The Wolfram Cloud has a number of settings that determine the allowed interactions of other users. See the Permissions documentation page for more details. Here, I just note a few of them: "Evaluate" would enable a user to do a shift-enter evaluation of a cell. "Interact" allows a user to change dynamic settings.

To update the permissions for your notebook, you evaluate something like this (either in a cloud notebook or a desktop Mathematica notebook):

SetPermissions[CloudObject[- your cloud object name or url-], {All->{"Evaluate", "Interact"}}]

Wolfram Language also has PermissionsGroups for a group of users, or you could have a list of usernames (instead of 'All') that would have these permissions.

POSTED BY: Chad Knutson

Hi Chad, thanks for your help.
I did the following:

In[10]:= CloudObject["/home/mynb.nb"]  
Out[10]= CloudObject["https://www.wolframcloud.com/objects/user-9c1598c7-xxxx-yyyy-bf3f-82b79605c5fc/home/mynb.nb"]  
In[11]:= CloudObjectInformation[%]  
Out[11]= $Failed  

I do not know what I'm doing wrong.

POSTED BY: Jorge Manrique
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract