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 PyPI Storage

๐Ÿงฑ 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:

๐Ÿงช Continuous Integration (CI) : Databricks Validation

  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.

๐Ÿ“ฆ Continuous Deployment (CD): PyPI Release

Once the Databricks tests pass successfully (SUCCESS state), the pipeline automatically triggers the Deployment Job:

  1. Build: The project is packaged into a standard distributable format (Wheel .whl and Source .tar.gz) using the Python build backend.
  2. Publish: The artifacts are securely uploaded to PyPI (Python Package Index).

The workflow uses strict dependency logic (needs: databricks-tests), ensuring that broken code is never published.

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.1.tar.gz (8.3 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.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for spark_project_databricks-1.0.1.tar.gz
Algorithm Hash digest
SHA256 6fd1e21eb878e44b93b4525e606f83e20b49cb0f69f9844432e70e0eb242d8c9
MD5 9e1c84bb53d10edfdbb9b9ac98ed6dd5
BLAKE2b-256 33c6b6af10f1609e5ee450ef9afb2ba3af7a07d9a33bd990eaadc3308eac48d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spark_project_databricks-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d2290ded825a90dbfe6e950fc00cff82e16be8ddf542fb0e0cbe9de837d07b66
MD5 d1fdc78246f0349f7e8299519ef9a61b
BLAKE2b-256 bd9f6bbc60fa03179f6c5126a1ace301a69860ec333f94c75dd8fcc6f518a099

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