【问题标题】:openCPU and rstan - cannot open the connectionopenCPU 和 rstan - 无法打开连接
【发布时间】:2016-11-10 15:55:16
【问题描述】:

我正在使用 openCPU 创建一个 API 来估计 rstan 中非常基本的模型。

我已经验证,当从普通 R 控制台会话调用时,我的函数在我的环境中工作,而不是从 openCPU 调用。

但是通过openCPU调用时,响应如下:

cannot open the connection

In call:
file(con, "r")

通过在 rstan 的源代码中插入检查点,我将其追溯到 R/cxxfunplus.R (link to line on github here) 中的一个调用:

dso <- new('cxxdso', sig = sig, dso_saved = save_dso, 
             dso_filename = dso_filename, 
             modulename = module_name, 
             system = R.version$system, 
             cxxflags = get_makefile_flags("CXXFLAGS"), 
             .CXXDSOMISC = new.env(parent = emptyenv()))

此调用中的什么试图读取可能失败的连接?

【问题讨论】:

    标签: r opencpu stan rstan


    【解决方案1】:

    想通了——rstan::get_makefile_txt 正在寻找的两个 makefile 之一在 openCPU 下运行时不存在。该文件是/usr/share/R/share/make。

    幸运的是,第一个 makefile 确实存在并且足够了,因此可以通过跳过第二个 makefile 并仅读取第一个来纠正此问题。

    rstan::get_makefile_text的最后一行之前,我插入了以下内容:

    makefiles <- makefiles[file.exists(makefiles)]
    

    【讨论】:

    • 感谢您告知我们。你可以添加到你的答案中,无论你叫什么只读取第一个 makefile?
    • 好的。我将该行添加到 GitHub 上 rstan 的开发分支。
    猜你喜欢
    • 1970-01-01
    • 2011-09-18
    • 2015-09-11
    • 2015-09-03
    • 2010-12-01
    • 2014-05-08
    • 2012-10-12
    • 2013-03-10
    相关资源
    最近更新 更多