Skip to content

Commit

Permalink
refactor: config validation
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnatovFedor committed Aug 15, 2023
1 parent f13a85b commit 3881ce7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions deeppavlov/core/commands/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,9 @@ def train_evaluate_model_from_config(config: Union[str, Path, dict],
if iterator is None:
try:
data = read_data_by_config(config)
# if the value 'val_every_n_epochs' is set in the config and there is no validation data - raise exception
if config.get('train', {}).get('val_every_n_epochs', None) and not data.get('valid', []):
if config.get('train', {}).get('val_every_n_epochs', None) and not data.get('valid'):
error_message = 'The value "val_every_n_epochs" is set in the config but no validation data is provided'
log.exception(error_message)
raise Exception(error_message)
raise ConfigError(error_message)
except ConfigError as e:
to_train = False
log.warning(f'Skipping training. {e.message}')
Expand Down

0 comments on commit 3881ce7

Please sign in to comment.