YAML Configuration Guide
YAML Configuration Guide
Introduction
The Axion Framework utilizes a centralized YAML configuration file (config.yaml) to streamline its settings and ensure easy customization. This approach simplifies managing configurations across various environments, such as development, staging, and production.
In this guide, we’ll cover:
The purpose and structure of the configuration file.
How to modify and manage settings.
Best practices for secure management of sensitive data using environment variables.
Configuration File Structure
Here’s a sample config.yaml file, with an explanation of each section:
Editing the Configuration File
Locate and Open config.yaml
config.yamlYou’ll find config.yaml in the root directory of your Axion Framework project.
Update Configuration Values
Modify the file based on your specific environment:
Example for a production setup:
Use Environment-Specific Configurations
It’s a best practice to use separate YAML files for each environment:
config.development.yamlconfig.staging.yamlconfig.production.yaml
Dynamic Loading
Load the appropriate configuration file based on the environment:
Using Environment Variables
To manage sensitive data (like API keys and passwords) securely, avoid hardcoding them in your YAML file.
Steps for Secure Key Management
Add Variables to a
.envFileReference Variables in
config.yamlUse the${VARIABLE_NAME}syntax to include them dynamically:Load Environment Variables in Code Use Python’s
osmodule to read environment variables:
Best Practices
Secure Sensitive Data Always use environment variables for keys, passwords, and other confidential settings.
Environment-Specific YAML Files Use separate YAML files (
config.development.yaml,config.production.yaml) and load them dynamically.Document Configuration Changes Ensure any new configuration options are added to project documentation for clarity and collaboration.
Example Workflow
Set the Environment
Edit the YAML File Update paths, hostnames, or thresholds specific to your environment.
Run the Framework
Common Issues and Solutions
1. Missing Configuration File
Error:
FileNotFoundError: config.yaml not foundSolution: Ensure the
config.yamlfile is in the correct directory, or explicitly specify the file path.
2. Missing Environment Variables
Error:
API key for openai not foundSolution: Add the required variables to a
.envfile or set them in your system environment.
3. Invalid YAML Syntax
Error:
yaml.scanner.ScannerErrorSolution: Validate the YAML file using a linter or an online validator.
Last updated