Update project widgets and examples [ci skip]

This commit is contained in:
Ines Montani 2020-09-10 13:04:16 +02:00
parent 908f3a4494
commit 763e302dcc
2 changed files with 35 additions and 37 deletions

View File

@ -219,7 +219,7 @@ pipelines.
<!-- TODO: update with better (final) example --> <!-- TODO: update with better (final) example -->
```yaml ```yaml
https://github.com/explosion/spacy-boilerplates/blob/master/ner_fashion/project.yml https://github.com/explosion/projects/tree/v3/tutorials/ner_fashion_brands/project.yml
``` ```
| Section | Description | | Section | Description |
@ -815,8 +815,10 @@ package helps you integrate spaCy visualizations into your Streamlit apps and
quickly spin up demos to explore your pipelines interactively. It includes a quickly spin up demos to explore your pipelines interactively. It includes a
full embedded visualizer, as well as individual components. full embedded visualizer, as well as individual components.
<!-- TODO: update once version is stable -->
```bash ```bash
$ pip install spacy_streamlit $ pip install "spacy_streamlit>=1.0.0a0"
``` ```
</div> </div>
@ -828,22 +830,15 @@ $ pip install spacy_streamlit
Using [`spacy-streamlit`](https://github.com/explosion/spacy-streamlit), your Using [`spacy-streamlit`](https://github.com/explosion/spacy-streamlit), your
projects can easily define their own scripts that spin up an interactive projects can easily define their own scripts that spin up an interactive
visualizer, using the latest pipeline you trained, or a selection of pipelines visualizer, using the latest pipeline you trained, or a selection of pipelines
so you can compare their results. The following script starts an so you can compare their results.
[NER visualizer](/usage/visualizers#ent) and takes two positional command-line
argument you can pass in from your `config.yml`: a comma-separated list of paths
to load the pipelines from and an example text to use as the default text.
<!-- TODO: replace with embed --> <Project id="integrations/streamlit">
```python Get started with spaCy and Streamlit using our project template. It includes a
### scripts/visualize.py script to spin up a custom visualizer and commands you can adjust to showcase
import spacy_streamlit and explore your own custom trained pipelines.
import sys
DEFAULT_TEXT = sys.argv[2] if len(sys.argv) >= 3 else "" </Project>
PIPELINES = [name.strip() for name in sys.argv[1].split(",")]
spacy_streamlit.visualize(PIPELINES, DEFAULT_TEXT, visualizers=["ner"])
```
> #### Example usage > #### Example usage
> >
@ -860,16 +855,16 @@ commands:
script: script:
- 'streamlit run ./scripts/visualize.py ./training/model-best "I like Adidas shoes."' - 'streamlit run ./scripts/visualize.py ./training/model-best "I like Adidas shoes."'
deps: deps:
- 'training/model-best' - "training/model-best"
``` ```
<Project id="integrations/streamlit"> The following script is called from the `project.yml` and takes two positional
command-line argument: a comma-separated list of paths or packages to load the
pipelines from and an example text to use as the default text.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus interdum ```python
sodales lectus, ut sodales orci ullamcorper id. Sed condimentum neque ut erat https://github.com/explosion/projects/blob/v3/integrations/streamlit/scripts/visualize.py
mattis pretium. ```
</Project>
--- ---
@ -882,9 +877,11 @@ library for serving machine learning models and you can use it in your spaCy
projects to quickly serve up a trained pipeline and make it available behind a projects to quickly serve up a trained pipeline and make it available behind a
REST API. REST API.
```python <Project id="integrations/fastapi">
# TODO: show an example that addresses some of the main concerns for serving ML (workers etc.)
``` Get started with spaCy and FastAPI using our project template.
</Project>
> #### Example usage > #### Example usage
> >
@ -895,23 +892,24 @@ REST API.
<!-- prettier-ignore --> <!-- prettier-ignore -->
```yaml ```yaml
### project.yml ### project.yml
commands: - name: "serve"
- name: serve help: "Serve the models via a FastAPI REST API using the given host and port"
help: "Serve the trained pipeline with FastAPI"
script: script:
- 'python ./scripts/serve.py ./training/model-best' - "uvicorn scripts.main:app --reload --host 127.0.0.1 --port 5000"
deps: deps:
- 'training/model-best' - "scripts/main.py"
no_skip: true no_skip: true
``` ```
<Project id="integrations/fastapi"> The script included in the template shows a simple REST API with a `POST`
endpoint that accepts batches of texts and returns batches of predictions, e.g.
named entities found in the documents. Type hints and
[`pydantic`](https://github.com/samuelcolvin/pydantic) are used to define the
expected data types.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus interdum ```python
sodales lectus, ut sodales orci ullamcorper id. Sed condimentum neque ut erat https://github.com/explosion/projects/blob/v3/integrations/fastapi/scripts/main.py
mattis pretium. ```
</Project>
--- ---

View File

@ -6,7 +6,7 @@ import Link from '../components/link'
import { InlineCode } from '../components/code' import { InlineCode } from '../components/code'
// TODO: move to meta? // TODO: move to meta?
const DEFAULT_REPO = 'https://github.com/explosion/projects' const DEFAULT_REPO = 'https://github.com/explosion/projects/tree/v3'
const COMMAND = 'python -m spacy project clone' const COMMAND = 'python -m spacy project clone'
export default function Project({ id, repo, children }) { export default function Project({ id, repo, children }) {