kloch

Warning

Despite being public, this repository is still in development stage and have not been tested extensively yet.

kloch /klˈoʃ/ [1] [2], is a configuration system for launching software.

Configurations are yaml files referred as environment profile which specify the parameters for one or multiple pre-defined launchers.

./profiles/beta.yml
__magic__: kloch_profile:4
identifier: knots:echoes:beta
version: 0.3.2
launchers:
  .base:
    environ:
      PROD_STATUS: beta
      PROD_NAME: echoes
  rezenv:
    requires:
      houdini: 20.1
      maya: 2023
      devUtils: 1+
  rezenv@os=windows:
    config:
      default_shell: "powershell"
./profiles/prod.yml
__magic__: kloch_profile:4
identifier: knots:echoes
version: 0.2.0
inherit: knots:echoes:beta
launchers:
  .base:
    environ:
      PROD_STATUS: prod
  rezenv:
    requires:
      houdini: 20.2
      -=devUtils: _

Launchers are internally-defined python objects that specify how to execute a combinations of options and (optional) command.

To use the profile, one must call the CLI tool. The profile example shared above can be launched using:

python -m kloch run knots:echoes

Design

kloch was initially designed as the environment manager layer when used with the rez package manager.

In a very abstract way, kloch is a system that:

  • serialize the arguments passed to a pre-defined function as yaml files.

    myLauncher(optionA="paint.exe", optionB={"PATH": "/foo"})
    

    becomes:

    myProfile.yml
    myLauncher:
       optionA: paint.exe
       optionB:
          PATH: /foo
    
  • execute that function by unserializing the parameters provided at runtime.

    pseudo-code in python
    profile = read_profile("myProfile.yml")
    for launcher_name, launcher_config in profile.items():
       launcher = get_launcher(launcher_name)
       launcher(**launcher_config)
    

Features

  • offer a CLI and a public python API

  • custom config format for environment profiles:
    • inheritance

    • inheritance merging rules with token system

  • arbitrary profile locations with flexible configuration

  • plugin system for launchers

Programming distinctions

  • robust logging.

  • good amount of unittesting

  • good documentation with a lot of doc created at code level

  • python 3.7+ support (EOL was in June 2023).

  • PyYAML as only mandatory external python dependency.

  • flexible “meta” configuration from environment variable or config file.

  • clear public and private API

Contents


References