微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Databricks 上的 STAN - AttributeError: 'ConsoleBuffer' 对象没有属性 'closed'

如何解决Databricks 上的 STAN - AttributeError: 'ConsoleBuffer' 对象没有属性 'closed'

在 Databricks 8.2 ML 上运行 STAN (pystan) 会引发以下错误

要重现,只需运行 https://pystan.readthedocs.io/en/latest/

中的简单示例

似乎 ConsoleBuffer 类没有关闭的实现?有其他人遇到过这个问题吗?有什么解决方法推荐吗?我目前使用的是单节点集群,理想情况下不想在本地机器上运行它。

堆栈跟踪

AttributeError                            Traceback (most recent call last)
<command-261559943577864> in <module>
      3                 "sigma": [15,10,16,11,9,18]}
      4 
----> 5 posterior = stan.build(schools_code,data=schools_data)
      6 fit = posterior.sample(num_chains=4,num_samples=1000)
      7 eta = fit["eta"]  # array with shape (8,4000)

/databricks/python/lib/python3.8/site-packages/stan/model.py in build(program_code,data,random_seed)
    468 
    469     try:
--> 470         return asyncio.run(go())
    471     except KeyboardInterrupt:
    472         return  # type: ignore

/databricks/python/lib/python3.8/asyncio/runners.py in run(main,debug)
     41         events.set_event_loop(loop)
     42         loop.set_debug(debug)
---> 43         return loop.run_until_complete(main)
     44     finally:
     45         try:

/databricks/python/lib/python3.8/asyncio/base_events.py in run_until_complete(self,future)
    614             raise RuntimeError('Event loop stopped before Future completed.')
    615 
--> 616         return future.result()
    617 
    618     def stop(self):

/databricks/python/lib/python3.8/site-packages/stan/model.py in go()
    438     async def go():
    439         io = ConsoleIO()
--> 440         io.error("<info>Building...</info>")
    441         async with stan.common.HttpstanClient() as client:
    442             # Check to see if model is in cache.

/databricks/python/lib/python3.8/site-packages/clikit/api/io/io.py in error(self,string,flags)
     84         The string is formatted before it is written to the output.
     85         """
---> 86         self._error_output.write(string,flags=flags)
     87 
     88     def error_line(self,flags=None):  # type: (str,Optional[int]) -> None

/databricks/python/lib/python3.8/site-packages/clikit/api/io/output.py in write(self,flags,new_line)
     59                 formatted += "\n"
     60 
---> 61             self._stream.write(to_str(formatted))
     62 
     63     def write_line(self,Optional[int]) -> None

/databricks/python/lib/python3.8/site-packages/clikit/io/output_stream/stream_output_stream.py in write(self,string)
     19         Writes a string to the stream.
     20         """
---> 21         if self.is_closed():
     22             raise io.UnsupportedOperation("Cannot write to a closed input.")
     23 

/databricks/python/lib/python3.8/site-packages/clikit/io/output_stream/stream_output_stream.py in is_closed(self)
    114         Returns whether the stream is closed.
    115         """
--> 116         return self._stream.closed

AttributeError: 'ConsoleBuffer' object has no attribute 'closed'

解决方法

在尝试了一些旧集群之后,我意识到 pystan 3 是完全重写的。所以一种解决方法是回到 pystan==2.19.1.1

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?