Use your SDK to manage deepset Cloud pipelines. You can save, load, list, deploy, and undeploy pipelines using Python methods of the Pipeline
class.
Prerequisites
- You must be an Admin to perform this task.
- If you work from your local SDK, you must have Haystack installed. For more information, see Haystack Installation. If you use Jupyter Notebooks in deepset Cloud, you don't have to worry about that.
- Add API endpoint and API key to the environment variables. The API endpoint is
<https://api.cloud.deepset.ai/api/v1>
. See Generate an API Key.
Server restartIf the Notebooks server closes while you're still working, all the files you saved are still there. When you restart the server, you'll be able to work on them again.
Save Your Pipeline to deepset Cloud
Create native Haystack pipelines and use the SDK to save them to deepset Cloud. Remember that your pipeline file should contain both a query pipeline and an indexing pipeline.
You can only save a pipeline that has not been deployed.
When using this method, you can only use DeepsetCloudDocumentStore
as your document_store
. Other document store types are not allowed and if you use them, they are replaced with DeepsetCloudDocumentStore
with default parameters.
Here's a table describing the parameters that you can use with the save_to_deepset_cloud()
method:
Method | Parameters | Description |
---|---|---|
|
| Saves a pipeline configuration to deepset Cloud. A single pipeline configuration file must declare two pipelines: a query pipeline and an indexing pipeline. |
Example of usage
from haystack import Pipeline
query_pipeline = Pipeline()
index_pipeline = Pipeline()
Pipeline.save_to_deepset_cloud(
query_pipeline=query_pipeline,
index_pipeline=index_pipeline,
pipeline_config_name="my_new_pipeline",
api_endpoint=DC_API_ENDPOINT,
api_key=DC_API_KEY,
)
Generate Code from an Existing Pipeline
Turn a pipeline object into code and then continue working with it. The pipeline must already exist, otherwise you'll receive an error message.
This table lists the parameters that you can use with the to_code()
and to_notebook_cell()
methods.
Method | Parameters | Description |
---|---|---|
|
| Returns the pipeline as a string of code. |
|
| Creates a new cell with the pipeline code in a Jupyter Notebook. |
Missing API KeyIf you see an API key error after running the pipeline code in your notebook, it means that you must add the API key to the document store parameters and rerun your code. You can find the API keys when you click your name in deepset Cloud and go to Connections.
Example of usage
from haystack import pipeline
index_pipeline = Pipeline.load_from_yaml(
"test_pipeline.yaml", pipeline_name="indexing_pipeline"
)
query_pipeline_code = query_pipeline.to_code(pipeline_variable_name="query_pipeline_from_code")
query_pipeline_code # string that contains the code of the query pipeline
query_pipeline_code = query_pipeline.to_notebook_cell(pipeline_variable_name="query_pipeline_from_code")
List Available Pipelines
Display a list of all pipelines in deepset Cloud.
This table lists all the parameters that you can use with the list_pipelines_on_deepset_cloud()
method.
Method | Parameters | Description |
---|---|---|
|
| Lists all pipelines available in deepset Cloud. |
Example of usage
from haystack import Pipeline
pipeline_list = Pipeline.list_pipelines_on_deepset_cloud()
print(pipeline_list) #this lets you see the names of the pipelines
Load a Pipeline
Load a pipeline from deepset Cloud.
Here are all the parameters that you can use with the load_from_deepset_cloud()
method.
Method | Parameters | Description |
---|---|---|
|
| Loads a pipeline from deepset Cloud. |
Example of usage
from haystack import Pipeline
p = Pipeline.load_from_deepset_cloud(
pipeline_config_name="my_pipeline", api_endpoint=API_ENDPOINT, api_key=API_KEY, pipeline_name="query"
)
p.run(query="Who is the father of Arya Stark?")
Deploy and Undeploy Pipelines
Deploy and undeploy pipelines that exist in deepset Cloud. While a pipeline is being deployed (or undeployed), you cannot modify it. If a pipeline is already deployed (or undeployed), nothing happens.
This table describes the parameters that you can use with the deploy_on_deepset_cloud
and undeploy_on_deepset_cloud
methods.
Method | Parameters | Description |
---|---|---|
|
| Deploys the pipeline in deepset Cloud. |
|
| Undeploys a pipeline in deepset Cloud. |
Example of usage
from haystack import Pipeline
p = Pipeline.deploy_on_deepset_cloud(
pipeline_config_name="my_pipeline", workspace="default", api_endpoint=API_ENDPOINT, api_key=API_KEY)