Show warnings if there's nothing to auto-fill

This commit is contained in:
Ines Montani 2020-08-16 14:19:43 +02:00
parent dd5804d499
commit 34bda91695
1 changed files with 14 additions and 6 deletions

View File

@ -88,11 +88,19 @@ def fill_config(
nlp, _ = util.load_model_from_config(config, auto_fill=True) nlp, _ = util.load_model_from_config(config, auto_fill=True)
except ValueError as e: except ValueError as e:
msg.fail(str(e), exits=1) msg.fail(str(e), exits=1)
before = config.to_str()
after = nlp.config.to_str()
if before == after:
msg.warn("Nothing to auto-fill: base config is already complete")
else:
msg.good("Auto-filled config with all values") msg.good("Auto-filled config with all values")
if diff and not is_stdout: if diff and not is_stdout:
if before == after:
msg.warn("No diff to show: nothing was auto-filled")
else:
msg.divider("START CONFIG DIFF") msg.divider("START CONFIG DIFF")
print("") print("")
print(diff_strings(config.to_str(), nlp.config.to_str())) print(diff_strings(before, after))
msg.divider("END CONFIG DIFF") msg.divider("END CONFIG DIFF")
print("") print("")
save_config(nlp.config, output_file, is_stdout=is_stdout) save_config(nlp.config, output_file, is_stdout=is_stdout)