MCPcopy
hub / github.com/explosion/spaCy / init_labels_cli

Function init_labels_cli

spacy/cli/init_pipeline.py:150–187  ·  view source on GitHub ↗

Generate JSON files for the labels in the data. This helps speed up the training process, since spaCy won't have to preprocess the data to extract the labels.

(
    # fmt: off
    ctx: typer.Context,  # This is only used to read additional arguments
    config_path: Path = Arg(
        ..., help="Path to config file", exists=True, allow_dash=True
    ),
    output_path: Path = Arg(..., help="Output directory for the labels"),
    code_path: Optional[Path] = Opt(
        None,
        "--code",
        "-c",
        help="Path to Python file with additional code (registered functions) to be imported",
    ),
    verbose: bool = Opt(
        False,
        "--verbose",
        "-V",
        "-VV",
        help="Display more information for debugging purposes",
    ),
    use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU"),
    # fmt: on
)

Source from the content-addressed store, hash-verified

148 context_settings={"allow_extra_args": True, "ignore_unknown_options": True},
149)
150def init_labels_cli(
151 # fmt: off
152 ctx: typer.Context, # This is only used to read additional arguments
153 config_path: Path = Arg(
154 ..., help="Path to config file", exists=True, allow_dash=True
155 ),
156 output_path: Path = Arg(..., help="Output directory for the labels"),
157 code_path: Optional[Path] = Opt(
158 None,
159 "--code",
160 "-c",
161 help="Path to Python file with additional code (registered functions) to be imported",
162 ),
163 verbose: bool = Opt(
164 False,
165 "--verbose",
166 "-V",
167 "-VV",
168 help="Display more information for debugging purposes",
169 ),
170 use_gpu: int = Opt(-1, "--gpu-id", "-g", help="GPU ID or -1 for CPU"),
171 # fmt: on
172):
173 """Generate JSON files for the labels in the data. This helps speed up the
174 training process, since spaCy won't have to preprocess the data to
175 extract the labels."""
176 if verbose:
177 util.logger.setLevel(logging.DEBUG)
178 if not output_path.exists():
179 output_path.mkdir(parents=True)
180 overrides = parse_config_overrides(ctx.args)
181 import_code(code_path)
182 setup_gpu(use_gpu)
183 with show_validation_error(config_path):
184 config = util.load_config(config_path, overrides=overrides)
185 with show_validation_error(hint_fill=False):
186 nlp = init_nlp(config, use_gpu=use_gpu)
187 _init_labels(nlp, output_path)
188
189
190def _init_labels(nlp, output_path):

Callers

nothing calls this directly

Calls 6

parse_config_overridesFunction · 0.85
import_codeFunction · 0.85
setup_gpuFunction · 0.85
show_validation_errorFunction · 0.85
_init_labelsFunction · 0.85
init_nlpFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…