fidelity / spock

spock is a framework that helps manage complex parameter configurations during research and development of Python applications
https://fidelity.github.io/spock/
Apache License 2.0
121 stars 13 forks source link
configuration-management machine-learning python3

Managing complex configurations any other way would be highly illogical...

Quick Start · Documentation · Examples · Releases

About

spock is a framework that helps users easily define, manage, and use complex parameter configurations within Python applications. It lets you focus on the code you need to write instead of re-implementing boilerplate code such as creating ArgParsers, reading configuration files, handling dependencies, implementing type validation, maintaining traceability, etc.

spock configurations are normal python classes that are decorated with @spock. It supports inheritance, dynamic class dependencies, loading/saving configurations from/to multiple markdown formats, automatically generating CLI arguments, and hierarchical configuration by composition.

💥 Why You Should Use Spock 💥

Key Features

Quick Install

The basic install and [s3] extension require Python 3.7+ while the [tune] extension requires Python 3.8+

Base w/ S3 Extension w/ Hyper-Parameter Tuner
pip install spock-config pip install spock-config[s3] pip install spock-config[tune]

News/Releases

See Releases for more information.

Recent Changes

#### August 30th, 2023 * Removed Python 3.6 support as it was causing dependency hell * Collection of bugfixes #### Jan 12th, 2023 * Added support for resolving value definitions from references to other defined variables with the following syntax,`${spock.var:SpockClass.defined_variable}` * Added support for new fundamental types: (1) file: this is an overload of a str that verifies file existence and (r/w) access (2) directory: this is an overload of a str that verifies directory existence, creation if not existing, and (r/w) access * Deprecated support for `List` of repeated `@spock` decorated classes. * Collection of bugfixes #### May 17th, 2022 * Added support for resolving value definitions from environmental variables with the following syntax, `${spock.env:name, default}` * Added `.inject` annotation that will write back the original env notation to the saved output * Added the `.crypto` annotation which provides a simple way to hide sensitive environmental variables while still maintaining the written/loadable state of the spock config #### March 17th, 2022 * Added support for `typing.Callable` types (includes advanced types such as `List[List[Callable]]`) * Added support for `typing.Dict` types with type checking for types of both keys and values (includes advanced types such as `Dict[str, Tuple[Callable, Callable]]`) * Added support for post init hooks that allow for validation on parameters defined within `@spock` decorated classes. Additionally, added some common validation check to utils (within, greater than, less than, etc.) * Updated unit tests to support Python 3.10 #### January 26th, 2022 * Added `evolve` support to the underlying `SpockBuilder` class. This provides functionality similar to the underlying attrs library ([attrs.evolve](https://www.attrs.org/en/stable/api.html#attrs.evolve)). `evolve()` creates a new `Spockspace` instance based on differences between the underlying declared state and any passed in instantiated `@spock` decorated classes.

Original Implementation

spock was originally developed by the Artificial Intelligence Center of Excellence at Fidelity Investments by Nicholas Cilfone and Siddharth Narayanan