MCPcopy Index your code
hub / github.com/explosion/spaCy / debug_diff

Function debug_diff

spacy/cli/debug_diff.py:72–112  ·  view source on GitHub ↗
(
    config_path: Path,
    compare_to: Optional[Path],
    gpu: bool,
    optimize: Optimizations,
    pretraining: bool,
    markdown: bool,
)

Source from the content-addressed store, hash-verified

70
71
72def debug_diff(
73 config_path: Path,
74 compare_to: Optional[Path],
75 gpu: bool,
76 optimize: Optimizations,
77 pretraining: bool,
78 markdown: bool,
79):
80 msg = Printer()
81 with show_validation_error(hint_fill=False):
82 user_config = load_config(config_path)
83 if compare_to:
84 other_config = load_config(compare_to)
85 else:
86 # Recreate a default config based from user's config
87 lang = user_config["nlp"]["lang"]
88 pipeline = list(user_config["nlp"]["pipeline"])
89 msg.info(f"Found user-defined language: '{lang}'")
90 msg.info(f"Found user-defined pipelines: {pipeline}")
91 other_config = init_config(
92 lang=lang,
93 pipeline=pipeline,
94 optimize=optimize.value,
95 gpu=gpu,
96 pretraining=pretraining,
97 silent=True,
98 )
99
100 user = user_config.to_str()
101 other = other_config.to_str()
102
103 if user == other:
104 msg.warn("No diff to show: configs are identical")
105 else:
106 diff_text = diff_strings(other, user, add_symbols=markdown)
107 if markdown:
108 md = MarkdownRenderer()
109 md.add(md.code_block(diff_text, "diff"))
110 print(md.text)
111 else:
112 print(diff_text)

Callers 1

debug_diff_cliFunction · 0.85

Calls 4

show_validation_errorFunction · 0.85
load_configFunction · 0.85
init_configFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…