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 theDataFlowinstance.put_in_data_dict(name, data): Stores data in a dictionary attributedata_dictof theDataFlowinstance.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 ofget_datathat 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.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nh-0.0.6.tar.gz | 8.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nh-0.0.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.4 kB
Release files / nh-0.0.6.tar.gz
| Download URL | nh-0.0.6.tar.gz |
|---|---|
| Size | 8.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
884490b5d1eb0e83183c8be33d1bbbf78d393e5021c5d92189300364f7eccb31
|
|
BLAKE2b-256 checksum How to use checksums |
a5525fa7c3c7681ecc36e41b045c2f398628281a5bc1e4a54070fef7f5cb84ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / nh-0.0.6-py3-none-any.whl
| Download URL | nh-0.0.6-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c53a3ea66519b26d7ac0db01bc28e388351924c2f86a61fa655715d08d9f10b3
|
|
BLAKE2b-256 checksum How to use checksums |
1f0600a1a546fb4d7b588fb88ae7135c1052c38ef4d0699ae2af70f9e39a7695
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|