# Extending Default Parameters File Support

Currently, the pipeline only supports YAML files for defining default values. This functionality is handled by the `ConfigDefaults` class in `ci_pipe/utils/config_default.py`, specifically in the `load_from_file` method.

If you want to support other file types, such as JSON or TOML, you need to modify this function to detect the file type and use the appropriate library to read it. You would add the code **inside the `load_from_file` method**, keeping the file structure as follows:

ci\_pipe/\
└─ utils/\
&#x20;       └─ config\_default.py <-- modify this file

Example modification:

```python
import yaml
import json
import toml

class ConfigDefaults:
    @staticmethod
    def load_from_file(path, file_system):
        if not file_system.exists(path):
            raise FileNotFoundError(f"Config file not found: {path}")

        try:
            content = file_system.read(path)
            if path.endswith(".yaml") or path.endswith(".yml"):
                data = yaml.safe_load(content) or {}
            elif path.endswith(".json"):
                data = json.loads(content)
            elif path.endswith(".toml"):
                data = toml.loads(content)
            else:
                raise ValueError(f"Unsupported config file type: {path}")
            
            if not isinstance(data, dict):
                raise ValueError(f"Config file {path} must contain a dictionary at the top level.")
            return data
        except Exception as e:
            raise ValueError(f"Error parsing config file: {e}")
```

For a more robust solution, you could encapsulate each loader in separate private functions (e.g., `_load_yaml`, `_load_json`, `_load_toml`) and have `load_from_file` select the appropriate loader based on the file extension. This approach makes it easier to add new formats in the future without modifying the core pipeline logic.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cipipe.gitbook.io/cipipe-docs/expansion-guide/extending-default-parameters-file-support.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
