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

Function profile_cli

spacy/cli/profile.py:20–49  ·  view source on GitHub ↗

Profile which functions take the most time in a spaCy pipeline. Input should be formatted as one JSON object per line with a key "text". It can either be provided as a JSONL file, or be read from sys.sytdin. If no input file is specified, the IMDB dataset is loaded via Thinc. D

(
    # fmt: off
    ctx: typer.Context,  # This is only used to read current calling context
    model: str = Arg(..., help="Trained pipeline to load"),
    inputs: Optional[Path] = Arg(
        None,
        help="Location of input file. '-' for stdin.",
        exists=True,
        allow_dash=True,
    ),
    n_texts: int = Opt(
        10000, "--n-texts", "-n", help="Maximum number of texts to use if available"
    ),
    # fmt: on
)

Source from the content-addressed store, hash-verified

18@debug_cli.command("profile")
19@app.command("profile", hidden=True)
20def profile_cli(
21 # fmt: off
22 ctx: typer.Context, # This is only used to read current calling context
23 model: str = Arg(..., help="Trained pipeline to load"),
24 inputs: Optional[Path] = Arg(
25 None,
26 help="Location of input file. '-' for stdin.",
27 exists=True,
28 allow_dash=True,
29 ),
30 n_texts: int = Opt(
31 10000, "--n-texts", "-n", help="Maximum number of texts to use if available"
32 ),
33 # fmt: on
34):
35 """
36 Profile which functions take the most time in a spaCy pipeline.
37 Input should be formatted as one JSON object per line with a key "text".
38 It can either be provided as a JSONL file, or be read from sys.sytdin.
39 If no input file is specified, the IMDB dataset is loaded via Thinc.
40
41 DOCS: https://spacy.io/api/cli#debug-profile
42 """
43 if ctx.parent.command.name == NAME: # type: ignore[union-attr] # called as top-level command
44 msg.warn(
45 "The profile command is now available via the 'debug profile' "
46 "subcommand. You can run python -m spacy debug --help for an "
47 "overview of the other available debugging commands."
48 )
49 profile(model, inputs=inputs, n_texts=n_texts)
50
51
52def profile(model: str, inputs: Optional[Path] = None, n_texts: int = 10000) -> None:

Callers

nothing calls this directly

Calls 1

profileFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…