Report with R metric is running without an end in the web

Sep 24, 2013 at 5:29 AM
Hi,

I have developed a Report which has a metric that uses a Rscript in it. It is running properly in the Server machine's desktop(Intially we had a problem and it got resolved with your instructions).

But when I run it in the web, it runs without any completion. It is keep on executing without any completion. It is not even timing out. Whereas it runs properly in the desktop and it is also very fast in desktop. I also tried by updating the cache in the report. Eventhen it is not completing its execution in web.

Also for your information, the report executes(in web) properly when I remove the R metric from the report. But the problem occurs only when I add the metric with RScript.
Coordinator
Sep 24, 2013 at 5:56 AM
One explanation would be that the web server doesn't have R installed (see pages 3 and 4 of the User Guide), or that the web server is missing a package required by the script (which is a known bug we'll be fixing in the next release*).

Can you confirm that the server you tested using Desktop is the same server you tested using Web?

Please keep in mind that, if you deployed your R analytic using Desktop as a derived metric (via Insert New Metric within the context of a report), the derived metric is executed on the Desktop client, not the server.

Thanks,

Rick
  • = the work around is to install any required packages on the server manually using the R Console on that machine, or by specifying a CRAN mirror by adding this line with the desired CRAN Mirror URL (e.g., http://cran.us.r-project.org ) to the RProfile file at <R installation folder>/library/base/R on that machine:
options(repos = c(CRAN="<<CRAN Mirror URL>>"))
Sep 24, 2013 at 10:28 AM
Yes, I am using the same server to run the report for both desktop and web.

when you say "the web server doesn't have R installed (see pages 3 and 4 of the User Guide), or that the web server is missing a package required by the script" Did you mean that I have missed to install a package that is required by the script to make it run in the web server or Is it missing by default in the current version"

Kindly clarify on the above so that will be easy for us to take a decision.
Coordinator
Sep 24, 2013 at 5:40 PM
Yes, that's exactly what I mean. For example, in the SeasonalForecasting.R script, it has a dependency on the pmml package, which is not part of the standard R install. In that sample script, there's this code segment:
    if(is.na(match("pmml", installed.packages()))) {       #package installed?
      install.packages("pmml")                             #  install package
    }
    library(pmml)                                          #Load pmml package       
If the the pmml package is not installed, the script tries to load it with install.packages. The bug is that, if you don't have a default CRAN Mirror specified, R will popup a window on the machine prompting you to select a CRAN Mirror. Unfortunately, since that window pops up on the server and not your client, I suspect your script is hung waiting for a CRAN Mirror to be selected since there's no one to notice/respond the pop-up window on the server. The fix to this bug is a change to the script replacing the install.packages code with this one:
    install.packages(“pmml”, repos="http://cran.us.r-project.org"))
Bottom-line: Please make sure that you have either 1) manually install any package dependencies on the machine, 2) specify a default CRAN Mirror in the RProfile file (see above), or 3) specifiy the CRAN Mirror using the repos attribute of the install.packages command in your script.

Good luck! Looking forward to hearing back from you,

Rick
Coordinator
Sep 24, 2013 at 6:31 PM
A couple more things:
  • When you ran successfully using Desktop, were you running 2-tier (direct) or 3-tier (server) and was the R analytic deployed as a derived metric in a report or as a first class metric in metadata?
  • To implement the fix I describe above, you'll need to restart the Intelligence Server where the R analytic was running (in this case, I believe that's your server) to ensure any side effects of the hung process are eliminated.
Sep 25, 2013 at 10:22 AM
Edited Sep 25, 2013 at 12:04 PM
Is PMML package mandatorily required to be installed in server machine(Machine where R & MSTR Installed) to make it run in the web ?
Please kindly confirm it, because We have installed all the other required packages other than PMML in our machine. We have also omitted the PMML clause in our script.


Also for your information,
** We are running the report in the desktop in 3-tier(Server) and the R analytic is deployed as a derived metric in the report. Whenever the Report hangs we are restarting the I server to remove the hanged job in the backend
Coordinator
Sep 26, 2013 at 4:43 AM
Hi Vinod,

I'm sorry you're still having troubles. If you're asking if the R Integration Pack requires the pmml package, the answer is no. I just used the SeasonalForecasting.R script we include as an example to illustrate the problem we found with the automatic installation of packages from a script when there is no CRAN Mirror specified.

Let's review Page 3 & 4. which I'll paste here:

R and any dependencies must be installed on systems that will execute the R analytics deployed to MicroStrategy. This includes:
  • MicroStrategy Intelligence Server. [NOTE: THIS IS WHERE THINGS EXECUTE FOR WEB, DESKTOP 3-TIER, OFFICE, MOBILE... everything except what's in the next bullet]
  • MicroStrategy Desktop clients that execute R analytics in direct (two-tier) mode or as derived metrics.
R is not required on other clients such as MicroStrategy Web, MicroStrategy Mobile, MicroStrategy Visual Insight, and MicroStrategy Office since they are consumers of analytics deployed to the MicroStrategy Intelligence Server.
  • If an R analytic has dependencies on add-on packages that are not included standard with R, those packages must also be added to the R installation on the MicroStrategy systems listed above.
So, if the script depends on the pmml package, the pmml package has to be installed where R executes. That's always your I-Server if it's going to be used to deploy your R analytics, and Desktop if you want to connect 2-tier or using derived metrics (which get calculated on the Desktop client and not the I-Server).

But, if you removed the dependency on the pmml package from your script, then this is all moot. Assuming you don't have other missing required packages, then is your problem fixed or do we need to keep looking?

What's your status now?

Thanks again,

Thanks,

Rick
Sep 26, 2013 at 6:26 AM
Edited Sep 26, 2013 at 6:27 AM
Hi

Thanks for your support.

Yes, still we are facing the issue.
We are not able to figure out the reason why it hangs in the web.

Not sure why it is hanging in the web when it is running in the desktop.
Coordinator
Oct 6, 2013 at 11:56 PM
After feedback from Vinod that his problem has been solved, I'll summarize here for future users:

The SeasonalForecasting.R script includes code that tries to automatically install the a missing package. In that sample script, there's this code segment:
    if(is.na(match("pmml", installed.packages()))) {       #package installed?
      install.packages("pmml")                             #  install package
    }
    library(pmml)                                          #Load pmml package       
If the the pmml package is not installed, the script tries to load it with install.packages. The problem happens when there is no default CRAN mirror. R will popup a window prompting for a CRAN mirror to be selected, on the machine where the R script is running. When reports are run using MicroStrategy Web, that machine is the MicroStrategy Intelligence Server and not the Web client. And since there's usually no one to notice/respond the pop-up window on the server, the report execution appears to hang. We will be fixing this problem in the next release of the RScript functions, expected later this month (October 2013).

To work around this problem, make the following change which uses the repos argument to specify the CRAN mirror to use:
    if(is.na(match("pmml", installed.packages()))) {       #package installed?
      install.packages("pmml", repos="http://cran.rstudio.com"))  #  install package
    }
    library(pmml)                                          #Load pmml package       
We recommend using the RStudio mirror because it automatically re-directs (for details, see http://blog.rstudio.org/2013/06/10/rstudio-cran-mirror).

Other workarounds include:

1) Use the R Console to manually install any package dependencies on the Intelligence Server machine (or Desktop Client for derived metrics in 3-tier or if you're running 2-tier),
2) Specify a default CRAN mirror in the .RProfile file on that machine using this code "options(repos = c(CRAN = "http://cran.rstudio.com"))" , or
3) if you're not interested in the PMML, simply comment out or remove the code associated with it from the script.

Finally, be sure to restart your Intelligence Server to eliminate all sides effects of the hang.

Thanks,

Rick