Config
Browse files- README.md +15 -1
- config.yaml.example +1 -1
- src/config.py +14 -2
README.md
CHANGED
@@ -68,4 +68,18 @@ To use these configuration values:
|
|
68 |
2. Replace the placeholder values in `config.yaml` with your actual configuration.
|
69 |
3. The application will automatically read these values from the `config.yaml` file.
|
70 |
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
2. Replace the placeholder values in `config.yaml` with your actual configuration.
|
69 |
3. The application will automatically read these values from the `config.yaml` file.
|
70 |
|
71 |
+
## Configuration
|
72 |
+
|
73 |
+
The project uses a flexible configuration system that allows for both local development and deployment:
|
74 |
+
|
75 |
+
1. For local development:
|
76 |
+
- Copy the `config.yaml.example` file to `config.yaml`.
|
77 |
+
- Replace the placeholder values in `config.yaml` with your actual configuration.
|
78 |
+
- The application will automatically read these values from the `config.yaml` file.
|
79 |
+
|
80 |
+
2. For deployment (e.g., to Hugging Face):
|
81 |
+
- The `config.yaml` file is not required and should not be included in the repository.
|
82 |
+
- Set the `HF_TOKEN` environment variable with your Hugging Face API token.
|
83 |
+
- Other configuration values will use sensible defaults if not specified.
|
84 |
+
|
85 |
+
Note: Make sure not to commit your `config.yaml` file with sensitive information to version control. It is already added to the `.gitignore` file to prevent accidental commits.
|
config.yaml.example
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
# API and Token configurations
|
2 |
api_token: YOUR_API_TOKEN_HERE
|
3 |
-
queue_repo:
|
4 |
|
5 |
# File paths
|
6 |
eval_requests_path: ./eval-queue
|
|
|
1 |
# API and Token configurations
|
2 |
api_token: YOUR_API_TOKEN_HERE
|
3 |
+
queue_repo: stacklok/requests
|
4 |
|
5 |
# File paths
|
6 |
eval_requests_path: ./eval-queue
|
src/config.py
CHANGED
@@ -1,9 +1,21 @@
|
|
1 |
import yaml
|
|
|
2 |
from typing import List, Dict, Any
|
3 |
|
4 |
def load_config() -> Dict[str, Any]:
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
config = load_config()
|
9 |
|
|
|
1 |
import yaml
|
2 |
+
import os
|
3 |
from typing import List, Dict, Any
|
4 |
|
5 |
def load_config() -> Dict[str, Any]:
|
6 |
+
if os.path.exists('config.yaml'):
|
7 |
+
with open('config.yaml', 'r') as file:
|
8 |
+
config = yaml.safe_load(file)
|
9 |
+
else:
|
10 |
+
raise FileNotFoundError("config.yaml not found. Please create it based on config.yaml.example.")
|
11 |
+
|
12 |
+
# Ensure required configurations are present
|
13 |
+
required_configs = ['api_token', 'queue_repo', 'eval_requests_path', 'eval_results_path']
|
14 |
+
for config_name in required_configs:
|
15 |
+
if config_name not in config:
|
16 |
+
raise ValueError(f"Required configuration '{config_name}' is missing in config.yaml")
|
17 |
+
|
18 |
+
return config
|
19 |
|
20 |
config = load_config()
|
21 |
|