• Stars
    star
    118
  • Rank 298,239 (Top 6 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created about 4 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

spock is a framework that helps manage complex parameter configurations during research and development of Python applications

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 ๐Ÿ’ฅ

  • Simple organized parameter definitions (i.e. a single line)
  • Type checked (static-eqsue) & frozen parameters (i.e. fail early during long ML training runs)
  • Complex parameter dependencies made simple (i.e. @spock class with a parameter that is an Enum of other @spock classes)
  • Fully serializable parameter state(s) (i.e. exactly reproduce prior runtime parameter configurations)
  • Automatic type checked CLI generation w/o argparser boilerplate (i.e click and/or typer for free!)
  • Easily maintain parity between CLIs and Python APIs (i.e. single line changes between CLI and Python API definitions)
  • Unified hyper-parameter definitions and interface (i.e. don't write different definitions for Ax or Optuna)
  • Resolver that supports value definitions from reference to other defined variables, environmental variables, dynamic template re-injection, and encryption of sensitive values

Key Features

  • Simple Declaration: Type checked parameters are defined within a @spock decorated class. Supports required/optional and automatic defaults.
  • Easily Managed Parameter Groups: Each class automatically generates its own object within a single namespace.
  • Parameter Inheritance: Classes support inheritance (w/ lazy evaluation of inheritance/dependencies) allowing for complex configurations derived from a common base set of parameters.
  • Complex Types: Nested Lists/Tuples, List/Tuples of Enum of @spock classes, List of repeated @spock classes
  • Multiple Configuration File Types: Configurations are specified from YAML, TOML, or JSON files.
  • Hierarchical Configuration: Compose from multiple configuration files via simple include statements.
  • Command-Line Overrides: Quickly experiment by overriding a value with automatically generated command line arguments.
  • Immutable: All classes are frozen preventing any misuse or accidental overwrites (to the extent they can be in Python).
  • Tractability and Reproducibility: Save runtime parameter configuration to YAML, TOML, or JSON with a single chained command (with extra runtime info such as Git info, Python version, machine FQDN, etc). The saved markdown file can be used as the configuration input to reproduce prior runtime configurations.
  • Hyper-Parameter Tuner Addon: Provides a unified interface for defining hyper-parameters (via @spockTuner decorator) that supports various tuning/algorithm backends (currently: Optuna, Ax)
  • S3 Addon: Automatically detects s3:// URI(s) and handles loading and saving spock configuration files when an active boto3.Session is passed in (plus any additional S3Transfer configurations)

Quick Install

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

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

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). 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

More Repositories

1

mabwiser

[IJAIT 2021] MABWiser: Contextual Multi-Armed Bandits Library
Python
203
star
2

kconnect

Kubernetes Connection Manager CLI
Go
196
star
3

mab2rec

[AAAI 2024] Mab2Rec: Multi-Armed Bandits Recommender
Jupyter Notebook
113
star
4

seq2pat

[AAAI 2022] Seq2Pat: Sequence-to-Pattern Generation Library
Python
110
star
5

kraan

Kraan is a Kubernetes Controller that manages the deployment of HelmReleases to a cluster.
Go
91
star
6

awsrun

CLI and library to execute commands over one or more AWS or Azure accounts concurrently.
Python
78
star
7

stoke

A lightweight wrapper for PyTorch that provides a simple declarative API for context switching between devices, distributed modes, mixed-precision, and PyTorch extensions.
Python
65
star
8

selective

[CPAIOR 2021] Selective: Feature Selection Library
Python
59
star
9

sim2real-docs

Synthesize image datasets of documents in natural scenes with Python+Blender3D
Python
56
star
10

textwiser

[AAAI 2021] TextWiser: Text Featurization Library
Python
50
star
11

jurity

[ICMLA 2021] Jurity: Fairness & Evaluation Library
Python
42
star
12

vbc-desktop

Python
15
star
13

theliv

Go
10
star
14

classitransformers

A abstract text classification library using language models. Build your fine-tuned text classifier in 5 steps.
Jupyter Notebook
9
star
15

BoolXAI

BoolXAI is a research library for machine learning for Explainable AI (XAI) based on expressive Boolean formulas.
Jupyter Notebook
4
star
16

easyimputer

An abstract missing value imputation library. EasyImputer employs the right kind of imputation technique based on the statistics of missing data.
Python
4
star
17

homebrew-tap

Allow for homebrew based installation of Fidelity authored works before they are ready for homebrew-core
Ruby
3
star
18

vbc-board

Python
3
star
19

PhraseExtraction

An abstract python library to extract key phrases from text document.
Jupyter Notebook
3
star
20

krew-index

1
star