# Setup - Run only once per Kernel App%conda install openjdk-11-y# install PySpark%pip install pyspark==3.2.0%pip install spark-nlp==4.2.1# restart kernelfrom IPython.core.display import HTMLHTML("<script>Jupyter.notebook.kernel.restart()</script>")
Channels:
- conda-forge
Platform: linux-64
Collecting package metadata (repodata.json): done
Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
- openjdk-11
Current channels:
- https://conda.anaconda.org/conda-forge
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
Note: you may need to restart the kernel to use updated packages.
Requirement already satisfied: pyspark==3.2.0 in /opt/conda/lib/python3.10/site-packages (3.2.0)
Requirement already satisfied: py4j==0.10.9.2 in /opt/conda/lib/python3.10/site-packages (from pyspark==3.2.0) (0.10.9.2)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Note: you may need to restart the kernel to use updated packages.
Requirement already satisfied: spark-nlp==4.2.1 in /opt/conda/lib/python3.10/site-packages (4.2.1)
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
Note: you may need to restart the kernel to use updated packages.
import sagemakersess = sagemaker.Session()bucket = sess.default_bucket() print(f"the default SageMaker region specific bucket for this account is {bucket}")
the default SageMaker region specific bucket for this account is sagemaker-us-east-1-227905235486
!java -version
/bin/bash: line 1: java: command not found
%%timeimport boto3import sagemakerfrom sagemaker.spark.processing import PySparkProcessoraccount_id = boto3.client('sts').get_caller_identity()['Account']# Setup the PySpark processor to run the job. Note the instance type and instance count parameters. SageMaker will create these many instances of this type for the spark job.role = sagemaker.get_execution_role()spark_processor = PySparkProcessor( base_job_name="sm-spark-lab8", image_uri=f"{account_id}.dkr.ecr.us-east-1.amazonaws.com/sagemaker-spark:latest", role=role, instance_count=6, instance_type="ml.m5.xlarge", max_runtime_in_seconds=3600,)# s3 pathssession = sagemaker.Session()bucket = session.default_bucket()s3_dataset_path =f"s3a://{bucket}/project/comments/"print(f"account_id={account_id}, s3_dataset_path={s3_dataset_path}")output_prefix_data =f"project"output_prefix_logs =f"project_sentiment/spark_logs"year_filter ="2021"subreddit_filter ="climatechange"# run the job now, the arguments array is provided as command line to the Python script (Spark code in this case).spark_processor.run( submit_app="./sentiment_analysis_code/process.py", arguments=["--s3_dataset_path", s3_dataset_path,"--s3_output_bucket", bucket,"--s3_output_key_prefix", output_prefix_data,"--year", year_filter,"--subreddit", subreddit_filter, ], spark_event_logs_s3_uri="s3://{}/{}/spark_event_logs".format(bucket, output_prefix_logs), logs=False,)
INFO:sagemaker:Creating processing-job with name sm-spark-lab8-2024-04-19-19-56-35-899
UnexpectedStatusException: Error for Processing job sm-spark-lab8-2024-04-19-19-56-35-899: Failed. Reason: AlgorithmError: See job logs for more information