Skip to main content

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.

Metadata

Release files for nh 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nh 0.0.5
File Size Uploaded Provenance Actions
nh-0.0.5.tar.gz 7.8 kB Without provenance Details for nh-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nh 0.0.5
File Interpreter ABI Platform Actions
nh-0.0.5-py3-none-any.whl Python 3 none any Details for nh-0.0.5-py3-none-any.whl

Total release size: 15.9 kB

Release files / nh-0.0.5.tar.gz

Download URL nh-0.0.5.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7109803a72bb570ccfeda5ad9cd832be29c50fc3382e50b4bed47b242ce5e031
BLAKE2b-256 checksum
How to use checksums
0012b8314bcf81a06c139d32b4685590affdbb46d5984ccaae69d7d22fcaba18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.13

Release files / nh-0.0.5-py3-none-any.whl

Download URL nh-0.0.5-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
71470830e81ecc05381499b0dcc6d09eb89ba401a6e48bc4081c39c1f90e30b6
BLAKE2b-256 checksum
How to use checksums
cfc9c95b51fc6a1a463168b7e439342a68b65c2550399074327b15436e645963
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.13

Security for nh 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page