Group Abstract Group Abstract

Message Boards Message Boards

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

Posted 11 years ago

I have a Manipulate[] with some initialization code (3 funcs) and 3 sliders. I have bundled all that inside a DynamicModule[] (defined as a function). So far so good, everything runs smoothly!

The problem is that I cannot deploy it to the cloud (tried different variations of CloudDeploy[]) without breaking the interface.

The funny thing is that I upload the cdf version of my code (generate it with CDFDeploy[]) to the cloud manually and it works like a charm-the problem in this case is that it is not publicly accessible and I cannot find a way to change its permissions.

Is there anyone out there with any hint on what to do? How can I make CloudDeploy[] work with DynamicModule[Manipulate[]] or how can I change the permissions of an uploaded cdf to the cloud?

Any help is HUGELY appreciated!

POSTED BY: nik tsak
10 Replies

The first thing to note is that it you don't have to include your function definitions using the Initialization option. When you CloudDeploy, any dependencies will be worked out (effectively like SaveDefinitions -> True) and saved as part of the cloud object. It is one of the nicer features of CloudDeploy that you don't have to worry about sorting out all the dependencies. That said, doing so won't fix the problem with your Manipulate. I suspect as originally written that the symbols getting created with the ToExpression call are not ending up in the same context as the symbols you are comparing to in func3 and thus preventing them from matching when compared with ===. When I tried to deploy your code as originally written, everything came out gray which seems to confirm that. The alternative code posted by Rolf Mertig above fixes this problem by using strings rather than symbols which is why his code does work. While not knowing what your full application is trying to do, I would suggest that the work done with func3 may be done more idiomatically with rules and Replace or ReplaceAll.

POSTED BY: Andrew de Laix
Posted 11 years ago
POSTED BY: nik tsak
POSTED BY: Rolf Mertig
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

I understand what you are saying.

I highly doubt ToExpression is breaking the code, although I cannot be 100% sure it isn't.

Nevertheless I'm tired of wasting my time on something like that. It took me two days to put the whole thing together with the sole purpose of making it available on the cloud only to find out that I can't.

Anyway,

Thank you Nasser for your input. :)

POSTED BY: nik tsak
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
Posted 11 years ago
POSTED BY: nik tsak

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
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard