Skip to content

Commit edf02ee

Browse files
mpangrazzibilgeyucelanakin87
authored
Update README (#66)
* update .env.example * fix CLI name and add python 3.9 to classifiers * add CLI name * Update README (WIP) * Update README * Add image * Correctly use cwd for loading .env file (#67) * Add gifs * Minor updates * Add initial paragraph about hayhooks * Update README.md Co-authored-by: Bilge Yücel <[email protected]> * Update deployment guidelines * Add explanation of why we need a pipeline wrapper * Update table of contents * Add support for short and long option names (#68) * Add support for short and long option names * Removed unused import * Update README.md Co-authored-by: Stefano Fiorucci <[email protected]> * Add a section to the former way of pipeline deployment --------- Co-authored-by: Bilge Yücel <[email protected]> Co-authored-by: Stefano Fiorucci <[email protected]>
1 parent 869bd26 commit edf02ee

File tree

9 files changed

+234
-140
lines changed

9 files changed

+234
-140
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ HAYHOOKS_PIPELINES_DIR="pipelines"
1212

1313
# Additional Python path to be added to the Python path
1414
HAYHOOKS_ADDITIONAL_PYTHON_PATH=""
15+
16+
# Disable SSL verification when making requests from the CLI
17+
HAYHOOKS_DISABLE_SSL=false

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ coverage.xml
5252
cover/
5353
*.png
5454

55+
!docs/**/*.png
56+
5557
# Translations
5658
*.mo
5759
*.pot
@@ -163,3 +165,6 @@ cython_debug/
163165

164166
# Pipelines default directory
165167
/pipelines
168+
169+
# OSX .DS_Store files
170+
.DS_Store

README.md

Lines changed: 205 additions & 125 deletions
Large diffs are not rendered by default.
401 KB
Loading

docs/assets/chat-completion.gif

413 KB
Loading
46 KB
Loading

docs/deployment_guidelines.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ Following are some guidelines about deploying and running Haystack pipelines.
77

88
## TL;DR
99

10-
- Use a single worker environment if you have mainly I/O operations in your pipeline and/or a low number of concurrent requests.
11-
- Use a multi-worker environment if you have mainly CPU-bound operations in your pipeline and/or a high number of concurrent requests.
10+
- Use a **single worker environment** if you have mainly I/O operations in your pipeline and/or a low number of concurrent requests.
11+
- Use a **multi-worker environment** if you have mainly CPU-bound operations in your pipeline and/or a high number of concurrent requests.
1212
- In any case, use `HAYHOOKS_PIPELINES_DIR` to share pipeline definitions across workers (if possible).
13+
- You can use [any additional supported `uvicorn` environment variables](https://www.uvicorn.org/settings) to the `hayhooks run` command (or put them in a `.env` file).
1314

1415
## Single worker environment
1516

@@ -26,31 +27,35 @@ command (or having a single Docker container running). This will launch a **sing
2627
You can deploy a pipeline using:
2728

2829
```bash
29-
hayhooks deploy
30+
hayhooks deploy-files # recommended
31+
32+
# or
33+
34+
hayhooks deploy ...
3035
```
3136

32-
command or do a `POST /deploy` request.
37+
or make `POST /deploy` / `POST /deploy-files` requests.
3338

3439
### Handling concurrent requests (single worker)
3540

36-
The `run()` method of the pipeline instance is synchronous code, and it's executed using `run_in_threadpool` to avoid blocking the main async event loop.
41+
The `run()` method of the pipeline instance is _synchronous_ code, and it's executed using `run_in_threadpool` to avoid blocking the main async event loop.
3742

3843
- If your pipeline is doing **mainly I/O operations** (like making HTTP requests, reading/writing files, etc.), the single worker should be able to handle concurrent requests.
3944
- If your pipeline is doing **mainly CPU-bound operations** (like computing embeddings), the GIL (Global Interpreter Lock) will prevent the worker from handling concurrent requests, so they will be queued.
4045

4146
## Multiple workers environment
4247

43-
### Single instance with multiple workers
48+
### Using `uvicorn` with multiple workers
4449

45-
Currently, `hayhooks run` command does not support multiple `uvicorn` workers. However, you can run multiple instances of the application using directly the `uvicorn` command or [FastAPI CLI](https://fastapi.tiangolo.com/fastapi-cli/#fastapi-run) using `fastapi run` command.
50+
Hayhooks supports multiple `uvicorn` workers running on a single instance, you can use the `hayhooks run` command with the `--workers` flag to start the application with the desired number of workers.
4651

4752
For example, if you have enough cores to run 4 workers, you can use the following command:
4853

4954
```bash
50-
fastapi run src/hayhooks/server/app.py --workers 4
55+
hayhooks run --workers 4
5156
```
5257

53-
This vertical scaling approach allows you to handle more concurrent requests (depending on available resources).
58+
This vertical scaling approach allows you to handle more concurrent requests (depending on environment available resources).
5459

5560
### Multiple single-worker instances behind a load balancer
5661

@@ -60,12 +65,12 @@ This horizontal scaling approach allows you to handle more concurrent requests.
6065

6166
### Pipeline deployment (multiple workers)
6267

63-
In both the above scenarios, **it's NOT recommended** to deploy a pipeline using the `hayhooks deploy` command (or `POST /deploy` request) as it will deploy the pipeline only on one of the workers, which is not ideal.
68+
In both the above scenarios, **it's NOT recommended** to deploy a pipeline using Hayhooks CLI commands (or corresponding API requests) as **it will deploy the pipeline only on one of the workers**, which is not ideal.
6469

65-
Instead, you want to provide the env var `HAYHOOKS_PIPELINES_DIR` pointing to a shared folder where all the workers can read the pipeline definitions at startup and load them. This way, all the workers will have the same pipelines available and there will be no issues when calling the API to run a pipeline.
70+
Instead, set the environment variable `HAYHOOKS_PIPELINES_DIR` to point to a shared directory accessible by all workers. When Hayhooks starts up, each worker will load pipeline definitions from this shared location, ensuring consistent pipeline availability across all workers when handling API requests.
6671

6772
### Handling concurrent requests (multiple workers)
6873

69-
When having multiple workers and pipelines deployed using `HAYHOOKS_PIPELINES_DIR`, you will be able to handle concurrent requests as each worker will be able to run a pipeline independently. This should be enough to make your application scalable, according to your needs.
74+
When having multiple workers and pipelines deployed using `HAYHOOKS_PIPELINES_DIR`, you will be able to handle concurrent requests as each worker should be able to run a pipeline independently. This may be enough to make your application scalable, according to your needs.
7075

71-
Note that even in a multiple-workers environment the individual single workers will have the same GIL limitation discussed above, so if your pipeline is mainly CPU-bound, you will need to scale horizontally according to your needs.
76+
Note that even in a multiple-workers environment, the individual single worker will have the same GIL limitations discussed above, so if your pipeline is mainly CPU-bound, you will need to scale horizontally according to your needs.

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ authors = [
1616
classifiers = [
1717
"Development Status :: 4 - Beta",
1818
"Programming Language :: Python",
19+
"Programming Language :: Python :: 3.9",
1920
"Programming Language :: Python :: 3.10",
2021
"Programming Language :: Python :: 3.11",
2122
"Programming Language :: Python :: 3.12",
@@ -41,7 +42,7 @@ Issues = "https://github.com/unknown/hayhooks/issues"
4142
Source = "https://github.com/unknown/hayhooks"
4243

4344
[project.scripts]
44-
hayhooks = "hayhooks.cli:hayhooks"
45+
hayhooks = "hayhooks.cli:hayhooks_cli"
4546

4647
[tool.hatch.version]
4748
source = "vcs"

src/hayhooks/cli/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from rich.panel import Panel
1313
from rich import box
1414

15-
hayhooks_cli = typer.Typer()
15+
hayhooks_cli = typer.Typer(name="hayhooks")
1616
hayhooks_cli.add_typer(pipeline, name="pipeline")
1717

1818
console = Console()

0 commit comments

Comments
 (0)