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
)
| 18 | @debug_cli.command("profile") |
| 19 | @app.command("profile", hidden=True) |
| 20 | def 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 | |
| 52 | def profile(model: str, inputs: Optional[Path] = None, n_texts: int = 10000) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…