Skip to content

Commit 471cff9

Browse files
committed
Live preview for spark script samples
1 parent 2cd2404 commit 471cff9

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

spark/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
_work.py
2+
live.html
23

spark/live.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
from pyspark.sql import SparkSession
5+
6+
spark = SparkSession.builder.master("local").appName("SQL").getOrCreate()
7+
df = spark.read.load('data/containers_tiny.parquet')
8+
df.select("ship_imo", "container_id", "net_weight").show()
9+

spark/live.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
fswatch live.py | while read -r fpath; do \
5+
echo -e "\033[0;36mRELOAD\033[0m $fpath $(date +"%H%m%S")"
6+
pygmentize -f html -O full,linenos=1 -o live.html live.py
7+
scp live.html [email protected]:/var/www/html/index.html
8+
done
9+

0 commit comments

Comments
 (0)