docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a system that exports application configuration objects to JSON format with metadata tracking for version control and audit purposes.
The system should:
Your solution should work with the following configuration structures:
class DatabaseConfig:
def __init__(self, host: str, port: int, max_connections: int):
self.host = host
self.port = port
self.max_connections = max_connections
class CacheConfig:
def __init__(self, ttl_seconds: int, max_size: int):
self.ttl_seconds = ttl_seconds
self.max_size = max_size
class AppConfig:
def __init__(self, app_name: str, database: DatabaseConfig, cache: CacheConfig):
self.app_name = app_name
self.database = database
self.cache = cacheAppConfig with database config (host="localhost", port=5432, max_connections=10) and cache config (ttl_seconds=300, max_size=1000), when exported with metadata, the output should include a -meta section with class information and dump timestamp. @testAppConfig, DatabaseConfig, and CacheConfig objects. @testAppConfig with nested objects, when exported with metadata, the -meta section should map JSON paths to fully-qualified class names for the root object and all nested objects. @testAppConfig, when exported without metadata mode enabled, the output should be a plain JSON dictionary with no -meta section. @testdef export_config(config: AppConfig, include_metadata: bool = True) -> dict:
"""
Export configuration to a JSON-compatible dictionary.
Args:
config: The application configuration to export
include_metadata: If True, include type and timestamp metadata
Returns:
A dictionary containing the configuration data and optionally metadata
"""
pass
def load_config(data: dict) -> AppConfig:
"""
Load configuration from a JSON-compatible dictionary.
If the data contains metadata, uses it to reconstruct the correct types.
Otherwise, requires explicit type information.
Args:
data: The dictionary containing configuration data
Returns:
The reconstructed AppConfig object
"""
passProvides serialization and deserialization support with metadata capabilities.