dirigent_cli

Dirigent main CLI module.

This CLI hook and associated auxiliary functions sets up the required context prior to the calibration CLI hook being called.

This module contains the @with_calibration_context and @request_calibration_context decorators which can be used in calibration CLI hooks to request and open calibration contexts with certain required parameters/properties.

Functions

categorise_calibration(category)

Decorator to assign a category to a click command

check_git_status(repo_path)

find_module_info(opto_dict)

get_branch_name(repo_folder)

get_commit_hash(repo_folder)

get_git_tag(repo_folder)

get_repo_info(path)

is_head_detached(repo_path)

load_configuration(ctx, param, filename)

Load TOML or JSON calibration configuration file and attach resulting object to ctx.default_map.

load_default_files(ipaddress, opto_dict, ph2_dir)

request_calibration_context(function)

Decorator to request a calibration context.

verbosity(level)

Converts numeric verbosity level to logging level.

with_calibration_context(function)

Decorator to activate a requested calibration_context in a with-statement.

Classes

CalibrationCLI([name, ...])

Extension of Click's MultiCommand class to allow dynamic command loading.

categorise_calibration

module_testing.dirigent.dirigent_cli.categorise_calibration(category)

Decorator to assign a category to a click command

Categories are used to ensure specific behaviour in calibration_sequence

check_git_status

module_testing.dirigent.dirigent_cli.check_git_status(repo_path)

find_module_info

module_testing.dirigent.dirigent_cli.find_module_info(opto_dict)

get_branch_name

module_testing.dirigent.dirigent_cli.get_branch_name(repo_folder)

get_commit_hash

module_testing.dirigent.dirigent_cli.get_commit_hash(repo_folder)

get_git_tag

module_testing.dirigent.dirigent_cli.get_git_tag(repo_folder)

get_repo_info

module_testing.dirigent.dirigent_cli.get_repo_info(path: str) dict

is_head_detached

module_testing.dirigent.dirigent_cli.is_head_detached(repo_path)

load_configuration

module_testing.dirigent.dirigent_cli.load_configuration(ctx, param, filename)

Load TOML or JSON calibration configuration file and attach resulting object to ctx.default_map.

This function can be used as a callback to initialise all CLI options with values from the config file prior to argument parsing.

Parameters:
  • ctx – Click context.

  • param – Click parameter.

  • filename – Filename of config file. If ends in .toml, parsed as TOML, if in .json, as JSON.

load_default_files

module_testing.dirigent.dirigent_cli.load_default_files(ipaddress, opto_dict, ph2_dir)

request_calibration_context

module_testing.dirigent.dirigent_cli.request_calibration_context(function)

Decorator to request a calibration context.

This decorator accesses this module’s global variable register to set the request for a calibration context.

verbosity

module_testing.dirigent.dirigent_cli.verbosity(level)

Converts numeric verbosity level to logging level.

Parameters:

level – If <= 0 - WARNING, if 1 - INFO, if > 1 - DEBUG.

Returns:

logging.WARNING, logging.INFO or logging.DEBUG.

with_calibration_context

module_testing.dirigent.dirigent_cli.with_calibration_context(function)

Decorator to activate a requested calibration_context in a with-statement.

This decorator extend click’s pass_context handler to unwrap and activate a requested calibration_context in a with-statement.

CalibrationCLI

class module_testing.dirigent.dirigent_cli.CalibrationCLI(name: str | None = None, invoke_without_command: bool = False, no_args_is_help: bool | None = None, subcommand_metavar: str | None = None, chain: bool = False, result_callback: Callable[[...], Any] | None = None, **attrs: Any)

Bases: MultiCommand

Extension of Click’s MultiCommand class to allow dynamic command loading.

This class extends MultiCommand to list and load commands from the ../calibrations/ directory dynamically.

__init__(name: str | None = None, invoke_without_command: bool = False, no_args_is_help: bool | None = None, subcommand_metavar: str | None = None, chain: bool = False, result_callback: Callable[[...], Any] | None = None, **attrs: Any) None
get_command(ctx, name)

Loads requested module and returns calibration command (function) of same name within.

Parameters:
  • ctx – Click context.

  • name – name of module/calibration to load.

Returns:

Command object (function) within module.

list_categories(ctx)

Creates a dictionary of calibrations and their categories.

Returns:

Dictionary of calibration string keys and their categories as values.

list_commands(ctx)

Lists available calibrations.

Returns:

List of available calibrations in alphabetical order.