如何从 PySpark 上下文中提取应用程序 ID [英] How to extract application ID from the PySpark context
本文介绍了如何从 PySpark 上下文中提取应用程序 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
A 上一个问题推荐sc.applicationId
,但不是 存在于 PySpark
中,仅存在于 scala
中.
那么,如何确定 PySpark 进程的应用程序 ID(用于 yarn
)?
解决方案
您可以通过 Py4J RPC 网关使用 Java SparkContext 对象:
<预><代码>>>>sc._jsc.sc().applicationId()u'application_1433865536131_34483'请注意,sc._jsc
是内部变量,而不是公共 API 的一部分 - 所以它有(相当小的)可能在未来被改变.
我将提交拉取请求以为此添加公共 API 调用.
A previous question recommends sc.applicationId
, but it is not present in PySpark
, only in scala
.
So, how do I figure out the application id (for yarn
) of my PySpark process?
解决方案
You could use Java SparkContext object through the Py4J RPC gateway:
>>> sc._jsc.sc().applicationId()
u'application_1433865536131_34483'
Please note that sc._jsc
is internal variable and not the part of public API - so there is (rather small) chance that it may be changed in the future.
I'll submit pull request to add public API call for this.
这篇关于如何从 PySpark 上下文中提取应用程序 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文