Skip to main content

Sales pipeline processing for Databricks

Project description

๐ŸŽฏ Spark Pipeline Industrialization: A Packaged Python Project


CI/CD - Run Databricks Tests Python Databricks

๐Ÿงฑ Project Overview

This project focuses on industrializing the initial data processing workflow by transitioning from exploratory notebooks to a structured and packaged Python application.

Designed around a Medallion Architecture (Bronze -> Silver -> Gold), this pipeline aims to be fully reproducible, testable, and maintainable. It ensures a seamless flow from raw data ingestion to refined analytics, supporting automated execution and long-term versioning.

The Gold layer structures the data to answer specific business questions:

  • Global Performance: Consolidated monthly revenue (normalized to a single currency).
  • Store Performance: Comparative analysis of revenue across different boutiques.
  • Best Sellers (Volume): Identification of most popular products by units sold.
  • Best Sellers (Value): Identification of highest-grossing products.

๐Ÿ—‚๏ธ Project structure

sales_pipeline_TP/
โ”‚
โ”œโ”€โ”€ sales_pipeline/                 # Code source du projet
โ”‚   โ”œโ”€โ”€ config/             
โ”‚   โ”‚    โ””โ”€โ”€ config.yaml            # Configuration files
โ”‚   โ”œโ”€โ”€ bronze/
โ”‚   โ”‚    โ””โ”€โ”€ ingestion.py           # Data ingestion
โ”‚   โ”œโ”€โ”€ silver/
โ”‚   โ”‚    โ””โ”€โ”€ cleaning.py            # Data cleaning and filtering
โ”‚   โ”œโ”€โ”€ gold/
โ”‚   โ”‚    โ””โ”€โ”€ aggregation.py         # Data aggregation
โ”‚   โ””โ”€โ”€ utils/
โ”‚        โ””โ”€โ”€ spark_session.py       # Spark session management
โ”‚        โ””โ”€โ”€ utils.py               # Project constants & settings
โ”‚        โ””โ”€โ”€ Reset_Raw_Data.ipynb   # Reinitializes project state
โ”œโ”€โ”€ tests/                    
โ”‚   โ””โ”€โ”€ test_cleaning.py            # Tests file
โ”‚
โ”œโ”€โ”€ main.py                         # Main pipeline
โ”œโ”€โ”€ pyproject.toml                  # Project configuration
โ”œโ”€โ”€ requirements.txt                # Python dependencies
โ””โ”€โ”€ README.md                       # Project Documentation

๐Ÿš€ Usage

๐Ÿ“ฆ Install dependencies

Install all dependencies listed in requirements.txt:

pip install -r requirements.txt

โ–ถ๏ธ Run the main program

To execute the main script:

python main.py

๐Ÿงช Run tests

Tests are located in the tests/ directory. To run them with pytest:

pytest tests/

or run the Notebook tests/run_test.ipynb


๐Ÿš€ CI/CD Pipeline: Databricks Integration

To ensure the reliability of the code in the production environment, this project implements a Continuous Integration (CI) pipeline using GitHub Actions orchestrated directly with Databricks.

Instead of running tests on a standard runner, the pipeline triggers a remote execution on the Spark cluster.

Workflow Logic

Triggered automatically on every push to main, the workflow performs the following steps:

  1. Setup: Installs the databricks-cli and authenticates using secure secrets (DATABRICKS_HOST, DATABRICKS_TOKEN).
  2. Remote Trigger: Initiates the specific Databricks Job (using Job ID) responsible for running the test suite.
  3. Monitoring: The workflow enters a polling loop, querying the job status via the Databricks API.
  4. Validation:
    • โœ… Pass: If the remote job returns a SUCCESS state.
    • โŒ Fail: If the remote job fails, breaking the CI pipeline to prevent bad code deployment.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spark_project_databricks-1.0.0.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spark_project_databricks-1.0.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file spark_project_databricks-1.0.0.tar.gz.

File metadata

File hashes

Hashes for spark_project_databricks-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6c46b2a0546a49222eae260873422a7c54bf1968dfcc12489520ff83369115df
MD5 061f8fc4876a12d591f5aa8a475713bd
BLAKE2b-256 c7882635511c7283e1a6fa950429da25c732f3c1b56c027bc51c540ca1839b81

See more details on using hashes here.

File details

Details for the file spark_project_databricks-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for spark_project_databricks-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f2f8fda24150669d0c70ca7ce81365757a9aee1e6f14886e149445ec47fd2f7
MD5 991e33eb2fc29989e4a3c2f37584796d
BLAKE2b-256 673e2a9a6f81d50848678ab595d52f883135a9a5ff3cb8a741e7afba616ceb61

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page