I don't seem to understand CloudDeploy
; it seems like it deploys a function, but not its dependent expressions. How should I deploy an expression that may have dependencies previously in the notebook?
For example, I evaluated the following expression:
f=Sin[x];CloudDeploy[Manipulate[Plot[f,{x,0,t}],{t,1,15}]]
I then visited the deployed page, and got a plot with no function.
This is a simplified version; in more complex ones, such as when PlotRange
depends on something previously defined, I can see error messages.
It seems that CloudDeploy
's deployed object definition isn't closed over the set of definitions in effect. However, the docs (at ref/CloudDeploy.html) specify that:
CloudDeploy[expr,…]
automatically deploys all definitions needed to evaluate expr, much likeCloudSave
.
Am I misunderstanding something here?
Answer
The quick fix is to use Manipulate's
SaveDefinitions
, making it responsible for storing dependencies:
f = Sin[x];
CloudDeploy[
Manipulate[Plot[f, {x, 0, t}], {t, 1, 15}, SaveDefinitions -> True]
]
I don't know if that is expected, maybe Documentation sticks to the wording precisely here. So it happens because f
is not needed to evaluate Manipulate
(it is needed to display it):
InputForm @ Manipulate[Plot[f, {x, 0, t}], {t, 1, 15}]
in contrary to e.g. InputForm @ Grid[f]
.
On the other hand it does not make much sense since CloudDeploy
does not Hold its arguments which means expr
is evaluated before sending, which means no additional definition will ever be needed if we stick to the wording...
So maybe it is worth reporting?
Compare also:
CloudDeploy[Delayed[f]]
CloudDeploy[Dynamic[f]]
Comments
Post a Comment