Group Abstract Group Abstract

Message Boards Message Boards

Why is CloudDeploy[] having trouble to work with Manipulate[] ?

Posted 11 years ago
POSTED BY: nik tsak
10 Replies
POSTED BY: Andrew de Laix
POSTED BY: Rolf Mertig
Posted 11 years ago
POSTED BY: nik tsak

Both the CDF and the notebook versions of the code run smoothly. It all goes south when it gets deployed on the cloud!

As I mentioned above, there could be some commands you are using that are not supported in the Cloud. Just as there are some commands not supported/allowed to be used in a demo. In the link I gave above, I was trying to make a list of what works and what does not work in the Cloud. I think such a list should be made by WRI. May be there is one, I never seen it. For example, you are using ToExpression, which I know not supported for a demo, (due to it not being safe). May be that is the problem. Try to recode the program without the need to use ToExpression and see if that works. Or better, make a small CDF that uses ToExpression in some way just to see if it deploys and runs Ok on the Cloud. If it does not, then you know it is this command that is causing the problem.

POSTED BY: Nasser M. Abbasi
Posted 11 years ago

The following is a toy version of my actual code. Both the CDF and the notebook versions of the code run smoothly. It all goes south when it gets deployed on the cloud!

wrapper = Manipulate[

   main[s1, s2, s3],

   {{s1, 95, "Slider 1"}, 1, 99, 1},
   {{s2, 5, "Slider 2"}, 1, 99, 1},
   {{s3, 50, "Slider 3"}, 1, 99, 1},

   ControlType -> Slider,

   Initialization :> (

     func1[s1Val_: 0.95, s2Val_: 0.05] := Module[{},

       RandomReal[{0, 1}, 2]

       ];

     func2[s3Val_, s1Val_: 0.95, s2Val_: 0.05] := Module[{},

       {

        {
         {"Res1", 10^6 RandomReal[]},

         {"Res2", 10^6 RandomReal[]},

         {"Res3", 10^6 RandomReal[]},

         {"Res4", 10^6 RandomReal[]}

         },

        Table[{ToExpression[StringJoin["Res5", ToString[i]]], 
          RandomReal[]}, {i, 1, 10}],

        Table[{ToExpression[StringJoin["Res6", ToString[i]]], 
          RandomReal[]}, {i, 1, 5}],

        Table[{ToExpression[StringJoin["Res7", ToString[i]]], 
          10^6 RandomReal[]}, {i, 1, 5}]

        }

       ];

     func3[x_] := Which[

       x === Res71, RGBColor[{0., 0.4918, 0.7778}],

       x === Res72, RGBColor[{1., 0.1799, 0.1111}],

       x === Res73, RGBColor[{1., 0.2222, 0.2523}],

       x === Res74, RGBColor[{0.3011, 0.6667, 0.}],

       True, Gray

       ];

     main[s1Val_, s2Val_, s3Val_] := 
      Module[{list1, val1, array1, grid1, grid2, tmp, chart},

       list1 = func1[s1Val, s2Val];

       val1 = Rescale[s3Val, {0, 1}, list1];

       array1 = func2[val1, s1Val, s2Val];


       grid1 = 
        Grid[Prepend[
          Reverse /@ 
           MapAt[N[10^-3 Round[10^3 #/10^3]] &, 
            array1[[1]], {All, 2}], {Style[
            "some \!\(\*SuperscriptBox[\(text\), \(2\)]\)", Bold, 
            Smaller], Null}], Alignment -> Right];

       grid2 = 
        Grid[Prepend[
          array1[[4]], {Null, Style["some text", Bold, Underlined]}], 
         Alignment -> Right];


       tmp = (array1[[4]] // Reverse // Transpose);

       chart = 
        PieChart3D[tmp[[2]], ChartLabels -> tmp[[1]], 
         ChartStyle -> (func3 /@ tmp[[1]]), ImageSize -> Medium, 
         PlotLabel -> Style["some text", Larger, Bold], 
         SectorOrigin -> {Automatic, 1}];


       Column[{chart, 
         Grid[{{grid2, grid1}}, Dividers -> {{False, True}, False}], 
         Framed[Style["some text", 11, Bold, Darker[Blue]]]}, Center]

       ];

     ),

   SaveDefinitions -> True,

   SynchronousInitialization -> False,

   Deployed -> True

   ];

CDFDeploy[

 ToFileName[NotebookDirectory[], "test.cdf"],

 wrapper,

 WindowSize -> {1100, 1000},

 Method -> "Standalone",

 Target -> "CDFPlayer",

 Deployed -> True

 ]



CloudDeploy[

 ExportForm[wrapper, "CloudCDF"],

 Permissions -> "Public"

 ]
POSTED BY: nik tsak
POSTED BY: Nasser M. Abbasi

How can I make CloudDeploy[] work with DynamicModule[Manipulate[]]

Is there any specific reason to put Manipulate inside a DynamicModule, given that Manipulate is already a DynamicModule? What exactly the purpose of doing so? Have you tried just with Manipulate itself?

POSTED BY: Nasser M. Abbasi
Posted 11 years ago

Thank you for taking the time to work through the code

What is wrong with the sliders on the cloud?

POSTED BY: nik tsak
Posted 11 years ago

Thank you very much for your response!

I really appreciate the explanation.

I haven't run it yet, but what you're saying makes some sense.

Using strings instead of symbols is not a practical solution for me in this instance because of the way the actual code is written-I would have to re-write the whole thing from scratch! I'm not sure right now how Replace might have worked out in the actual code but it has intuitive appeal.

But it really doesn't matter. The window of opportunity for that piece of code is gone.

Now I will know next time not to mix symbols and strings like that.

That was really informative :)

POSTED BY: nik tsak
Posted 11 years ago

I chose to enclose Manipulate[] in a DynamicModule[] because I had to hide away some intermediate definitions that are essential to the computation

I have tried losing DynamicModule[] and nothing changed

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