configuration.configuration_reader

Author: Ismael Seidel Affiliation: Embedded Computing Lab (ECL), Federal University of Santa Catarina (UFSC) Contributors:

  • André Filipe da Silva Fernandes

  • Leonardo de Sousa Marques

Description:

Read and resolve toolkit configuration files, aliases and lightfield configurations used across the toolkit.

This module provides the ConfigurationReader class which: - Loads and merges common and user JSON configuration files; - Resolves and deep-merges codec declarations (including inheritance

and inline overrides) and selects the codecs to run;

  • Loads lightfield configuration files;

  • Reads and merges quality metric declarations.

class ConfigurationReader(user_configuration_filename, overriden_base_path=None, aliases=None, lightfields=None)[source]

Bases: object

Read and resolve toolkit configuration files, aliases and lightfield configurations.

Parameters:
  • user_configuration_filename (str)

  • overriden_base_path (Path | None)

  • aliases (Dict[str, str] | None)

  • lightfields (List[str] | None)

aliases

Resolved alias map where CLI-provided aliases override file aliases.

configuration

Merged configuration dictionary.

lightfield_names

List of lightfield names to process.

lightfield_configurations

Mapping of lightfield name to its configuration dict.

__init__(user_configuration_filename, overriden_base_path=None, aliases=None, lightfields=None)[source]

Initialize the ConfigurationReader.

Parameters:
  • user_configuration_filename (str) – Path to the user configuration JSON file.

  • overriden_base_path (Path | None) – Optional base path to override the default toolkit base path.

  • aliases (Dict[str, str] | None) – Optional aliases provided (e.g., from CLI). These take precedence over aliases defined in config files.

  • lightfields (List[str] | None) – Optional list of lightfields to process. These take precedence over lightfields defined in config files.

read_configurations(configuration_filename)[source]

Read a JSON configuration file and replace aliases using self.aliases.

Parameters:

configuration_filename (Path) – Path to JSON configuration file.

Returns:

Parsed configuration dictionary with aliases replaced.

Return type:

Dict[str, Any]

read_all_codec_declarations()[source]

Populate self.configuration[‘codec-declarations’] merging CTC declarations and any custom or example codec files.

Return type:

None

read_all_quality_metrics_declarations()[source]

Read and merge additional quality metric configuration files listed in configuration. Uses self.aliases for alias replacement.

Return type:

None

configure_codecs()[source]

Resolve codec declarations, apply inline codec configurations, handle inheritance and select codecs to run. Uses self.aliases for reading any codec declaration files.

Return type:

None

get_lightfield_names()[source]

Get all configured lightfield names from CTC and other lists.

Returns:

Iterator over lightfield names.

Return type:

Iterator[str]

get_target_bpps(name, category)[source]

Return target bits-per-pixel rates for a given lightfield based on its category or explicit target-rates.

Parameters:
  • name (str) – Lightfield name.

  • category (str | None) – Category name (e.g., ‘lenslets’, ‘synthetics’, ‘hdcas’).

Returns:

List of target bpp values.

Raises:

Exception if category is invalid or not provided and no target-rates were defined.

Return type:

List[Any]

get_configuration_filename(name)[source]

Determine and return the path to a lightfield’s configuration file by searching configured paths.

Parameters:

name (str) – Lightfield name.

Returns:

Path to the configuration file.

Raises:

Exception if no configuration file is found for the given lightfield.

Return type:

Path

get_lightfield_configuration(name)[source]

Load a specific lightfield configuration file, filling in target-rates from CTC if missing.

Parameters:

name (str) – Lightfield name.

Returns:

Loaded lightfield configuration dict.

Raises:

Exception if configuration file not found.

Return type:

Dict[str, Any]

get_used_quality_unit_and_tool(metric)[source]

Determine the unit and tool used for a given metric.

Parameters:

metric (str) – Metric name.

Returns:

Tuple (unit, used_tool).

Return type:

Tuple[str, str]

get_dict()[source]

Return the internal configuration dictionary.

Return type:

Dict[str, Any]

read_config_from_argv(overriden_base_path=None)[source]

Helper to create a ConfigurationReader from sys.argv parameters. :returns: ConfigurationReader instance created from CLI args.

Parameters:

overriden_base_path (Path | None)

Return type:

ConfigurationReader

deep_merge_dicts(dict1, dict2)[source]

Deep merge dict2 into dict1, returning a new merged dictionary. Nested dictionaries are merged recursively; other values are overwritten by dict2.

Parameters:
  • dict1 (Dict[str, Any])

  • dict2 (Dict[str, Any])

Return type:

Dict[str, Any]