Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Python Boilerplate contains all the boilerplate you need to create a Python package.

Project description


Data Engineered with python

Proof of concept project for python data engineering. Envisioned use cases:
  • Data access and sharing with data defined as code.
  • Data catologing and discovery.
  • Data transfer and partitioning for distributed computing.
  • Go from remote data sources to model training with simple and expressive python.


pip install d4data

Example API:

Define data as code

from d4data.storage_clients import FTPStorageClient
from d4data.sources import CSVDataSource

class NIHChromosomeSNPS38(CSVDataSource):
    def __init__(self, chromosome, output_path):
        # define data that is specific to your data source
        self.chromosome = chromosome

        # give your data source a name, file name, local paths to save to and uri = "NIH_Chromose_{}_SNPS38".format(self.chromosome)
        self.file_name = "bed_chr_{}.bed.gz".format(self.chromosome)
        self.uri = "" + self.file_name
        self.local_paths = [os.path.join(output_path, self.file_name)]

        # assign a storage client
        self.client = FTPStorageClient()
  • Download data programmatically
data = NIHChromosomeSNPS38(chromosome=1, local_path="./datasources")

# calls
  • Process data
dataset = data.to_dataset()
for i in range(len(dataset)):
  • Compose DataSources dynamically with a DataStrategy:
from d4data.storage_clients import HTTPStorageClient
from d4data.core import DataStrategy, CompositeDataSource

# Define the DataSource
class HaploRegSource(CSVDataSource):
    def __init__(self, population, local_path): = "LD_{}".format(population.upper())
        self.file_name = + ".tsv.gz"
        self.uri = "" + self.file_name
        self.local_paths = [os.path.join(local_path, self.file_name)]

        self.client = HTTPStorageClient()

# Define the DataStrategy
# Data Strategies contain logic for building data sources from some higher level data about the data, e.g list of s3 urls.
# Data Strategies can also contain a partition strategy where logic for partitioning data sources can be implemented- you may want to partition based on compute resources available.
class HaploRegStrategy(DataStrategy):
    def __init__(self, populations, local_path):
        self.populations = populations
        self.local_path = local_path

        self._sources = {
            "haplo_reg": HaploRegSource

    def create_sources(self):
        comp_source = CompositeDataSource()
        source = self._sources["haplo_reg"]
        for population in self.populations:
            ds = source(population, self.local_path)
        return comp_source

pops = ["afr", "eur", "amr]
haplo_strategy = HaploRegStrategy(pops, local_path="./data_sources")
comp_source = haplo_strategy.create_sources()
for source in comp_source:
    # Download sources to in-memory file system
    d = s.to_memfs()
  • Prefect Integration: TODO
  • Pytorch Integration: TODO


  • TODO

Project details

Download files

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

Files for d4data, version 0.1.3
Filename, size File type Python version Upload date Hashes
Filename, size d4data-0.1.3-py2.py3-none-any.whl (8.2 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size d4data-0.1.3.tar.gz (11.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page