1)Make sure your terminal at the main app folder directory
Pull data from API
PS : Use docker images to check Images ID
- docker run -v C:\Users\USER\Desktop\FypApp\DataStorage\data:/app/data (Python Script Image ID)
- file should be in FypApp\DataStorage\data
Store Data in NameNode
PS : Use docker ps to check container ID
- docker cp C:\Users\USER\Desktop\FypApp\DataStorage\data\data_australia.csv (namenode Container ID):/tmp
Make hdfs directory
-
docker exec -it namenode /bin/bash
-
hdfs dfs -mkdir -p /data
Store Data in hdfs
- hdfs dfs -put /tmp/data_australia.csv /data/data_australia.csv
Check if Data is stored in hdfs
- hdfs dfs -ls /data
PS: to leave from root of namenode use Ctrl-Z
PS : Use docker ps to check container ID
To go into spark
-
docker exec -it (spark Container ID) bash
-
inside bash use spark-shell
Load Data from HDFS
- val df = spark.read.csv("hdfs://namenode:9000/data/data_australia.csv")
PS: to leave from Scala cmd use Ctrl-D PS: to leave from bash cmd use Ctrl-Z
hadoop_namenode:/hadoop/dfs/name directories used are for Taskins system
Run new instance of Streamlit container docker run -p 8501:8501 fypapp-visualizeapp
Open new terminal to enter next few code blocks
Copy from HDFS to local storage docker cp (namenode container id):tmp\weather.csv C:\Users\taskin.intern"OneDrive - Razer (Asia-Pacific) Pte. Ltd"\Desktop\weather.csv Copy from local storage to streamlit container docker cp C:\Users\taskin.intern"OneDrive - Razer (Asia-Pacific) Pte. Ltd"\Desktop\weather.csv (visualizer Container ID):/app/weather.csv
Some useful commands docker ps --format "{{.Names}}" C:\Users\taskin.intern"OneDrive - Razer (Asia-Pacific) Pte. Ltd"\Desktop\tmp C:"Program Files (x86)"\FypApp\FypApp\DataStorage\data C:"Program Files (x86)"\FypApp2\FypApp\FypApp\DataStorage\data\weather.csv
Option to use volumes Copy from hdfs to streamlit via shared volume docker volume create shared_volume docker run -it --name hdfs_container -v shared_volume:/shared hdfs_image docker exec -it hdfs_container bash hdfs dfs -copyFromLocal /path/to/local/file /shared/file docker run -it --name streamlit_container -v shared_volume:/shared streamlit_image docker exec -it streamlit_container bash cat /shared/file