Giter Club home page Giter Club logo

dealpipe's Introduction

Dealpipe - a simple data pipeline experiment

Requirements

Create a python program to read two flat files (excel and csv), validate them and to produce output files.

Output File

The output should be the following files:

  • Original file with extra columns including RowNo (A unique row identifier), AsOfDate (date/time of the processing), ProcessIdentifier (a unique process identifier), and RowHash (a calculated hash for each row). All extra fields should be placed at the end of the file except the RowNo which should be the starting field in each row.
  • Parquet File (Parquet version of the above file)
  • Error file (if there is any error involved in processing)

Input File

Produce a series of input files that will test the logic in your python package. For example, a file containing character codes within a decimal field will produce an error file. The error file is to contain the reason for failure and the field and row on which it occurred.

  1. CSV file - The input file should be a Deal list having 10 fields each with the following types:

    • 1 String field - for the Deal Name and it is mandatory
    • 5 Decimal fields (28,8) – any value is allowed (negative and positive) and you can name them D1 to D5
    • 1 Boolean field - indication Is Active flag with values Yes or No
    • 1 Country field (ISO standard) – create a lookup file with Code, Name
    • 1 Currency field (ISO standard) – create a lookup file with Code, Name
    • 1 Company field (Create a list of dummy companies with Id and Name ).
    • Make the company, currency, country, and one decimal field mandatory.
  2. For Excel - Create two worksheets:

    • One containing the 10 fields specified above
    • The other containing the list of lookup codes (company, currency, and country)

The process should do the following validations:

  • Validate data types
  • Validate Country against a list
  • Validate currency against a list
  • Validate the company against the company lookup and include the company name in the output record too.

Expectation:

  • The test can be done in a couple of hours, but we would like to see your quality of thinking, the best practices, and clean code so don't rush it
  • The pipeline should have a fair set of unit tests representing different scenarios
  • Give us a list of improvements and suggestions that can be done to make the code better.

Implementation

Use the dagster python tool to implement a well-tested data pipeline that implements all requirements. Dagster provides a very nice pipeline development and debugging interface called dagit which makes it easy to interactively see what the pipeline does at each step.

Development setup

In order to start developing you need to have the Python (3.9.x) interpreter installed on your system, you can use the pyenv project to manage multiple versions of python. Then you need to install the poetry dependency management tool. After you have the prerequisites installed you need to initialize your virtual environment by changing to the project's directory (brady) and executing the following command:

poetry install

That's it. Every time you want to work within your virtual environment you just need to activate it by executing the command:

poetry shell

For more instructuons on poetry, please see the guide on https://python-poetry.org/

Running the examples in dagit UI

Once you've set up your virtual environment and activated it you can run and debug the pipeline There are configuration presets which you can use to run the pipeline - they are placed in the 'presets' directory. You can easily run the pipeline with all configuration presets in dagit by starting it like so:

dagit

Click this link to see the Pipeline DAG Definition

When you are ready to run the pipeline navigate to the playground by opening the following link: Dagit pipeline playground Now just pick the desired preset from the Preset dropdown and then hit the Launch Execution button (bottom right).

After you click the Launch Execution button the pipeline is started and you can see the execution chart and log in real time. The pipeline defines custom events that could be used to view interactive state reports in the form of markdown for each step.

If there are any errors, the following Excel report, with row-wise errors, is generated: Excel Error Report

Here are some screenshots: Timeline UI Custom markdown validation report popup Error report dataframe

Output artifacts, such as files, are recorded in the form of Asset Materializations: Asset Materialization link in Event Log Asset Materialization View

Running from CLI

You can also run the pre-defined pipeline presets from terminal with the dagster command:

dagster pipeline execute -f dealpipe/pipelines/process_deals.py --preset valid_csv_example
dagster pipeline execute -f dealpipe/pipelines/process_deals.py --preset invalid_csv_example
dagster pipeline execute -f dealpipe/pipelines/process_deals.py --preset valid_xlsx_example
dagster pipeline execute -f dealpipe/pipelines/process_deals.py --preset invalid_xlsx_example

Running the tests

You can run the tests by invoking pytest after activating the virtual environment and changing to the project directory:

pytest -v

dealpipe's People

Contributors

strongholder avatar

Watchers

 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.