Skip to main content

Grab and deploy Haystack pipelines

Project description

Hayhooks

PyPI - Version PyPI - Python Version Docker image release

Table of Contents

Quick start

Install the package

Start by installing the package:

pip install hayhooks

The hayhooks package ships both the server and the client component, and the client is capable of starting the server. From a shell, start the server with:

$ hayhooks run
INFO:     Started server process [44782]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://localhost:1416 (Press CTRL+C to quit)

Check Hayhooks status

From a different shell, you can query the status of the server with:

$ hayhooks status
Hayhooks server is up and running.

Deploy a Haystack pipeline

Time to deploy a Haystack pipeline. The pipeline must be in Yaml format (the output of pipeline.dump()), if you don't have one at hand, you can use one from this repository. From the root of the repo:

$ hayhooks deploy tests/test_files/test_pipeline_01.yml
Pipeline successfully deployed with name: test_pipeline_01

Another call to status should confirm your pipeline is ready to serve requests:

$ hayhooks status
Hayhooks server is up and running.

Pipelines deployed:
- test_pipeline_01

Have a look at the API schema

Hayhooks will use introspection to set up the OpenAPI schema accordingly to the inputs and outputs of your pipeline, and to see how this works let's get the pipeline diagram with:

$ curl http://localhost:1416/draw/test_pipeline_01 --output test_pipeline_01.png

The downloaded image should look like this:

test pipeline

As you can see, the pipeline in order to start requires an input of type int named value, and optionally we can pass another input of type int named add. At the end of the run, the pipeline will return an output of type int named result.

If you open a browser at http://localhost:1416/docs#/ you should see two schemas, one for the Request, where we'll pass the pipeline inputs (note how add is optional):

Test_pipeline_01RunRequest
    first_addition
        value* integer
        add (integer | null)

And another one for the Response, where we'll receive the pipeline results:

Test_pipeline_01RunResponse
    double
        value* integer

Run the pipeline

At this point, knowing the schema we can run our pipeline with an HTTP client:

$ curl -X 'POST' \
  'http://localhost:1416/test_pipeline_01' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "first_addition": {
    "value": 19
  }
}'

{"double":{"value":42}}%

Undeploy the pipeline

Hayhooks tries to do as much bookkeeping as possible without restarting the server. For example, to free up resources you can undeploy the pipeline directly from the client:

$ hayhooks undeploy test_pipeline_01
Pipeline successfully undeployed

Set a hayhooks server

To connect to a specific server you can pass a --server argument to the client:

$ hayhooks --server http://myserver:1416 status

Disable SSL verification

For development purposes, you can disable SSL verification with the --disable-ssl flag:

$ hayhooks --disable-ssl status

Docker setup

[!TIP] If you have docker-compose installed and you want to quickly get up and running, just do docker-compose up -d

Instead of launching the server in a separate shell like we did in the Quick Start, you can run it in a Docker container :

$ docker run --rm -p 1416:1416 deepset/hayhooks:main
...

If you want to build the container yourself:

$ cd docker
$ docker buildx bake
...

There are 2 special folders in the container you can override using a mount:

  1. A folder /opt/pipelines containing pipeline definitions that will be automatically deployed when the container starts
  2. A folder /opt/custom_components containing custom components that Haystack will be able to import if part of a pipeline

For example, you can mount a local ./pipelines folder containing pipelines you want to run at start-up like this:

$ docker run --rm -p 1416:1416 -v $PWD/pipelines:/opt/pipelines "deepset/hayhooks:main"

License

hayhooks is distributed under the terms of the Apache-2.0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hayhooks-0.0.17.tar.gz (17.1 kB view details)

Uploaded Source

Built Distribution

hayhooks-0.0.17-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file hayhooks-0.0.17.tar.gz.

File metadata

  • Download URL: hayhooks-0.0.17.tar.gz
  • Upload date:
  • Size: 17.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for hayhooks-0.0.17.tar.gz
Algorithm Hash digest
SHA256 9a92dfa5d7ec3b69464f44da2f0bd80113116157ed9d8c3532a2b1e5aaca600d
MD5 f1fe2bf7777601273b96aa3242cc6582
BLAKE2b-256 711f634cfaddf9526fdc5c21daf95ec8c739580235fe2e99963305688af8ed32

See more details on using hashes here.

File details

Details for the file hayhooks-0.0.17-py3-none-any.whl.

File metadata

  • Download URL: hayhooks-0.0.17-py3-none-any.whl
  • Upload date:
  • Size: 18.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.27.0

File hashes

Hashes for hayhooks-0.0.17-py3-none-any.whl
Algorithm Hash digest
SHA256 b4e14c6ab6da47d38d29931f763b7da58182c085326e891eaa7a5ddc51a1efe6
MD5 a00c31aa8444ffc211deba196f71a37d
BLAKE2b-256 1ad72616fdd1e3cd24db706ef2d4480e89a9668d055ebe5d3cfb9b345506ca7f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page