or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/fastcore@1.8.x
tile.json

tessl/pypi-fastcore

tessl install tessl/pypi-fastcore@1.8.0

Python supercharged for fastai development

Agent Success

Agent success rate when using this tile

56%

Improvement

Agent success rate improvement when using this tile compared to baseline

1.37x

Baseline

Agent success rate without this tile

41%

task.mdevals/scenario-4/

Directory Configuration Loader

Build a configuration file reader that can load settings from multiple configuration files located in different directories without permanently changing the program's working directory.

Requirements

Your task is to implement a configuration loader that:

  1. Accepts a list of directory paths, each containing a config.ini file
  2. Reads configuration values from each directory's config file
  3. Merges all configurations into a single dictionary, with later directories overriding earlier ones for duplicate keys
  4. Returns to the original working directory after all operations
  5. Handles cases where a directory or config file doesn't exist by skipping it with a warning

The implementation should ensure that the main program's working directory is never permanently changed, even when reading files from multiple different locations.

Function Signature

def load_configs(config_dirs: list[str]) -> dict:
    """
    Load and merge configuration files from multiple directories.

    Args:
        config_dirs: List of directory paths containing config.ini files

    Returns:
        Dictionary containing merged configuration values
    """
    pass

Test Cases

  • Given directories ['./dir1', './dir2'] where dir1/config.ini contains key1=value1 and dir2/config.ini contains key2=value2, the function returns {'key1': 'value1', 'key2': 'value2'} @test

  • Given directories ['./dir1', './dir2'] where both contain config.ini files with the same key key1, dir1 has key1=value1 and dir2 has key1=value2, the function returns {'key1': 'value2'} (later directory wins) @test

  • The original working directory is preserved after calling the function, even after reading from multiple directories @test

  • Given a directory path that doesn't exist, the function skips it and continues processing other directories @test

Implementation

@generates

Dependencies { .dependencies }

fastcore { .dependency }

Provides working directory context management utilities.

@satisfied-by