Skip to main content

framework for data flow

Project description

nh

framework for data flow

To install: pip install nh

Overview

The nh package provides a robust framework designed to facilitate the management and pipelining of data processes in Python applications. At its core, the package includes the DataFlow class, which allows for the definition, dependency management, and execution of data retrieval and storage operations in a structured manner.

Features

  • Data Dependency Management: Automatically handles the dependencies between different pieces of data within the application.
  • Dynamic Data Handling: Supports dynamic creation of data handlers if specific data-making functions are not provided.
  • Verbose Progress Reporting: Includes capabilities to report on the progress of data operations, which can be adjusted by setting the verbosity level.

Key Components

DataFlow Class

The DataFlow class is central to the nh framework, enabling the pipelining and management of data processes. It allows developers to define how data should be fetched, processed, and stored.

Constructor

The constructor accepts any number of keyword arguments to set initial properties. It sets up data dependencies, makers, and storers, and initializes the data flow process.

Methods

  • mk_data_flow(): Sets up the data flow based on dependencies and available data makers.
  • put_in_store(name, data): Stores data in a predefined storage system.
  • put_in_attr(name, data): Stores data as an attribute of the DataFlow instance.
  • put_in_data_dict(name, data): Stores data in a dictionary attribute data_dict of the DataFlow instance.
  • get_data(data_name, **kwargs): Retrieves data based on the name and optional parameters. Handles dependencies and uses data makers if necessary.
  • get_data_lite_and_broad(data_name, **kwargs): A variant of get_data that is optimized for broader and lighter data fetching scenarios.
  • print_progress(min_level, msg='', verbose_level=None): Utility method for printing progress messages based on the verbosity level.

Usage Examples

Setting Up a Data Flow

from nh import DataFlow

class MyDataFlow(DataFlow):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.data_dependencies = {
            'summary_data': ['raw_data']
        }
        self.data_makers = {
            'raw_data': self.fetch_raw_data
        }

    def fetch_raw_data(self):
        # Implement fetching raw data
        return "Raw data"

    def process_data(self, raw_data):
        # Implement data processing
        return f"Processed {raw_data}"

# Create instance of MyDataFlow
data_flow = MyDataFlow(verbose_level=2)

# Fetch and process data
processed_data = data_flow.get_data('summary_data')
print(processed_data)

Storing and Retrieving Data

# Assuming `data_flow` is an instance of MyDataFlow
data_flow.put_in_attr('processed_data', processed_data)
retrieved_data = data_flow.get_data('processed_data')
print(retrieved_data)

This enhanced documentation provides a clearer understanding of the functionalities provided by the nh package, along with examples to help users integrate it into their projects effectively.

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

nh-0.0.5.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

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

nh-0.0.5-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file nh-0.0.5.tar.gz.

File metadata

  • Download URL: nh-0.0.5.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for nh-0.0.5.tar.gz
Algorithm Hash digest
SHA256 7109803a72bb570ccfeda5ad9cd832be29c50fc3382e50b4bed47b242ce5e031
MD5 b4ce8d0794d09ea1d7ff2b225e751a6c
BLAKE2b-256 0012b8314bcf81a06c139d32b4685590affdbb46d5984ccaae69d7d22fcaba18

See more details on using hashes here.

File details

Details for the file nh-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: nh-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for nh-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 71470830e81ecc05381499b0dcc6d09eb89ba401a6e48bc4081c39c1f90e30b6
MD5 cc0e4225796f710b76842cf97a8cf9b8
BLAKE2b-256 cfc9c95b51fc6a1a463168b7e439342a68b65c2550399074327b15436e645963

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