-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
44 lines (39 loc) · 1.3 KB
/
utils.py
File metadata and controls
44 lines (39 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# This file contain utility functions that are used across the mutli agent
# solution
import re
import os
import json
import yaml
import time
import boto3
import zipfile
import logging
from io import BytesIO
from pathlib import Path
from typing import Union, Dict, Optional
# set a logger
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
PYTHON_TIMEOUT: int = 180
PYTHON_RUNTIME: str = "python3.12"
# Initialize S3 client
s3_client = boto3.client('s3')
# Initialize the bedrock runtime client. This is used to
# query search results from the FMC and Meraki KBs
bedrock_agent_runtime_client = boto3.client('bedrock-agent-runtime')
def load_config(config_file: Union[Path, str]) -> Optional[Dict]:
"""
Load configuration from a local file.
:param config_file: Path to the local file
:return: Dictionary with the loaded configuration
"""
try:
config_data: Optional[Dict] = None
logger.info(f"Loading config from local file system: {config_file}")
content = Path(config_file).read_text()
config_data = yaml.safe_load(content)
logger.info(f"Loaded config from local file system: {config_data}")
except Exception as e:
logger.error(f"Error loading config from local file system: {e}")
config_data = None
return config_data