Configuration management#

Tools for managing Local Product Launcher configuration.

The methods in the config class manage the default configuration for launching products. The configuration is loaded from and stored to a config.json file. By default, this file is located in the user configuration directory (platform-dependent). Its location can be specified explicitly with the ANSYS_LAUNCHER_CONFIG_PATH environment variable.

ansys.tools.local_product_launcher.config.get_config_for(*, product_name, launch_mode)#

Get the configuration object for a (product, launch_mode) combination.

Get the default configuration object for the product. If a launch_mode parameter is given, the configuration for this mode is returned. Otherwise, the configuration for the default launch mode is returned.

Parameters:
  • product_name (str) – Product to get the configuration for.

  • launch_mode (Optional[str]) – Launch mode for the configuration.

Return type:

DataclassProtocol

Returns:

Configuration object.

Raises:
  • KeyError – If the requested configuration does not exist.

  • TypeError – If the configuration type does not match the type specified by the launcher plugin.

ansys.tools.local_product_launcher.config.get_launch_mode_for(*, product_name, launch_mode=None)#

Get the default launch mode configured for a product.

Parameters:
  • product_name (str) – Product to retrieve the launch mode for.

  • launch_mode (Optional[str], default: None) – Launch mode to use. The default is None, in which case the default launch mode is used. If a launch mode is specified, this value is returned.

Returns:

Launch mode for the product.

Return type:

str or None

ansys.tools.local_product_launcher.config.is_configured(*, product_name, launch_mode=None)#

Check if a configuration exists for the product/launch mode.

Note that if only the fallback launcher/configuration is available, this method returns False.

Parameters:
  • product_name (str) – Product whose configuration is checked.

  • launch_mode (Optional[str], default: None) – Launch mode whose configuration is checked. The default is None, in which case the default launch mode is used.

Return type:

bool

ansys.tools.local_product_launcher.config.save_config()#

Save the configuration to a file on disk.

This method saves the current in-memory configuration to the config.json file.

Return type:

None

ansys.tools.local_product_launcher.config.set_config_for(*, product_name, launch_mode, config, overwrite_default=False)#

Set the configuration for a given product and launch mode.

Update the configuration by setting the configuration for the given product and launch mode.

This method only updates the in-memory configuration, and it does not store it to a file.

Parameters:
  • product_name (str) – Name of the product whose configuration to update.

  • launch_mode (str) – Launch mode that the configuration applies to.

  • config (TypeVar(LAUNCHER_CONFIG_T, bound= DataclassProtocol)) – Configuration object.

  • overwrite_default (bool, default: False) – Whether to change the default launch mode for the product to the value specified for the launch_mode parameter.

Return type:

None