From afee4f36ce5c753f1257b153497daa09bf211cdb Mon Sep 17 00:00:00 2001 From: oryx1729 <78848855+oryx1729@users.noreply.github.com> Date: Wed, 23 Jun 2021 12:01:54 +0200 Subject: [PATCH] Add scaffold for defining custom components for Pipelines (#1205) --- rest_api/config.py | 2 +- rest_api/controller/__init__.py | 1 + rest_api/pipeline/custom_component.py | 17 +++++++++++++++++ rest_api/{ => pipeline}/pipelines.yaml | 0 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 rest_api/pipeline/custom_component.py rename rest_api/{ => pipeline}/pipelines.yaml (100%) diff --git a/rest_api/config.py b/rest_api/config.py index 72fb0f0d5..56e1e7675 100644 --- a/rest_api/config.py +++ b/rest_api/config.py @@ -1,6 +1,6 @@ import os -PIPELINE_YAML_PATH = os.getenv("PIPELINE_YAML_PATH", "rest_api/pipelines.yaml") +PIPELINE_YAML_PATH = os.getenv("PIPELINE_YAML_PATH", "rest_api/pipeline/pipelines.yaml") QUERY_PIPELINE_NAME = os.getenv("QUERY_PIPELINE_NAME", "query") INDEXING_PIPELINE_NAME = os.getenv("INDEXING_PIPELINE_NAME", "indexing") diff --git a/rest_api/controller/__init__.py b/rest_api/controller/__init__.py index e69de29bb..4b066366a 100644 --- a/rest_api/controller/__init__.py +++ b/rest_api/controller/__init__.py @@ -0,0 +1 @@ +from rest_api.pipeline import custom_component # this import is required for the Custom Components to be registered diff --git a/rest_api/pipeline/custom_component.py b/rest_api/pipeline/custom_component.py new file mode 100644 index 000000000..35dfd97af --- /dev/null +++ b/rest_api/pipeline/custom_component.py @@ -0,0 +1,17 @@ +""" +Pipelines allow putting together Components to build a graph. + +In addition to the standard Haystack Components, custom user-defined Components +can be used in a Pipeline YAML configuration. + +The classes for the Custom Components must be defined in this file. +""" + + +from haystack import BaseComponent + + +class SampleComponent(BaseComponent): + + def run(self, **kwargs): + raise NotImplementedError diff --git a/rest_api/pipelines.yaml b/rest_api/pipeline/pipelines.yaml similarity index 100% rename from rest_api/pipelines.yaml rename to rest_api/pipeline/pipelines.yaml