prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  TCP port in `launch_opensearch()` is different from default value in `OpenSearchDocumentStore`
  In `launch_opensearch()` we are starting an OpenSearch container using the port `9201`. The default port for `OpenSearchDocumentStore` is currently `9200`. I think we should align those two values.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `haystack/utils/doc_store.py`
  Content:
  ```
  1 # pylint: disable=missing-timeout
  2 
  3 import time
  4 import logging
  5 import subprocess
  6 from pathlib import Path
  7 
  8 import requests
  9 
  10 
  11 logger = logging.getLogger(__name__)
  12 ELASTICSEARCH_CONTAINER_NAME = "elasticsearch"
  13 OPENSEARCH_CONTAINER_NAME = "opensearch"
  14 WEAVIATE_CONTAINER_NAME = "weaviate"
  15 
  16 
  17 def launch_es(sleep=15, delete_existing=False):
  18     """
  19     Start an Elasticsearch server via Docker.
  20     """
  21 
  22     logger.debug("Starting Elasticsearch ...")
  23     if delete_existing:
  24         _ = subprocess.run([f"docker rm --force {ELASTICSEARCH_CONTAINER_NAME}"], shell=True, stdout=subprocess.DEVNULL)
  25     status = subprocess.run(
  26         [
  27             f'docker start {ELASTICSEARCH_CONTAINER_NAME} > /dev/null 2>&1 || docker run -d -p 9200:9200 -e "discovery.type=single-node" --name {ELASTICSEARCH_CONTAINER_NAME} elasticsearch:7.9.2'
  28         ],
  29         shell=True,
  30     )
  31     if status.returncode:
  32         logger.warning(
  33             "Tried to start Elasticsearch through Docker but this failed. "
  34             "It is likely that there is already an existing Elasticsearch instance running. "
  35         )
  36     else:
  37         time.sleep(sleep)
  38 
  39 
  40 def launch_opensearch(sleep=15, delete_existing=False):
  41     """
  42     Start an OpenSearch server via Docker.
  43     """
  44     logger.debug("Starting OpenSearch...")
  45     # This line is needed since it is not possible to start a new docker container with the name opensearch if there is a stopped image with the same now
  46     # docker rm only succeeds if the container is stopped, not if it is running
  47     if delete_existing:
  48         _ = subprocess.run([f"docker rm --force {OPENSEARCH_CONTAINER_NAME}"], shell=True, stdout=subprocess.DEVNULL)
  49     status = subprocess.run(
  50         [
  51             f'docker start {OPENSEARCH_CONTAINER_NAME} > /dev/null 2>&1 || docker run -d -p 9201:9200 -p 9600:9600 -e "discovery.type=single-node" --name {OPENSEARCH_CONTAINER_NAME} opensearchproject/opensearch:1.3.5'
  52         ],
  53         shell=True,
  54     )
  55     if status.returncode:
  56         logger.warning(
  57             "Tried to start OpenSearch through Docker but this failed. "
  58             "It is likely that there is already an existing OpenSearch instance running. "
  59         )
  60     else:
  61         time.sleep(sleep)
  62 
  63 
  64 def launch_weaviate(sleep=15):
  65     """
  66     Start a Weaviate server via Docker.
  67     """
  68 
  69     logger.debug("Starting Weaviate ...")
  70     status = subprocess.run(
  71         [
  72             f"docker start {WEAVIATE_CONTAINER_NAME} > /dev/null 2>&1 || docker run -d -p 8080:8080 --env AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED='true' --env PERSISTENCE_DATA_PATH='/var/lib/weaviate' --name {WEAVIATE_CONTAINER_NAME} semitechnologies/weaviate:latest"
  73         ],
  74         shell=True,
  75     )
  76     if status.returncode:
  77         logger.warning(
  78             "Tried to start Weaviate through Docker but this failed. "
  79             "It is likely that there is already an existing Weaviate instance running. "
  80         )
  81     else:
  82         time.sleep(sleep)
  83 
  84 
  85 def stop_container(container_name, delete_container=False):
  86     logger.debug("Stopping %s...", container_name)
  87     status = subprocess.run([f"docker stop {container_name}"], shell=True)
  88     if status.returncode:
  89         logger.warning(
  90             f"Tried to stop {container_name} but this failed. "
  91             f"It is likely that there was no Docker container with the name {container_name}"
  92         )
  93     if delete_container:
  94         status = subprocess.run([f"docker rm {container_name}"], shell=True)
  95 
  96 
  97 def stop_opensearch(delete_container=False):
  98     stop_container(OPENSEARCH_CONTAINER_NAME, delete_container)
  99 
  100 
  101 def stop_elasticsearch(delete_container=False):
  102     stop_container(ELASTICSEARCH_CONTAINER_NAME, delete_container)
  103 
  104 
  105 def stop_weaviate(delete_container=False):
  106     stop_container(WEAVIATE_CONTAINER_NAME, delete_container)
  107 
  108 
  109 def stop_service(document_store, delete_container=False):
  110     ds_class = str(type(document_store))
  111     if "OpenSearchDocumentStore" in ds_class:
  112         stop_opensearch(delete_container)
  113     elif "ElasticsearchDocumentStore" in ds_class:
  114         stop_elasticsearch(delete_container)
  115     elif "WeaviateDocumentStore" in ds_class:
  116         stop_weaviate(delete_container)
  117     else:
  118         logger.warning("No support yet for auto stopping the service behind a %s", type(document_store))
  119 
  120 
  121 def launch_milvus(sleep=15, delete_existing=False):
  122     """
  123     Start a Milvus server via Docker
  124     """
  125     logger.debug("Starting Milvus ...")
  126 
  127     milvus_dir = Path.home() / "milvus"
  128     milvus_dir.mkdir(exist_ok=True)
  129 
  130     request = requests.get(
  131         "https://github.com/milvus-io/milvus/releases/download/v2.0.0/milvus-standalone-docker-compose.yml"
  132     )
  133     with open(milvus_dir / "docker-compose.yml", "wb") as f:
  134         f.write(request.content)
  135 
  136     status = subprocess.run(["cd /home/$USER/milvus/ && docker-compose up -d"], shell=True)
  137 
  138     if status.returncode:
  139         logger.warning(
  140             "Tried to start Milvus through Docker but this failed. "
  141             "It is likely that there is already an existing Milvus instance running. "
  142         )
  143     else:
  144         time.sleep(sleep)
  145
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/haystack/utils/doc_store.py b/haystack/utils/doc_store.py
  --- a/haystack/utils/doc_store.py
  +++ b/haystack/utils/doc_store.py
  @@ -37,7 +37,7 @@
           time.sleep(sleep)
   
   
  -def launch_opensearch(sleep=15, delete_existing=False):
  +def launch_opensearch(sleep=15, delete_existing=False, local_port=9200):
       """
       Start an OpenSearch server via Docker.
       """
  @@ -48,7 +48,7 @@
           _ = subprocess.run([f"docker rm --force {OPENSEARCH_CONTAINER_NAME}"], shell=True, stdout=subprocess.DEVNULL)
       status = subprocess.run(
           [
  -            f'docker start {OPENSEARCH_CONTAINER_NAME} > /dev/null 2>&1 || docker run -d -p 9201:9200 -p 9600:9600 -e "discovery.type=single-node" --name {OPENSEARCH_CONTAINER_NAME} opensearchproject/opensearch:1.3.5'
  +            f'docker start {OPENSEARCH_CONTAINER_NAME} > /dev/null 2>&1 || docker run -d -p {local_port}:9200 -p 9600:9600 -e "discovery.type=single-node" --name {OPENSEARCH_CONTAINER_NAME} opensearchproject/opensearch:1.3.5'
           ],
           shell=True,
       )
  
verification_info: {"golden_diff": "diff --git a/haystack/utils/doc_store.py b/haystack/utils/doc_store.py\n--- a/haystack/utils/doc_store.py\n+++ b/haystack/utils/doc_store.py\n@@ -37,7 +37,7 @@\n         time.sleep(sleep)\n \n \n-def launch_opensearch(sleep=15, delete_existing=False):\n+def launch_opensearch(sleep=15, delete_existing=False, local_port=9200):\n     \"\"\"\n     Start an OpenSearch server via Docker.\n     \"\"\"\n@@ -48,7 +48,7 @@\n         _ = subprocess.run([f\"docker rm --force {OPENSEARCH_CONTAINER_NAME}\"], shell=True, stdout=subprocess.DEVNULL)\n     status = subprocess.run(\n         [\n-            f'docker start {OPENSEARCH_CONTAINER_NAME} > /dev/null 2>&1 || docker run -d -p 9201:9200 -p 9600:9600 -e \"discovery.type=single-node\" --name {OPENSEARCH_CONTAINER_NAME} opensearchproject/opensearch:1.3.5'\n+            f'docker start {OPENSEARCH_CONTAINER_NAME} > /dev/null 2>&1 || docker run -d -p {local_port}:9200 -p 9600:9600 -e \"discovery.type=single-node\" --name {OPENSEARCH_CONTAINER_NAME} opensearchproject/opensearch:1.3.5'\n         ],\n         shell=True,\n     )\n", "issue": "TCP port in `launch_opensearch()` is different from default value in `OpenSearchDocumentStore`\nIn `launch_opensearch()` we are starting an OpenSearch container using the port `9201`. The default port for `OpenSearchDocumentStore` is currently `9200`. I think we should align those two values.\r\n\n", "before_files": [{"content": "# pylint: disable=missing-timeout\n\nimport time\nimport logging\nimport subprocess\nfrom pathlib import Path\n\nimport requests\n\n\nlogger = logging.getLogger(__name__)\nELASTICSEARCH_CONTAINER_NAME = \"elasticsearch\"\nOPENSEARCH_CONTAINER_NAME = \"opensearch\"\nWEAVIATE_CONTAINER_NAME = \"weaviate\"\n\n\ndef launch_es(sleep=15, delete_existing=False):\n    \"\"\"\n    Start an Elasticsearch server via Docker.\n    \"\"\"\n\n    logger.debug(\"Starting Elasticsearch ...\")\n    if delete_existing:\n        _ = subprocess.run([f\"docker rm --force {ELASTICSEARCH_CONTAINER_NAME}\"], shell=True, stdout=subprocess.DEVNULL)\n    status = subprocess.run(\n        [\n            f'docker start {ELASTICSEARCH_CONTAINER_NAME} > /dev/null 2>&1 || docker run -d -p 9200:9200 -e \"discovery.type=single-node\" --name {ELASTICSEARCH_CONTAINER_NAME} elasticsearch:7.9.2'\n        ],\n        shell=True,\n    )\n    if status.returncode:\n        logger.warning(\n            \"Tried to start Elasticsearch through Docker but this failed. \"\n            \"It is likely that there is already an existing Elasticsearch instance running. \"\n        )\n    else:\n        time.sleep(sleep)\n\n\ndef launch_opensearch(sleep=15, delete_existing=False):\n    \"\"\"\n    Start an OpenSearch server via Docker.\n    \"\"\"\n    logger.debug(\"Starting OpenSearch...\")\n    # This line is needed since it is not possible to start a new docker container with the name opensearch if there is a stopped image with the same now\n    # docker rm only succeeds if the container is stopped, not if it is running\n    if delete_existing:\n        _ = subprocess.run([f\"docker rm --force {OPENSEARCH_CONTAINER_NAME}\"], shell=True, stdout=subprocess.DEVNULL)\n    status = subprocess.run(\n        [\n            f'docker start {OPENSEARCH_CONTAINER_NAME} > /dev/null 2>&1 || docker run -d -p 9201:9200 -p 9600:9600 -e \"discovery.type=single-node\" --name {OPENSEARCH_CONTAINER_NAME} opensearchproject/opensearch:1.3.5'\n        ],\n        shell=True,\n    )\n    if status.returncode:\n        logger.warning(\n            \"Tried to start OpenSearch through Docker but this failed. \"\n            \"It is likely that there is already an existing OpenSearch instance running. \"\n        )\n    else:\n        time.sleep(sleep)\n\n\ndef launch_weaviate(sleep=15):\n    \"\"\"\n    Start a Weaviate server via Docker.\n    \"\"\"\n\n    logger.debug(\"Starting Weaviate ...\")\n    status = subprocess.run(\n        [\n            f\"docker start {WEAVIATE_CONTAINER_NAME} > /dev/null 2>&1 || docker run -d -p 8080:8080 --env AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED='true' --env PERSISTENCE_DATA_PATH='/var/lib/weaviate' --name {WEAVIATE_CONTAINER_NAME} semitechnologies/weaviate:latest\"\n        ],\n        shell=True,\n    )\n    if status.returncode:\n        logger.warning(\n            \"Tried to start Weaviate through Docker but this failed. \"\n            \"It is likely that there is already an existing Weaviate instance running. \"\n        )\n    else:\n        time.sleep(sleep)\n\n\ndef stop_container(container_name, delete_container=False):\n    logger.debug(\"Stopping %s...\", container_name)\n    status = subprocess.run([f\"docker stop {container_name}\"], shell=True)\n    if status.returncode:\n        logger.warning(\n            f\"Tried to stop {container_name} but this failed. \"\n            f\"It is likely that there was no Docker container with the name {container_name}\"\n        )\n    if delete_container:\n        status = subprocess.run([f\"docker rm {container_name}\"], shell=True)\n\n\ndef stop_opensearch(delete_container=False):\n    stop_container(OPENSEARCH_CONTAINER_NAME, delete_container)\n\n\ndef stop_elasticsearch(delete_container=False):\n    stop_container(ELASTICSEARCH_CONTAINER_NAME, delete_container)\n\n\ndef stop_weaviate(delete_container=False):\n    stop_container(WEAVIATE_CONTAINER_NAME, delete_container)\n\n\ndef stop_service(document_store, delete_container=False):\n    ds_class = str(type(document_store))\n    if \"OpenSearchDocumentStore\" in ds_class:\n        stop_opensearch(delete_container)\n    elif \"ElasticsearchDocumentStore\" in ds_class:\n        stop_elasticsearch(delete_container)\n    elif \"WeaviateDocumentStore\" in ds_class:\n        stop_weaviate(delete_container)\n    else:\n        logger.warning(\"No support yet for auto stopping the service behind a %s\", type(document_store))\n\n\ndef launch_milvus(sleep=15, delete_existing=False):\n    \"\"\"\n    Start a Milvus server via Docker\n    \"\"\"\n    logger.debug(\"Starting Milvus ...\")\n\n    milvus_dir = Path.home() / \"milvus\"\n    milvus_dir.mkdir(exist_ok=True)\n\n    request = requests.get(\n        \"https://github.com/milvus-io/milvus/releases/download/v2.0.0/milvus-standalone-docker-compose.yml\"\n    )\n    with open(milvus_dir / \"docker-compose.yml\", \"wb\") as f:\n        f.write(request.content)\n\n    status = subprocess.run([\"cd /home/$USER/milvus/ && docker-compose up -d\"], shell=True)\n\n    if status.returncode:\n        logger.warning(\n            \"Tried to start Milvus through Docker but this failed. \"\n            \"It is likely that there is already an existing Milvus instance running. \"\n        )\n    else:\n        time.sleep(sleep)\n", "path": "haystack/utils/doc_store.py"}], "after_files": [{"content": "# pylint: disable=missing-timeout\n\nimport time\nimport logging\nimport subprocess\nfrom pathlib import Path\n\nimport requests\n\n\nlogger = logging.getLogger(__name__)\nELASTICSEARCH_CONTAINER_NAME = \"elasticsearch\"\nOPENSEARCH_CONTAINER_NAME = \"opensearch\"\nWEAVIATE_CONTAINER_NAME = \"weaviate\"\n\n\ndef launch_es(sleep=15, delete_existing=False):\n    \"\"\"\n    Start an Elasticsearch server via Docker.\n    \"\"\"\n\n    logger.debug(\"Starting Elasticsearch ...\")\n    if delete_existing:\n        _ = subprocess.run([f\"docker rm --force {ELASTICSEARCH_CONTAINER_NAME}\"], shell=True, stdout=subprocess.DEVNULL)\n    status = subprocess.run(\n        [\n            f'docker start {ELASTICSEARCH_CONTAINER_NAME} > /dev/null 2>&1 || docker run -d -p 9200:9200 -e \"discovery.type=single-node\" --name {ELASTICSEARCH_CONTAINER_NAME} elasticsearch:7.9.2'\n        ],\n        shell=True,\n    )\n    if status.returncode:\n        logger.warning(\n            \"Tried to start Elasticsearch through Docker but this failed. \"\n            \"It is likely that there is already an existing Elasticsearch instance running. \"\n        )\n    else:\n        time.sleep(sleep)\n\n\ndef launch_opensearch(sleep=15, delete_existing=False, local_port=9200):\n    \"\"\"\n    Start an OpenSearch server via Docker.\n    \"\"\"\n    logger.debug(\"Starting OpenSearch...\")\n    # This line is needed since it is not possible to start a new docker container with the name opensearch if there is a stopped image with the same now\n    # docker rm only succeeds if the container is stopped, not if it is running\n    if delete_existing:\n        _ = subprocess.run([f\"docker rm --force {OPENSEARCH_CONTAINER_NAME}\"], shell=True, stdout=subprocess.DEVNULL)\n    status = subprocess.run(\n        [\n            f'docker start {OPENSEARCH_CONTAINER_NAME} > /dev/null 2>&1 || docker run -d -p {local_port}:9200 -p 9600:9600 -e \"discovery.type=single-node\" --name {OPENSEARCH_CONTAINER_NAME} opensearchproject/opensearch:1.3.5'\n        ],\n        shell=True,\n    )\n    if status.returncode:\n        logger.warning(\n            \"Tried to start OpenSearch through Docker but this failed. \"\n            \"It is likely that there is already an existing OpenSearch instance running. \"\n        )\n    else:\n        time.sleep(sleep)\n\n\ndef launch_weaviate(sleep=15):\n    \"\"\"\n    Start a Weaviate server via Docker.\n    \"\"\"\n\n    logger.debug(\"Starting Weaviate ...\")\n    status = subprocess.run(\n        [\n            f\"docker start {WEAVIATE_CONTAINER_NAME} > /dev/null 2>&1 || docker run -d -p 8080:8080 --env AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED='true' --env PERSISTENCE_DATA_PATH='/var/lib/weaviate' --name {WEAVIATE_CONTAINER_NAME} semitechnologies/weaviate:latest\"\n        ],\n        shell=True,\n    )\n    if status.returncode:\n        logger.warning(\n            \"Tried to start Weaviate through Docker but this failed. \"\n            \"It is likely that there is already an existing Weaviate instance running. \"\n        )\n    else:\n        time.sleep(sleep)\n\n\ndef stop_container(container_name, delete_container=False):\n    logger.debug(\"Stopping %s...\", container_name)\n    status = subprocess.run([f\"docker stop {container_name}\"], shell=True)\n    if status.returncode:\n        logger.warning(\n            f\"Tried to stop {container_name} but this failed. \"\n            f\"It is likely that there was no Docker container with the name {container_name}\"\n        )\n    if delete_container:\n        status = subprocess.run([f\"docker rm {container_name}\"], shell=True)\n\n\ndef stop_opensearch(delete_container=False):\n    stop_container(OPENSEARCH_CONTAINER_NAME, delete_container)\n\n\ndef stop_elasticsearch(delete_container=False):\n    stop_container(ELASTICSEARCH_CONTAINER_NAME, delete_container)\n\n\ndef stop_weaviate(delete_container=False):\n    stop_container(WEAVIATE_CONTAINER_NAME, delete_container)\n\n\ndef stop_service(document_store, delete_container=False):\n    ds_class = str(type(document_store))\n    if \"OpenSearchDocumentStore\" in ds_class:\n        stop_opensearch(delete_container)\n    elif \"ElasticsearchDocumentStore\" in ds_class:\n        stop_elasticsearch(delete_container)\n    elif \"WeaviateDocumentStore\" in ds_class:\n        stop_weaviate(delete_container)\n    else:\n        logger.warning(\"No support yet for auto stopping the service behind a %s\", type(document_store))\n\n\ndef launch_milvus(sleep=15, delete_existing=False):\n    \"\"\"\n    Start a Milvus server via Docker\n    \"\"\"\n    logger.debug(\"Starting Milvus ...\")\n\n    milvus_dir = Path.home() / \"milvus\"\n    milvus_dir.mkdir(exist_ok=True)\n\n    request = requests.get(\n        \"https://github.com/milvus-io/milvus/releases/download/v2.0.0/milvus-standalone-docker-compose.yml\"\n    )\n    with open(milvus_dir / \"docker-compose.yml\", \"wb\") as f:\n        f.write(request.content)\n\n    status = subprocess.run([\"cd /home/$USER/milvus/ && docker-compose up -d\"], shell=True)\n\n    if status.returncode:\n        logger.warning(\n            \"Tried to start Milvus through Docker but this failed. \"\n            \"It is likely that there is already an existing Milvus instance running. \"\n        )\n    else:\n        time.sleep(sleep)\n", "path": "haystack/utils/doc_store.py"}]}