Skip to content
Snippets Groups Projects
Commit 073ba868 authored by Stefan Kesselheim's avatar Stefan Kesselheim
Browse files

added example notebook

parent 58053a3a
No related branches found
No related tags found
No related merge requests found
%% Cell type:code id:0d4c4bff-43ef-4574-8252-d309f872de3a tags:
``` python
!squeue --me
```
%% Output
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
6526639 develboos spark-cl kesselhe R 24:48 2 jwb[0097,0117]
%% Cell type:code id:67b9bb6e-6dbb-4c0f-80fa-3aea2afcce28 tags:
``` python
from pyspark.sql import SparkSession
import os
import random
home = os.environ["HOME"]
spark_master="spark://jwb0097i.juwels"
```
%% Cell type:code id:5b2ee080-70e8-42b4-935f-3c8fa9634c85 tags:
``` python
# This is required to add a "i" to the hostname
tmp=os.environ["HOSTNAME"].split("."); tmp[0]+="i"; spark_driver_hostname=".".join(tmp)
spark = SparkSession \
.builder \
.appName("My SparkSession") \
.config("spark.master", spark_master) \
.config("spark.driver.memory", "10g") \
.config("spark.driver.host", spark_driver_hostname) \
.config("spark.executor.memory", "400g") \
.getOrCreate()
sc=spark.sparkContext
def inside(p):
x, y = random.random(), random.random()
return x*x + y*y < 1
NUM_SAMPLES=10000000
count = sc.parallelize(range(0, NUM_SAMPLES)) \
.filter(inside).count()
print("Pi is roughly %f" % (4.0 * count / NUM_SAMPLES))
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment