Closed WilliamMcCumstie closed 5 years ago
I'll merge this through now as discussed
Two things: First is the definition of CONFIG DIR in models/config
https://github.com/alces-software/adminware/pull/133/files#diff-9dec05cb851210ad467cd073ec726c7cR14 - shouldn't this be in the top level config
module with the rest of the path definitions for consistency & to be as DRY as poss.?
https://github.com/alces-software/adminware/blob/refactor/command-generation/src/config.py#L19-L21
The other is the use of glob - https://github.com/alces-software/adminware/pull/133/files#diff-9dec05cb851210ad467cd073ec726c7cR36 - how does this work around the issue that was our original motivation for abandoning glob in favour of manual recursion to begin with? The case in which there is a large file tree sibling to a config.yaml that may itself contain a file called config.yaml. That being possibly a) extremely computationally intensive & b) flooding the cli with deep namespace suggestions. Have you changed stance on this?
Thanks to the assistance of @bobwhitelock, there is a dedicated function for generating commands:
appliance_cli.command_generation.generate_commands
. It was originally designed as a wrapper cli that is configured using adictionary
. In order for it to be useful, theconfig
directory structure needs to be compiled into a singledict
.https://github.com/alces-software/imageware/blob/4efa15d9f243ba18aa6dc250c6f71d073ef6dd2a/controller/cli/src/fly_wrapper_config.py#L45-L73
A new
Config.hashify_all
method takes the configs from aglob
and a templatecommand
hash. The templatecommand
is duplicated for eachConfig
(at the hashes leaves). The templatecommand
also supports functions,lambda
, and other callable objects as dictionary values; with the config as the input.All of this has been wrapped in a
Config.command
decorator which can be used in theCLI
. Some adjusted to the option parsing was required. The--node
and--group
flags must be placed after the tool name now. Thenodes
option unpacking has also been placed in a decorator.Basic caching of the
Config
objects has also been added. This PR addresses parts of #126 and #114.