Skip to main content

A bare-bones configuration managment tool.

Project description

SkeletonKey: A Bare-bones Configuration Management Tool

skeletonkey is a simple, lightweight, and flexible configuration management tool that allows you to manage complex configurations for your applications using YAML files. It dynamically loads classes and their arguments at runtime, making it easy to set up and modify your projects.

Installation

To install skeletonkey via pip, run the following command:

pip install skeletonkey

Usage

Below is an example of how to use skeletonkey in your project:

import skeletonkey

class MyModel:
    def __init__(self, layer_size: int, activation: str) -> None:
        self.layer_size = layer_size
        self.activation = activation

@skeletonkey.unlock("config.yaml")
def main(args):
    model = skeletonkey.instantiate(args.model)
    print("Model layer size: ", model.layer_size)
    print("Model activation: ", model.activation)
    print("Number of Epochs: ", args.epochs)

if __name__ == "__main__":  
    main()

To run the example above, create a config.yaml file with the following content:

epochs: 128
model:
  _target_: MyModel
  layer_size: 128
  activation: relu

Overwriting Arguments

Overwriting default config arguments is easy with skeletonkey.

To execute the script and overwrite default arguments, use this command:

python project.py --epochs 256

Moreover, skeletonkey allows you to conveniently work with nested configurations. When dealing with nested arguments in a configuration file, skeletonkey enables you to overwrite default configuration values using dot-separated keys.

For instance, if your configuration file has a nested YAML, you can overwrite the default values like this:

python project.py --model.parameters.layer_size 256

The resulting Namespace object will contain nested Namespace objects that can be accessed using dot notation, such as args.model.parameters.layer_size.

Default Configuration Files

skeletonkey also provides the functionality to specify multiple default configuration files at the beginning of the main configuration file. This feature allows you to easily manage and reuse common configurations across different projects or components.

Your main configuration file can include default configuration files using either of the following formats:

Format 1: Simple List

defaults:
  - path\to\yaml_config1.yaml
  - path\to\yaml_config2.yaml

Format 2: Nested Dictionary

defaults:
  path:
    to:
      - yaml_config1
      - yaml_config2

In both cases, skeletonkey will automatically merge the default configuration files with the main configuration file, prioritizing the settings in the main configuration file. This means that if there are any conflicts between the default configuration files and the main configuration file, the values in the main configuration file will take precedence.

Here's an example of how to use default configuration files in your project:

  1. Create two default configuration files:

default_config1.yaml:

learning_rate: 0.001
batch_size: 64

default_config2.yaml:

dropout: 0.5
optimizer: adam
  1. In your main config.yaml file, include the default configuration files:
defaults:
  - default_config1.yaml
  - default_config2.yaml

epochs: 128
model:
  _target_: MyModel
  layer_size: 128
  activation: relu
  1. When you run your project, skeletonkey will merge the default configuration files with the main configuration file, making the values from the default configuration files available in the args Namespace object:
print("Learning rate: ", args.learning_rate)
print("Batch size: ", args.batch_size)
print("Dropout: ", args.dropout)
print("Optimizer: ", args.optimizer)

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

skeletonkey-0.1.0.tar.gz (8.2 kB view hashes)

Uploaded Source

Built Distribution

skeletonkey-0.1.0-py3-none-any.whl (8.0 kB view hashes)

Uploaded Python 3

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