3
$\begingroup$

I am really trying to get my head around Cloud Deployment and Programming cloud, and the more I use it, the more I think it is a fantastic product. At least in principle. I successfully deployed a range of Manipulate 'applications' to the cloud and they work neatly. Now I wanted to do something more challenging and produces a little larger code (40 kb Mathematica nb). I tested the principle elements in a cloud deploy and it works. However, the more complex program doesn't work. I tried a tedious amount of possibilities – it doesn't work. This is especially frustrating, as there is no feedback at all what the problem is. I just get a white webpage with nothing on it. I can get it to work when compacting the program, but obviously that doesn't help in the long run. It's not a complicated program and on Mathematica it works without any delays. I've no idea why it won't deploy to cloud, i.e. it seems to deploy, but the webpage remains blank, no matter how long I wait. Any help much appreciated!

OK, below is the code. I'm a user, not a programmer, so apologies for any too complicated stuff. The code usually executes within the programming cloud environment. But it doesn't update when I change something in the Manipulate output shell. On the website, the Manipulate output shell never appears. As said above, it works with less complex programs that are basically similar to the one below.

(*---- Befehlsdefinition>extractData ----*)

extractData[exal_, name_, opt_: 0] :=
    Switch[opt
      , 0, Rest@exal[[Position[exal, name][[1, 1]]]]
      , 1, Rest@exal[[All, Position[exal[[1]], name][[1, 1]]]]
      ];
(*---- Befehlsdefinition>extractData ----*)


    (*---- Directory,Import,etc. ----*)
  data = CloudGet["Complementarity/chdmtxdata"];
cCData = CloudGet["Complementarity/ccdata"];
    (*---- Directory,Import,etc. ----*)


(*---- Some required data extractions etc. Start ----*)

cIData = cCData[[1 ;; 2]];
metGroups = DeleteDuplicates@extractData[data, "Group", 1];
elmentList = {"H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", 
   "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", 
   "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", 
   "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", 
   "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", 
   "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", 
   "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", 
   "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", 
   "Ra", "Ac", "Th", "Pa", "U"};
headerRow = data[[1]];
components = extractData[data, "Component Type", 1];
availableComponents = DeleteDuplicates@components;
group = extractData[data, "Group", 1];
(*---- Some required data extractions etc. End ----*)


(*---- Formats Start ----*)

stdStyle[txt_] := 
 Style[txt, Darker@Gray, 14, FontFamily -> "Helvetica"]

stdFrame[obj_] := Framed[obj
  , Background -> GrayLevel[.95]
  , FrameStyle -> GrayLevel[.95]
  , RoundingRadius -> 5]
(*---- Formats End ----*)



screenoutput[chondriteGroup_, component1_, component2_, yaxisElement_,
   xaxisElement_] := Module[{},
  (*---- CC Data Start----*)

  xCI = extractData[cIData, xaxisElement, 1];
  yCI = extractData[cIData, yaxisElement, 1];
  cILine = Plot[yCI/xCI x, {x, 0, 30}
    , PlotStyle -> {Dashed, Darker@Gray}
    ];

  xCC = extractData[cCData, chondriteGroup][[
    Position[cCData[[1]], xaxisElement][[1, 1]] - 1]];
  yCC = extractData[cCData, chondriteGroup][[
    Position[cCData[[1]], yaxisElement][[1, 1]] - 1]];
  (*---- CC Data End----*)


  (*---- Result List Start----*)

  yElement = extractData[data, yaxisElement, 1];
  xElement = extractData[data, xaxisElement, 1];
  ref = extractData[data, "Reference", 1];
  doi = extractData[data, "doi", 1];
  metName = extractData[data, "Meteorite Name", 1];

  resultListComp1 = 
   DeleteCases[
    If[components[[#]] == component1 && group[[#]] == chondriteGroup &&
         NumberQ@xElement[[#]] && 
        NumberQ@yElement[[#]], {xElement[[#]], yElement[[#]], 
        ref[[#]], doi[[#]], metName[[#]]}] & /@ 
     Range[Length[data] - 1], Null];
  resultListComp2 = 
   DeleteCases[
    If[components[[#]] == component2 && group[[#]] == chondriteGroup &&
         NumberQ@xElement[[#]] && 
        NumberQ@yElement[[#]], {xElement[[#]], yElement[[#]], 
        ref[[#]], doi[[#]], metName[[#]]}] & /@ 
     Range[Length[data] - 1], Null];
  (*---- Result List End----*)


  (*---- Plot Data Start----*)

  comp1LPData1 = resultListComp1[[All, 1]];
  comp1LPData2 = resultListComp1[[All, 2]];
  comp2LPData1 = resultListComp2[[All, 1]];
  comp2LPData2 = resultListComp2[[All, 2]];
  (*---- Plot Data End----*)


  (*---- ListPlot Start----*)

  dataPlot = 
   ListPlot[{Transpose[{comp1LPData1, 
       comp1LPData2}], {{Mean@comp1LPData1, Mean@comp1LPData2}}, 
     Transpose[{comp2LPData1, comp2LPData2}], {{Mean@comp2LPData1, 
       Mean@comp2LPData2}}, {{xCC/10^4, yCC/10^4}}, {{xCI[[1]]/10^4, 
       yCI[[1]]/10^4}}}
    , Frame -> True
    , FrameLabel -> {Row[{xaxisElement <> " (wt.%)"}], 
      Row[{yaxisElement <> " (wt.%)"}]}
    , FrameStyle -> 
     Directive[14, Darker@Gray, FontFamily -> "Helvetica"]
    , PlotMarkers -> {"\[FilledCircle]", {"\[CircleTimes]", 20}, 
      "\[Bullet]", {"\[CirclePlus]", 20}, {"\[FivePointedStar]", 
       20}, {"\[FivePointedStar]", 20}}
    , PlotStyle -> {Darker@Green, Red, Blue, Red, Orange, Gray}
    , PlotRange -> {{0, Automatic}, {0, Automatic}}
    , ImageSize -> 500
    ];
  (*---- ListPlot End----*)


  (*---- Histogram Start----*)
  histograms = Row[{
     Histogram[{comp1LPData1, comp2LPData1}
      , Frame -> True
      , FrameStyle -> 
       Directive[14, Darker@Gray, FontFamily -> "Helvetica"]
      , FrameLabel -> {Row[{xaxisElement <> " (wt.%)"}], "Frequency"}
      , ChartStyle -> {Darker@Green, Blue}
      , ImageSize -> 350
      ]
     , Spacer@50
     , Histogram[{comp1LPData2, comp2LPData2}
      , Frame -> True
      , FrameStyle -> 
       Directive[14, Darker@Gray, FontFamily -> "Helvetica"]
      , FrameLabel -> {Row[{yaxisElement <> " (wt.%)"}], "Frequency"}
      , ChartStyle -> {Darker@Green, Blue}
      , ImageSize -> 350
      ]
     }]
  ;
  (*---- Histogram End----*)


  (*---- Info Sheet Start ----*)
  infoSheet = stdFrame@stdStyle@Grid[{
       {"Number of " <> component1 <> ": ", Length@resultListComp1}
       , {"Number of " <> component2 <> ": ", Length@resultListComp2}
       , {Spacer[{0, 1}]}
       , {Style["Included Meteorites", Bold]}
       , {Style[
         Grid[{{Column[
             Prepend[DeleteDuplicates@resultListComp1[[All, 5]], 
              Style[component1, Bold]]], Spacer@3, 
            Column[Prepend[DeleteDuplicates@resultListComp2[[All, 5]],
               Style[component2, Bold]]]}}, Alignment -> Top], Blue]}
       }, Alignment -> Left];
  (*---- Info Sheet End ----*)


  (*---- Reference Sheet Start ----*)

  refDOIListComp1 = 
   DeleteDuplicates@
    Transpose[{resultListComp1[[All, 3]], 
      resultListComp1[[All, 4]]}];
  finalRefComp1 = 
   If[refDOIListComp1[[#, 2]] == "", refDOIListComp1[[#, 1]], 
      Hyperlink[refDOIListComp1[[#, 1]], 
       "http://dx.doi.org/" <> refDOIListComp1[[#, 2]]]] & /@ 
    Range@Length@refDOIListComp1;
  refDOIListComp2 = 
   DeleteDuplicates@
    Transpose[{resultListComp2[[All, 3]], 
      resultListComp2[[All, 4]]}];
  finalRefComp2 = 
   If[refDOIListComp2[[#, 2]] == "", refDOIListComp2[[#, 1]], 
      Hyperlink[refDOIListComp2[[#, 1]], 
       "http://dx.doi.org/" <> refDOIListComp2[[#, 2]]]] & /@ 
    Range@Length@refDOIListComp2;

  infoRef = stdFrame@stdStyle@Grid[{
       {Style["Data From", Bold]}
       , {Spacer[{0, 5}]}
       , {Grid[{{Column[
            Prepend[finalRefComp1, Style["Chondrules", Bold]]], 
           Spacer@3, 
           Column[Prepend[finalRefComp2, Style["Matrix", Bold]]]}}, 
         Alignment -> Top]}
       }];
  (*---- Reference Sheet End ----*)


  (*---- Screen Output Start ----*)
  Grid[{
    {Show[dataPlot, cILine], Spacer@10, infoSheet}
    , {Spacer[{0, 15}]}
    , {histograms, SpanFromLeft}
    , {Spacer[{0, 15}]}
    , {infoRef, SpanFromLeft}
    }, Alignment -> Top]
  (*---- Reference Sheet End ----*)
  ]


(*----------------------------*)
(*-------- Manipulate --------*)
(*----------------------------*)
Manipulate[
 screenoutput[chondriteGroup, component1, component2, yaxisElement, 
  xaxisElement]

 , {{chondriteGroup, "CV", "Group"}, metGroups, 
  ControlType -> PopupMenu}
 , {{component1, "Chondrule", "Component 1"}, availableComponents, 
  ControlType -> PopupMenu}
 , {{component2, "Matrix", "Component 2"}, availableComponents, 
  ControlType -> PopupMenu}
 , Delimiter
 , {{yaxisElement, "Mg", "y-axis"}, elmentList, 
  ControlType -> PopupMenu}
 , {{xaxisElement, "Si", "x-axis"}, elmentList, 
  ControlType -> PopupMenu}

 , ControlPlacement -> Left
 , Deployed -> True
 , SaveDefinitions -> True
 ]
$\endgroup$
  • 2
    $\begingroup$ Link us to your code? $\endgroup$ – mfvonh Sep 3 '14 at 8:05
  • $\begingroup$ I'm not sure how to link to the code. Otherwise I'm happy to. $\endgroup$ – Mockup Dungeon Sep 4 '14 at 13:42
  • $\begingroup$ OK, just added the full code – as the deployment only doesn't work with the full code. $\endgroup$ – Mockup Dungeon Sep 4 '14 at 14:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.