Skip to main content

Minnow Python

Utilities for the Minnow file processing framework.

import minnow

Create a processor

A processor can be created by subclassing minnow.Processor and overriding its process method, which must take a metadata file path, a data file path, and an output path. The built-in run method will take care of finding files to process in the input directory.

import sys

from pathlib import Path

import minnow

class MyProcessor(minnow.Processor):
    def process(self, metadata_file_path, data_file_path, output_path):
        metadata_dict = minnow.load_properties(metadata_file_path)
        data_file = data_file_path.open('rb')  # Use 'r' for text and 'rb' for binary

        # Do whatever work here

        # Write 0, 1, or many data/metadata pairs as output
        output_path.joinpath('mydata').write_bytes(my_output_data)
        minnow.save_properties(my_output_metadata_dict, output_path.joinpath('mydata.properties'))

def main():
    input_path = Path(sys.argv[1])
    output_path = Path(sys.argv[2])
    my_processor = MyProcessor(input_path, output_path)  # Create an instance of your processor
    my_processor.run()

if __name__ == "__main__":
    main()

Utilities

The minnow.Processor class is basically a wrapper for many of the utilities below. If you need more manual control, these utilities can be used directly.

Load a .properties file

This function will return the properties from a file as a dictionary.

from pathlib import Path

props = load_properties(Path('path/to/file.properties'))

Save to a .properties file

This function will save a dictionary as a .properties file.

props = {'type': 'blueprints', 'orientation': 'above', 'size': 2}
save_properties(props, Path('path/to/file.properties'))

Finding files to process

This function will return pairs of data/metadata files in a directory as DataMetaPair instances.

pairs_to_process = list_pairs_at_path(Path('path/to/input/directory'))

for pair in pairs_to_process:
    data_path = pair.data_path
    properties_path = pair.metadata_path

    # read the properties if you need to
    properties_dict = load_properties(properties_path)

    # do some processing on each pair

By default, list_pairs_at_path() looks for .properties files, but you can change the extension parameter:

pairs_to_process = list_pairs_at_path(Path('path/to/input/directory'), extension='.json')

for pair in pairs_to_process:
    data_path = pair.data_path
    properties_path = pair.metadata_path

    # read the properties if you need to
    properties_json = json.load(properties_path.read_text())

    # do some processing on each pair

Metadata

Release files for minnow 2020.307.0

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

Source distribution (sdist)

Source distribution for minnow 2020.307.0
File Size Uploaded Provenance
minnow-2020.307.0.tar.gz 4.0 kB Without provenance Details

Release files / minnow-2020.307.0.tar.gz

Download URL minnow-2020.307.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
961143bebe27a4edab2f81fbd5586f119447132ac82ff0ce701e8ac3c84e70b0
BLAKE2b-256 checksum
How to use checksums
2b1fadde474a6748b5cabb2cb799d0d09370fa8282a2455b6e6d086473ffdc5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.9.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.7

Security for minnow 2020.307.0

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.

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