Giter Club home page Giter Club logo

efficient_data_processing_spark's Introduction

Code for my Efficient Data Processing in Spark course.

Efficient Data Processing in Spark

Repository for examples and exercises from the "Efficient Data Processing in Spark" course (under data-processing-spark). The capstone project is also present in this repository (under capstone/rainforest).

Setup

In order to run the project you'll need to install the following:

  1. git version >= 2.37.1
  2. Docker version >= 20.10.17 and Docker compose v2 version >= v2.10.2.

Windows users: please setup WSL and a local Ubuntu Virtual machine following the instructions here. Install the above prerequisites on your ubuntu terminal; if you have trouble installing docker, follow the steps here (only Step 1 is necessary). Please install the make command with sudo apt install make -y (if its not already present).

All the commands shown below are to be run via the terminal (use the Ubuntu terminal for WSL users). The make commands in this book should be run in the efficient_data_processing_spark folder. We will use docker to set up our containers. Clone and move into the lab repository, as shown below.

Note: If you are using mac M1 or later, please replace the "FROM deltaio/delta-docker:latest" in data-processing-spark/1-lab-setup/containers/spark/Dockerfile with "FROM deltaio/delta-docker:latest_arm64"

git clone https://github.com/josephmachado/efficient_data_processing_spark.git
cd efficient_data_processing_spark
# Start docker containers and create data for exercises and capstone project
# If you are using mac M1, please replace the "FROM deltaio/delta-docker:latest" 
# in data-processing-spark/1-lab-setup/containers/spark/Dockerfile
# with "FROM deltaio/delta-docker:latest_arm64"
make restart && make setup

Create aliases for long commands with a Makefile

Makefile lets you define shortcuts for commands that you might want to run, E.g., in our Makefile, we set the alias spark-sql for the command that opens us a spark sql session.

We have some helpful make commands for working with our systems. Shown below are the make commands and their definitions

  1. make restart: Stops running docker containers(if any) and starts new containers for our data infra.
  2. make setup: Generates data and loads them into tables and starts spark histroy server where we can see logs/Spark UI for already completed jobs.
  3. make spark-sql: Open a spark sql session; Use exit to quit the cli. This is where you will type your SQL queries.
  4. make cr: To run our pyspark code by pasting the relative path of exercise/example problems under data-processing-spark folder. See example image shown below.
  5. make rainforest: Runs our rainforest capstone project, the entry point for this code is here

This is how you run pyspark exercise files: make cr example

You can see the commands in this Makefile. If your terminal does not support make commands, please use the commands in the Makefile directly. All the commands in this book assume that you have the docker containers running.

You can test and run the capstone project as:

make pytest # to run all test cases
make ci # to run linting, formatting, and type checks
make rainforest # to run our ETL and create the final reports

Run a Jupyter notebook

Use the following command to start a jupyter server:

make notebook

You will see a link displayed with the format http://127.0.0.1:3000/?token=your-token, click it to open the jupyter notebook on your browser. You can use local jupyter notebook sample to get started.

You can stop the jupyter server with ctrl + c.

Infrastructure

We have three major services that run together, they are

  1. Postgres database: We use a postgres data base to simulate an upstream application database for our rainforest capstone project.
  2. Spark cluster: We create a spark cluster with a master and 2 workers which is where the data is processed. The spark cluster also includes a history server, which displays the logs and resource utilization (Spark UI) for completed/failed spark applications.
  3. Minio: Minio is an open source software that has fully compatable API with AWS S3 cloud storage system. We use minio to replicate S3 locally.

Infra

All our Spark images are built from the official Spark Delta image, and have the necessary modules installed. You can find the docker files defined here

efficient_data_processing_spark's People

Contributors

josephmachado avatar dependabot[bot] avatar

Stargazers

 avatar Vishnuraayan G avatar Eash Vrudhula avatar Ricardo avatar Sanket_Jadhav avatar Greg Dean avatar Miguel Asse avatar Muhammad Ilham Fajar avatar PB avatar  avatar Spiros Denaxas avatar Abdul Rehman Zia avatar Ram Shankar Choudhary avatar  avatar Alexander Demichev avatar Agasthya avatar Suhascp avatar  avatar Laurentiu Andrei avatar Chinmoy Dutta avatar Joseph Luiz avatar Jan Doležal avatar José Andrés Villanueva López avatar Jason Zhang avatar Kevin McBride avatar Jeff Pierce avatar Jimmy Brock avatar Anderson Frazão avatar  avatar  avatar  avatar Fellipe Fernandes avatar Hannas avatar  avatar Christian Schmidt avatar  avatar Badr Tarek Alaghoury avatar Christian avatar Sam avatar Gino Baltazar avatar jacob avatar Yudhistira Satryo avatar  avatar Jeff Takiguchi avatar  avatar Saqib Saleem avatar  avatar Ian Lanham avatar lelouvincx avatar  avatar  avatar  avatar Krishna Sai Raj Ponneboina avatar Shane Kenny avatar Anu Wat avatar Alex Chen avatar Kan Ouivirach avatar Mario Renau avatar  avatar Randy Meacham avatar Elie Kawerk avatar Levy Nunes avatar Nguyen Hiep avatar  avatar  avatar Phong Nguyen Nhat avatar Omar Valdez avatar  avatar Yudhiesh Ravindranath avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.