Pretty-print configuration errors
This commit is contained in:
@@ -21,6 +21,7 @@ from accelerate.utils import (
|
|||||||
is_xpu_available,
|
is_xpu_available,
|
||||||
)
|
)
|
||||||
from huggingface_hub import ModelCard
|
from huggingface_hub import ModelCard
|
||||||
|
from pydantic import ValidationError
|
||||||
|
|
||||||
from .config import Settings
|
from .config import Settings
|
||||||
from .evaluator import Evaluator
|
from .evaluator import Evaluator
|
||||||
@@ -47,7 +48,19 @@ def main():
|
|||||||
# Assume the last argument is the model.
|
# Assume the last argument is the model.
|
||||||
sys.argv.insert(-1, "--model")
|
sys.argv.insert(-1, "--model")
|
||||||
|
|
||||||
|
try:
|
||||||
settings = Settings()
|
settings = Settings()
|
||||||
|
except ValidationError as error:
|
||||||
|
print(f"[red]Configuration contains [bold]{error.error_count()}[/] errors:[/]")
|
||||||
|
|
||||||
|
for error in error.errors():
|
||||||
|
print(f"[bold]{error['loc'][0]}[/]: [yellow]{error['msg']}[/]")
|
||||||
|
|
||||||
|
print()
|
||||||
|
print(
|
||||||
|
"Run [bold]heretic --help[/] or see [bold]config.default.toml[/] for details about configuration parameters."
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
# Adapted from https://github.com/huggingface/accelerate/blob/main/src/accelerate/commands/env.py
|
# Adapted from https://github.com/huggingface/accelerate/blob/main/src/accelerate/commands/env.py
|
||||||
if torch.cuda.is_available():
|
if torch.cuda.is_available():
|
||||||
|
|||||||
Reference in New Issue
Block a user