# Path: valohai_cli/exceptions.py
# class CLIException(ClickException):
#     kind: str = 'Error'
#     color: str = 'red'
# 
#     def __init__(self, message: str, kind: Optional[str] = None) -> None:
#         super().__init__(message)
#         self.kind = str(kind or self.kind)
# 
#     def show(self, file: Optional[Any] = None) -> None:
#         formatted_message = self.format_message()
#         if formatted_message and '\n' in formatted_message:
#             # If there are newlines in the message, we'll format things a little differently.
#             # Namely, the entire message is on a separate line, and to avoid "color fatigue",
#             # it's not all red.
#             click.secho(f'{self.kind}:', file=file, err=True, fg=self.color)
#             click.secho(formatted_message, file=file, err=True)
#         else:
#             text = f'{self.kind}: {formatted_message}'
#             click.secho(text, file=file, err=True, fg=self.color)
# 
#         hints = list(self.get_hints())
#         if hints:
#             click.secho('\nHint:', bold=True, err=True)
#             for hint in hints:
#                 click.echo(f'* {hint}', err=True)
# 
#     def get_hints(self) -> Iterable[str]:
#         return []


import json
import os
import yaml
from typing import Any
from valohai_cli.exceptions import CLIException




def read_data_file(path: str) -> Any:
    ext = os.path.splitext(path)[-1].lower()
    with open(path) as infp:
        if ext == '.json':
            return json.load(infp)

# Path: valohai_cli/exceptions.py
# class CLIException(ClickException):
#     kind: str = 'Error'
#     color: str = 'red'
# 
#     def __init__(self, message: str, kind: Optional[str] = None) -> None:
#         super().__init__(message)
#         self.kind = str(kind or self.kind)
# 
#     def show(self, file: Optional[Any] = None) -> None:
#         formatted_message = self.format_message()
#         if formatted_message and '\n' in formatted_message:
#             # If there are newlines in the message, we'll format things a little differently.
#             # Namely, the entire message is on a separate line, and to avoid "color fatigue",
#             # it's not all red.
#             click.secho(f'{self.kind}:', file=file, err=True, fg=self.color)
#             click.secho(formatted_message, file=file, err=True)
#         else:
#             text = f'{self.kind}: {formatted_message}'
#             click.secho(text, file=file, err=True, fg=self.color)
# 
#         hints = list(self.get_hints())
#         if hints:
#             click.secho('\nHint:', bold=True, err=True)
#             for hint in hints:
#                 click.echo(f'* {hint}', err=True)
# 
#     def get_hints(self) -> Iterable[str]:
#         return []


# Path: valohai_cli/utils/file_input.py
import json
import os
import yaml
from typing import Any
from valohai_cli.exceptions import CLIException





def read_data_file(path: str) -> Any:
    ext = os.path.splitext(path)[-1].lower()
    with open(path) as infp:
        if ext == '.json':
            return json.load(infp)

        elif ext == '.yaml':