我需要使用這個參數,所以我怎樣才能得到工人的數量? 與Scala一樣,我可以撥打sc.getExecutorMemoryStatus
以獲得可用的工作人員數量。但在PySpark中,似乎沒有暴露的API來獲取這個數字。如何獲取PySpark中工作者(執行者)的數量?
回答
在scala中,getExecutorStorageStatus
和getExecutorMemoryStatus
都返回包括驅動程序在內的執行程序的數量。 像例如以下代碼段
/** Method that just returns the current active/registered executors
* excluding the driver.
* @param sc The spark context to retrieve registered executors.
* @return a list of executors each in the form of host:port.
*/
def currentActiveExecutors(sc: SparkContext): Seq[String] = {
val allExecutors = sc.getExecutorMemoryStatus.map(_._1)
val driverHost: String = sc.getConf.get("spark.driver.host")
allExecutors.filter(! _.split(":")(0).equals(driverHost)).toList
}
But In python api it was not implemented
answer @DanielDarabos也證實了這一點。
但是,我不是pyspark的專家。你可以嘗試一些相當於這個python的東西...
sc.getConf.getInt("spark.executor.instances", 1)
對不起,我遲到了,但在我的Pyspark中,它顯示「SparkContext對象有沒有屬性getConf「 –
我的意思是在你嘗試python等效語法。不是因爲它... –
我認爲它就像這個logger.info(sparkContext.getConf.getAll.mkString(「\ n」))將打印出所有參數,你可以找到執行人數以及 –
- 1. 獲取gunicorn工作者的數量?
- 2. Spark度量標準:如何訪問執行者和工作者數據?
- 3. Jenkins集羣中執行者的數量
- 4. 詹金斯 - 只增加一個工作的執行者數量
- 5. Rails,Heroku,Unicorn&Resque - 如何選擇網絡工作者/ resque工作者的數量?
- 6. 從.dll執行者彙編獲取
- 7. PySpark執行MapReduce工作
- 8. 如何從HDI集羣獲取工作者,核心,RAM的數量
- 9. Spark如何將片段與任務/執行者/工作者並列?
- 10. 報價註解者獲取作者
- 11. 獲取文件所有者/作者
- 12. Github API獲取特定行代碼的作者/提交者
- 13. c中的獲取者和安裝者#
- 14. 如何從網絡工作者調用共享工作者?
- 15. boost shared_ptr獲取擁有者數量
- 16. 隨機獲取作者
- 17. 行動聽者不工作
- 18. 如何獲取GAE頁面的訪問者數量?
- 19. 無法獲得手動活動的所有者和執行者
- 20. 如何在Eclipse工作區中獲取當前的Subclipse提交作者姓名?
- 21. 作者頁面獲取作者的帖子和頁面
- 22. 如何取消執行者的運行任務
- 23. pyspark在所有執行者之間均勻分配負載
- 24. 如何訪問網絡工作者中的變量?
- 25. 如何從作者ID獲取Wordpress帖子的總數?
- 26. 如何使用Tweepy獲取關注者數量(無分頁)?
- 27. 網絡工作者代表(子工作者)不工作
- 28. 在Wordpress中獲取發佈作者
- 29. 迭代指針向量的獲取者
- 30. API調用獲取作者數量GitHub API
我不認爲這個問題是另一個重複。我想知道有多少執行者可以在驅動程序中使用,甚至在創建任何rdds之前,在Mesos上運行。很煩人,但我最終解析了ui:import pandas作爲pd df = pd.read_html(「http:// localhost:4040/executors」)[1] len(df [df ['Executor ID']! ='driver']) – MarkNS
快速回答,獲取核心數:sc._jsc.sc()。getExecutorMemoryStatus()。size() – OronNavon