Function Repository Resource:

CloudNotebookEvaluate

Source Notebook

Evaluate a notebook from the cloud

Contributed by: Bob Sandheinrich

ResourceFunction["CloudNotebookEvaluate"][co]

evaluates the inputs in the cloud-deployed notebook co.

Details and Options

The cloud object co can be a CloudObject, URL or URL string.
ResourceFunction["CloudNotebookEvaluate"] supports the option InsertResults with a default value of False. Setting it to True will store the generated results in the original cloud notebook.

Examples

Basic Examples (4) 

Deploy a notebook with definitions in input cells:

In[1]:=
nbo = CreateDocument[{ExpressionCell[Defer[f[x_] := x^3], "Input"],
    ExpressionCell[Defer[g[x_] := x^3 - x], "Input"],
    ExpressionCell[Defer[RandomReal[100, 100]], "Input"]}];
CloudDeploy[nbo, "SimpleDefinitions.nb", Permissions -> "Public"]
Out[2]=

Evaluate the definitions from that notebook:

In[3]:=
Clear[f, g];
NotebookClose[nbo]
In[4]:=
result = ResourceFunction[
  "CloudNotebookEvaluate", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][CloudObject["SimpleDefinitions.nb"]]
Out[4]=

The definitions exist:

In[5]:=
f[10]
Out[5]=
In[6]:=
g[5]
Out[6]=

See the result of the evaluation:

In[7]:=
result["Output"]
Out[7]=

Scope (1) 

Specify the notebook using the URL directly:

In[8]:=
ResourceFunction[
 "CloudNotebookEvaluate", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"]["https://www.wolframcloud.com/obj/bobs/SimpleDefinitions.nb"]
Out[8]=

Options (3) 

InsertResults (3) 

Deploy a notebook with definitions in input cells:

In[9]:=
nbo = CreateDocument[{ExpressionCell[Defer[f[x_] := x^3], "Input"],
    ExpressionCell[Defer[g[x_] := x^3 - x], "Input"],
    ExpressionCell[Defer[RandomReal[100, 100]], "Input"]}];
cobj = CloudDeploy[nbo, "SimpleDefinitions-WithOutputs.nb", Permissions -> "Public"]
Out[10]=

Evaluate the definitions from that notebook and store the results using InsertResults:

In[11]:=
Clear[f, g];
NotebookClose[nbo]
In[12]:=
result = ResourceFunction[
  "CloudNotebookEvaluate", ResourceSystemBase -> "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"][cobj, InsertResults -> True]
Out[12]=

The outputs are stored in the cloud notebook:

In[13]:=
SystemOpen[cobj]

Version History

  • 1.1.0 – 29 March 2023
  • 1.0.0 – 20 September 2022

Related Resources

Author Notes

1.1.0: added support for InsertResults. Perhaps someday NotebookEvaluate will accept CloudObject inputs and this function will be obsolete.

License Information