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.

a profile with the configuration for a rezenv launcher
__magic__: kloch_profile:3
identifier: knots:echoes
version: 0.2.0
inherit: knots:echoes:beta
launchers:
  +=rezenv:
    +=config:
      +=package_filter:
        - excludes:
            - after(1714574770)
    +=params:
      - --verbose
    +=requires:
      houdini: 20.2
      -=devUtils: _
    +=environ:
      PROD_STATUS: prod

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