本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
使用 Apache Spark 執行處理任務
Apache Spark 是用於大規模資料處理的統一分析引擎。Amazon SageMaker AI 提供預先建置的 Docker 映像,其中包含 Apache Spark 和其他執行分散式資料處理任務所需的相依性。以下提供如何使用 Apache Spark 執行 Amazon SageMaker 處理任務的範例。
使用 Amazon SageMaker Python SDK
GitHub
您可以使用 sagemaker.spark.PySparkProcessorsagemaker.spark.SparkJarProcessor
以下程式碼範例示範如何執行可調用 PySpark 指令碼 preprocess.py 的處理任務。
from sagemaker.spark.processing import PySparkProcessor spark_processor = PySparkProcessor( base_job_name="spark-preprocessor", framework_version="2.4", role=role, instance_count=2, instance_type="ml.m5.xlarge", max_runtime_in_seconds=1200, ) spark_processor.run( submit_app="preprocess.py", arguments=['s3_input_bucket', bucket, 's3_input_key_prefix', input_prefix, 's3_output_bucket', bucket, 's3_output_key_prefix', output_prefix] )
如需深入探討,請參閱使用 Apache Spark 和 SageMaker Processing 進行分散式資料處理的範例筆記本
如果您未使用 Amazon SageMaker AI Python SDK
若要進一步了解如何搭配處理容器使用 SageMaker Python SDK,請參閱 Amazon SageMaker AI Python SDK