-
-
Notifications
You must be signed in to change notification settings - Fork 466
/
update_configs.py
executable file
·36 lines (32 loc) · 1.04 KB
/
update_configs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from pathlib import Path
from spacy.cli.init_config import fill_config
from wasabi import msg
import typer
def main(
root: Path = typer.Argument(Path.cwd(), help="Root path of repo"),
skip: bool = typer.Option(False, "--skip", "-s", help="Skip errors"),
):
"""
Automatically auto-fill all .cfg files in the repo using the current version
of spaCy. If --skip is set, errors will be logged but not raised.
"""
msg.info(f"Updating configs in {root}")
for path in root.glob("**/configs/*.cfg"):
rel_path = path.relative_to(root)
if rel_path.parts[0].startswith("."):
continue
print(rel_path)
try:
before, after = fill_config(path, path, silent=True)
except (Exception, SystemExit) as e:
if skip:
msg.fail("Failed", e)
continue
else:
raise
if before != after:
msg.good("Filled")
else:
msg.info("Already up to date")
if __name__ == "__main__":
typer.run(main)