The config.py module#

Summary#

get_launch_mode_for

Get the default launch mode configured for a product.

get_config_for

Get the configuration object for a given product and launch mode.

is_configured

Check if a configuration exists for a given product and launch mode.

set_config_for

Set the configuration for a given product and launch mode.

save_config

Save the configuration to a file on disk.

Description#

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.

Module detail#

config.get_launch_mode_for(*, product_name: str, launch_mode: str | None = None) str#

Get the default launch mode configured for a product.

Parameters#

product_namestr

Product to retrieve the launch mode for.

launch_modestr, 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#

str or None

Launch mode for the product.

config.get_config_for(*, product_name: str, launch_mode: str | None) ansys.tools.common.launcher.interface.DataclassProtocol#

Get the configuration object for a given product and launch mode.

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_namestr

Product to get the configuration for.

launch_modestr, default: None

Launch mode for the configuration.

Returns#

DataclassProtocol

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.

config.is_configured(*, product_name: str, launch_mode: str | None = None) bool#

Check if a configuration exists for a given product and 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_modestr, default: None

Launch mode whose configuration is checked. The default is None, in which case the default launch mode is used.

config.set_config_for(*, product_name: str, launch_mode: str, config: ansys.tools.common.launcher.interface.LAUNCHER_CONFIG_T, overwrite_default: bool = False) None#

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. It does not store it to a file.

Parameters#

product_namestr

Name of the product whose configuration to update.

launch_modestr

Launch mode that the configuration applies to.

configLAUNCHER_CONFIG_T

Configuration object.

overwrite_defaultbool, default: False

Whether to change the default launch mode for the product to the value specified for the launch_mode parameter.

config.save_config() None#

Save the configuration to a file on disk.

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