Deep Merge YAML Configuration Files
Beginner Mode

Start your terminal to use beginner mode.

Scenario

A microservices application uses two YAML configuration files: a base file with defaults and an overrides file for environment-specific settings.

Task

Write a Python script named merge_config.py in /home/interview/ that accepts two YAML file paths as command-line arguments (base and overrides), performs a deep merge, then extracts the database section and saves it to /home/interview/database_config.json.

The script will be executed as: python3 /home/interview/merge_config.py /home/interview/base.yaml /home/interview/overrides.yaml

Note: The PyYAML library is already installed.

Example

Expected output format in /home/interview/database_config.json:

{
  "primary": {
    "host": "prod-db-primary.example.com",
    "port": 5432,
    ...
  },
  "replica": {
    ...
  }
}

Terminal requires a larger screen

Open this page on a desktop or tablet (≥ 768px) to launch the terminal and practice hands-on.

Linux Terminal Environment

Write and execute your solution in the terminal below.

Sign In

Track

Question Difficulty Company Access
Need more practice in this area? Explore more questions →