qpandalite.config module#
QPanda-lite configuration management module.
This module provides centralized configuration management for quantum cloud platforms including OriginQ (本源量子), Quafu (夸父), and IBM Quantum.
Configuration file location: ~/.qpandalite/qpandalite.yml
- Example configuration structure:
- default:
- originq:
token: xxx
- quafu:
token: xxx
- ibm:
token: xxx proxy:
http: http://proxy:8080 https: https://proxy:8080
- exception qpandalite.config.ConfigError[源代码]
基类:
ExceptionConfiguration-related error.
- exception qpandalite.config.ConfigValidationError[源代码]
基类:
ConfigErrorConfiguration validation error.
- exception qpandalite.config.PlatformNotFoundError[源代码]
基类:
ConfigErrorPlatform configuration not found error.
- exception qpandalite.config.ProfileNotFoundError[源代码]
基类:
ConfigErrorProfile not found error.
- qpandalite.config.create_default_config(config_path=None)[源代码]
Create default configuration file if it doesn't exist.
- 参数:
config_path (str | Path | None) -- Path to configuration file. If None, uses default path.
- 返回类型:
None
- qpandalite.config.get_active_profile(config_path=None)[源代码]
Get the active profile from configuration.
First checks QPANDALITE_PROFILE environment variable, then falls back to 'default'.
- 参数:
config_path (str | Path | None) -- Path to configuration file. If None, uses default path.
- 返回:
Active profile name.
- 返回类型:
str
- qpandalite.config.get_ibm_config(profile='default')[源代码]
Get IBM Quantum configuration.
- 参数:
profile (str) -- Configuration profile name (default: "default").
- 返回:
IBM Quantum configuration dictionary.
- 返回类型:
dict[str, Any]
- qpandalite.config.get_originq_config(profile='default')[源代码]
Get OriginQ (本源量子) configuration.
- 参数:
profile (str) -- Configuration profile name (default: "default").
- 返回:
OriginQ configuration dictionary.
- 返回类型:
dict[str, Any]
- qpandalite.config.get_platform_config(platform_name, profile='default', config_path=None)[源代码]
Get configuration for a specific platform.
- 参数:
platform_name (str) -- Name of the quantum cloud platform (originq, quafu, ibm).
profile (str) -- Configuration profile name (default: "default").
config_path (str | Path | None) -- Path to configuration file. If None, uses default path.
- 返回:
Platform configuration dictionary.
- 抛出:
PlatformNotFoundError -- If platform is not supported.
ProfileNotFoundError -- If profile does not exist in configuration.
ConfigError -- If platform configuration is not found within profile.
- 返回类型:
dict[str, Any]
- qpandalite.config.get_quafu_config(profile='default')[源代码]
Get Quafu (夸父) configuration.
- 参数:
profile (str) -- Configuration profile name (default: "default").
- 返回:
Quafu configuration dictionary.
- 返回类型:
dict[str, Any]
- qpandalite.config.load_config(config_path=None)[源代码]
Load configuration from YAML file.
- 参数:
config_path (str | Path | None) -- Path to configuration file. If None, uses default path.
- 返回:
Configuration dictionary.
- 抛出:
ConfigError -- If configuration file cannot be read.
- 返回类型:
dict[str, Any]
- qpandalite.config.save_config(config, config_path=None)[源代码]
Save configuration to YAML file.
- 参数:
config (dict[str, Any]) -- Configuration dictionary to save.
config_path (str | Path | None) -- Path to configuration file. If None, uses default path.
- 抛出:
ConfigError -- If configuration file cannot be written.
- 返回类型:
None
- qpandalite.config.set_active_profile(profile, config_path=None)[源代码]
Set the active profile in configuration.
- 参数:
profile (str) -- Profile name to set as active.
config_path (str | Path | None) -- Path to configuration file. If None, uses default path.
- 抛出:
ProfileNotFoundError -- If profile does not exist in configuration.
- 返回类型:
None
- qpandalite.config.update_platform_config(platform_name, platform_config, profile='default', config_path=None)[源代码]
Update configuration for a specific platform.
- 参数:
platform_name (str) -- Name of the quantum cloud platform.
platform_config (dict[str, Any]) -- Platform configuration dictionary.
profile (str) -- Configuration profile name (default: "default").
config_path (str | Path | None) -- Path to configuration file. If None, uses default path.
- 抛出:
PlatformNotFoundError -- If platform is not supported.
- 返回类型:
None
- qpandalite.config.validate_config(config=None, config_path=None)[源代码]
Validate configuration structure and required fields.
- 参数:
config (dict[str, Any] | None) -- Configuration dictionary to validate. If None, loads from file.
config_path (str | Path | None) -- Path to configuration file. Used if config is None.
- 返回:
List of validation error messages. Empty list if valid.
- 返回类型:
list[str]