Skip to content

Commit 3c34452

Browse files
committed
Wrap gcloud and gsutil in an script
1 parent 451f408 commit 3c34452

5 files changed

Lines changed: 21 additions & 2 deletions

File tree

spark/live.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
spark = SparkSession.builder.master("local").appName("SQL").getOrCreate()
44
df = spark.read.load('data/containers_tiny.parquet')
55
df.select("ship_imo", "container_id", "net_weight").show()
6+

spark/live/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.PHONY: watch
2+
watch:
3+
./live.sh
4+
5+
.PHONY: auth
6+
auth:
7+
docker run -ti --name gcloud-config google/cloud-sdk gcloud auth login
8+
9+
.PHONY: set-project
10+
set-project:
11+
./gcloud config set project bigdataupv2021
12+

spark/live/gcloud

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
docker run --rm -ti --volumes-from gcloud-config google/cloud-sdk gcloud "$@"
3+

spark/live/gsutil

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
docker run --rm --volumes-from gcloud-config -w /tmp/current -v $(pwd):/tmp/current google/cloud-sdk gsutil "$@"
3+

spark/live/live.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ fswatch ../live.py | while read -r fpath; do \
55
echo -e "\033[0;36mRELOAD\033[0m $fpath $(date +"%H%M%S")"
66
echo -e "# $(date +"%H:%M:%S")\n" | cat - ../live.py > live_mod.py
77
sed -e '/-python">/r./live_mod.py' live_template.html > live.html
8-
gsutil -h "Cache-Control:no-cache,max-age=0" \
9-
cp live.html gs://bigdata.luisbelloch.es/en_directo.html
8+
./gsutil -h "Cache-Control:no-cache,max-age=0" \
9+
cp /tmp/current/live.html gs://bigdata.luisbelloch.es/en_directo.html
1010

1111
# echo -e "# $(date +"%H:%M:%S")\n" | cat - live.py | pygmentize -f html -O full,linenos=1 -o live.html
1212
# scp live.html root@live.luisbelloch.es:/var/www/html/index.html

0 commit comments

Comments
 (0)