Skip to main content

The tool for advanced project configuration with python object injection.

Project description

SmartParams

SmartParams is a lightweight Python framework that simplifies the development and configuration of research and other complex applications.

Installation

Run pip install smartparams.

Basic usage

# examples/basic/script.py
from dataclasses import dataclass

from smartparams import Smart


@dataclass
class Params:
    value1: str
    value2: str


def main(smart: Smart[Params]) -> None:
    params = smart()

    print('value1', params.value1)
    print('value2', params.value2)


if __name__ == '__main__':
    Smart(Params).run(
        function=main,
    )

Run script python -m examples.basic.script -s value1=one -s value2=two.

The script can also be configured from a file. First create the template file manually or via

python -m examples.basic.script --path examples/basic/params.yaml --dump,

then edit the file and set the appropriate values

# params.yaml
value1: one
value2: two

finally, run script python -m examples.basic.script --path examples/basic/params.yaml.

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

SmartParams-0.1.1.tar.gz (9.0 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page