我沒有太多使用 maven 和 spark 的經驗,但到目前為止我所做的一切都是在 Scala 中進行的。現在我必須在 Pyspark 中開發一個專案,我想知道是否有可能使用 maven 在 Pyspark 中創建一個專案,如果可以,我將如何構建 pom 檔案。
因為到目前為止,在我指定的 pom 中,例如,這些屬性:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.assembly.plugin.version>3.1.0</maven.assembly.plugin.version>
<maven.antrun.plugin.version>1.8</maven.antrun.plugin.version>
<maven.surefire.plugin.version>3.0.0-M5</maven.surefire.plugin.version>
<maven.surefire.report.plugin.version>2.18.1</maven.surefire.report.plugin.version>
<maven.shade.plugin.version>3.1.1</maven.shade.plugin.version>
<maven.site.plugin.version>3.6</maven.site.plugin.version>
<maven.project.info.reports.plugin.version>2.2</maven.project.info.reports.plugin.version>
<scala.maven.plugin.version>4.1.1</scala.maven.plugin.version>
<maven.scalastyle.plugin.version>1.0.0</maven.scalastyle.plugin.version>
<encoding>UTF-8</encoding>
<scala.version>2.11.12</scala.version>
<spark.version>2.4.0.cloudera2</spark.version>
<hive-service.version>3.1.2</hive-service.version>
<spark.databricks.version>1.5.0</spark.databricks.version>
...
</properties>
是否以相同的方式僅將 <scala.version>2.11.12</scala.version> 更改為 <python.version>3.6</python.version>?或類似的東西?
uj5u.com熱心網友回復:
spark支持的語言有
- 爪哇
- 斯卡拉
- Python
- R
火花提交命令
./bin/spark-submit \
--class <main-class> \
--master <master-url> \
--deploy-mode <deploy-mode> \
--conf <key>=<value> \
... # other options
<application-jar> \
[application-arguments]
您可以從https://spark.apache.org/探索不同的語言支持 。
這些不同的語言有不同的構建和部署策略
例如:對于 java / scala - 您可以使用 Gradle 或 Maven 進行構建,這將生成一個 jar 檔案,您可以使用該檔案在任何具有 java 和 spark 設定的機器上運行。
./bin/spark-submit \
--class org.apache.spark.examples.SparkPi \
--master local[8] \
/path/to/examples.jar \
100
python - 你可以使用 pybuilder 構建一個 zip 檔案或者可以構建一個 egg 或者可以創建一個輪子分發檔案,可以在 submit spark 命令中使用。
只需傳遞一個 .py 檔案代替 ,然后使用 --py-files 將 Python .zip、.egg 或 .py 檔案添加到搜索路徑。
--py-files PY_FILES Comma-separated list of .zip, .egg, or .py files to place on the PYTHONPATH for Python apps.
--class CLASS_NAME Your application's main class (for Java / Scala apps).
--name NAME A name of your application.
--jars JARS Comma-separated list of jars to include on the driver and executor classpaths.
uj5u.com熱心網友回復:
要處理 Pyspark 專案,您需要 setup.py 。您可以參考打包 Python 應用程式。在 setup.py 中,您將列出依賴項并創建工件,您可以創建一個 wheel 檔案。然后輪檔案可以是火花提交的一部分
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/405483.html
標籤:
