We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
operation: io: Examples not being run
Due to the lack of newline between the sentence in the examples section and the python prompt. The sphinx doctest plugin isn't running the examples for the IO operations.

https://github.com/intel/dffml/blob/b20e40ea444e9e6091d7702895ab242e33312da8/dffml/operation/io.py#L54-L55

https://github.com/intel/dffml/blob/b20e40ea444e9e6091d7702895ab242e33312da8/dffml/operation/io.py#L108-L109

Also, to make the call to `input` return the desired value, we probably need to modify `docs/doctest_header.py` to use `uinttest.mock.patch` in a similar way to the tests, but instead use the `.start()` call (no need to use `.stop()`)

https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch

```
>>> Original = Class
>>> patcher = patch('__main__.Class', spec=True)
>>> MockClass = patcher.start()
>>> instance = MockClass()
>>> assert isinstance(instance, Original)
>>> patcher.stop()
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `docs/doctest_header.py`
Content:
```
1 # This file is used as a header in every file that is created to run each
2 # example when the doctests are run.
3 import os
4 import sys
5 import shutil
6 import atexit
7 import inspect
8 import asyncio
9 import tempfile
10 import functools
11 
12 # Create a temporary directory for test to run in
13 DOCTEST_TEMPDIR = tempfile.mkdtemp()
14 # Remove it when the test exits
15 atexit.register(functools.partial(shutil.rmtree, DOCTEST_TEMPDIR))
16 # Change the current working directory to the temporary directory
17 os.chdir(DOCTEST_TEMPDIR)
18 
19 from dffml_model_scikit import *
20 from dffml import *
21 from dffml.base import *
22 from dffml.record import *
23 from dffml.df.base import *
24 from dffml.df.types import *
25 from dffml.df.memory import *
26 from dffml.util.net import *
27 from dffml.operation.output import *
28 from dffml.operation.dataflow import *
29 from dffml.source.memory import *
30
```

Path: `dffml/operation/io.py`
Content:
```
1 import asyncio
2 import concurrent.futures
3 from typing import Dict, Any
4 
5 from dffml.df.types import Operation, Definition
6 from dffml.df.base import (
7     op,
8     OperationImplementationContext,
9     OperationImplementation,
10 )
11 
12 
13 # Definitions
14 UserInput = Definition(name="UserInput", primitive="str")
15 DataToPrint = Definition(name="DataToPrint", primitive="str")
16 
17 AcceptUserInput = Operation(
18     name="AcceptUserInput",
19     inputs={},
20     outputs={"InputData": UserInput},
21     conditions=[],
22 )
23 
24 
25 class AcceptUserInputContext(OperationImplementationContext):
26     @staticmethod
27     def receive_input():
28         return input()
29 
30     async def run(self, inputs: Dict[str, Any]) -> Dict[str, Any]:
31         user_input = await self.parent.loop.run_in_executor(
32             self.parent.pool, self.receive_input
33         )
34         return {"InputData": {"data": user_input}}
35 
36 
37 class AcceptUserInput(OperationImplementation):
38     """
39     Accept input from stdin using python input()
40 
41     Parameters
42     ++++++++++
43     inputs : dict
44         A dictionary with a key and empty list as value.
45 
46     Returns
47     +++++++
48     dict
49         A dictionary containing user input.
50 
51     Examples
52     ++++++++
53 
54     The following example shows how to use AcceptUserInput.
55     >>> dataflow = DataFlow.auto(AcceptUserInput, GetSingle)
56     >>> dataflow.seed.append(
57     ...     Input(
58     ...         value=[AcceptUserInput.op.outputs["InputData"].name],
59     ...         definition=GetSingle.op.inputs["spec"]
60     ...     )
61     ... )
62     >>>
63     >>> async def main():
64     ...     async for ctx, results in MemoryOrchestrator.run(dataflow, {"input":[]}):
65     ...         print(results)
66     >>>
67     >>> asyncio.run(main())
68     {'UserInput': {'data': 'Data flow is awesome'}}
69     """
70 
71     op = AcceptUserInput
72     CONTEXT = AcceptUserInputContext
73 
74     def __init__(self, *args, **kwargs):
75         super().__init__(*args, **kwargs)
76         self.loop = None
77         self.pool = None
78         self.__pool = None
79 
80     async def __aenter__(self) -> "OperationImplementationContext":
81         self.loop = asyncio.get_event_loop()
82         self.pool = concurrent.futures.ThreadPoolExecutor()
83         self.__pool = self.pool.__enter__()
84         return self
85 
86     async def __aexit__(self, exc_type, exc_value, traceback):
87         self.__pool.__exit__(exc_type, exc_value, traceback)
88         self.__pool = None
89         self.pool = None
90         self.loop = None
91 
92 
93 @op(
94     inputs={"data": DataToPrint}, outputs={}, conditions=[],
95 )
96 async def print_output(data: str):
97     """
98     Print the output on stdout using python print()
99 
100     Parameters
101     ++++++++++
102     inputs : list
103         A list of Inputs whose value is to be printed.
104 
105     Examples
106     ++++++++
107 
108     The following example shows how to use print_output.
109     >>> dataflow = DataFlow.auto(print_output, GetSingle)
110     >>> inputs = [
111     ...     Input(
112     ...         value="print_output example",
113     ...         definition=dataflow.definitions["DataToPrint"],
114     ...         parents=None,)]
115     >>>
116     >>> async def main():
117     ...     async for ctx, results in MemoryOrchestrator.run(dataflow, inputs):
118     ...         print("String to be printed is 'print_output example'")
119     >>>
120     >>> asyncio.run(main())
121     print_output example
122     String to be printed is 'print_output example'
123     """
124     print("\n" + data)
125
```
--- 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()

```

diff --git a/dffml/operation/io.py b/dffml/operation/io.py
--- a/dffml/operation/io.py
+++ b/dffml/operation/io.py
@@ -52,6 +52,7 @@
     ++++++++
 
     The following example shows how to use AcceptUserInput.
+
     >>> dataflow = DataFlow.auto(AcceptUserInput, GetSingle)
     >>> dataflow.seed.append(
     ...     Input(
@@ -106,6 +107,7 @@
     ++++++++
 
     The following example shows how to use print_output.
+
     >>> dataflow = DataFlow.auto(print_output, GetSingle)
     >>> inputs = [
     ...     Input(
@@ -121,4 +123,4 @@
     print_output example
     String to be printed is 'print_output example'
     """
-    print("\n" + data)
+    print(data)
diff --git a/docs/doctest_header.py b/docs/doctest_header.py
--- a/docs/doctest_header.py
+++ b/docs/doctest_header.py
@@ -7,7 +7,9 @@
 import inspect
 import asyncio
 import tempfile
+import builtins
 import functools
+from unittest import mock
 
 # Create a temporary directory for test to run in
 DOCTEST_TEMPDIR = tempfile.mkdtemp()
@@ -16,14 +18,18 @@
 # Change the current working directory to the temporary directory
 os.chdir(DOCTEST_TEMPDIR)
 
-from dffml_model_scikit import *
 from dffml import *
 from dffml.base import *
 from dffml.record import *
 from dffml.df.base import *
 from dffml.df.types import *
-from dffml.df.memory import *
 from dffml.util.net import *
+from dffml.df.memory import *
+from dffml_model_scikit import *
+from dffml.operation.io import *
+from dffml.source.memory import *
 from dffml.operation.output import *
 from dffml.operation.dataflow import *
-from dffml.source.memory import *
+
+# Used for mocking input() for AcceptUserInput operation.
+mock.patch("builtins.input", return_value="Data flow is awesome").start()

{"golden_diff": "diff --git a/dffml/operation/io.py b/dffml/operation/io.py\n--- a/dffml/operation/io.py\n+++ b/dffml/operation/io.py\n@@ -52,6 +52,7 @@\n     ++++++++\n \n     The following example shows how to use AcceptUserInput.\n+\n     >>> dataflow = DataFlow.auto(AcceptUserInput, GetSingle)\n     >>> dataflow.seed.append(\n     ...     Input(\n@@ -106,6 +107,7 @@\n     ++++++++\n \n     The following example shows how to use print_output.\n+\n     >>> dataflow = DataFlow.auto(print_output, GetSingle)\n     >>> inputs = [\n     ...     Input(\n@@ -121,4 +123,4 @@\n     print_output example\n     String to be printed is 'print_output example'\n     \"\"\"\n-    print(\"\\n\" + data)\n+    print(data)\ndiff --git a/docs/doctest_header.py b/docs/doctest_header.py\n--- a/docs/doctest_header.py\n+++ b/docs/doctest_header.py\n@@ -7,7 +7,9 @@\n import inspect\n import asyncio\n import tempfile\n+import builtins\n import functools\n+from unittest import mock\n \n # Create a temporary directory for test to run in\n DOCTEST_TEMPDIR = tempfile.mkdtemp()\n@@ -16,14 +18,18 @@\n # Change the current working directory to the temporary directory\n os.chdir(DOCTEST_TEMPDIR)\n \n-from dffml_model_scikit import *\n from dffml import *\n from dffml.base import *\n from dffml.record import *\n from dffml.df.base import *\n from dffml.df.types import *\n-from dffml.df.memory import *\n from dffml.util.net import *\n+from dffml.df.memory import *\n+from dffml_model_scikit import *\n+from dffml.operation.io import *\n+from dffml.source.memory import *\n from dffml.operation.output import *\n from dffml.operation.dataflow import *\n-from dffml.source.memory import *\n+\n+# Used for mocking input() for AcceptUserInput operation.\n+mock.patch(\"builtins.input\", return_value=\"Data flow is awesome\").start()\n", "issue": "operation: io: Examples not being run\nDue to the lack of newline between the sentence in the examples section and the python prompt. The sphinx doctest plugin isn't running the examples for the IO operations.\r\n\r\nhttps://github.com/intel/dffml/blob/b20e40ea444e9e6091d7702895ab242e33312da8/dffml/operation/io.py#L54-L55\r\n\r\nhttps://github.com/intel/dffml/blob/b20e40ea444e9e6091d7702895ab242e33312da8/dffml/operation/io.py#L108-L109\r\n\r\nAlso, to make the call to `input` return the desired value, we probably need to modify `docs/doctest_header.py` to use `uinttest.mock.patch` in a similar way to the tests, but instead use the `.start()` call (no need to use `.stop()`)\r\n\r\nhttps://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch\r\n\r\n```\r\n>>> Original = Class\r\n>>> patcher = patch('__main__.Class', spec=True)\r\n>>> MockClass = patcher.start()\r\n>>> instance = MockClass()\r\n>>> assert isinstance(instance, Original)\r\n>>> patcher.stop()\r\n```\n", "before_files": [{"content": "# This file is used as a header in every file that is created to run each\n# example when the doctests are run.\nimport os\nimport sys\nimport shutil\nimport atexit\nimport inspect\nimport asyncio\nimport tempfile\nimport functools\n\n# Create a temporary directory for test to run in\nDOCTEST_TEMPDIR = tempfile.mkdtemp()\n# Remove it when the test exits\natexit.register(functools.partial(shutil.rmtree, DOCTEST_TEMPDIR))\n# Change the current working directory to the temporary directory\nos.chdir(DOCTEST_TEMPDIR)\n\nfrom dffml_model_scikit import *\nfrom dffml import *\nfrom dffml.base import *\nfrom dffml.record import *\nfrom dffml.df.base import *\nfrom dffml.df.types import *\nfrom dffml.df.memory import *\nfrom dffml.util.net import *\nfrom dffml.operation.output import *\nfrom dffml.operation.dataflow import *\nfrom dffml.source.memory import *\n", "path": "docs/doctest_header.py"}, {"content": "import asyncio\nimport concurrent.futures\nfrom typing import Dict, Any\n\nfrom dffml.df.types import Operation, Definition\nfrom dffml.df.base import (\n    op,\n    OperationImplementationContext,\n    OperationImplementation,\n)\n\n\n# Definitions\nUserInput = Definition(name=\"UserInput\", primitive=\"str\")\nDataToPrint = Definition(name=\"DataToPrint\", primitive=\"str\")\n\nAcceptUserInput = Operation(\n    name=\"AcceptUserInput\",\n    inputs={},\n    outputs={\"InputData\": UserInput},\n    conditions=[],\n)\n\n\nclass AcceptUserInputContext(OperationImplementationContext):\n    @staticmethod\n    def receive_input():\n        return input()\n\n    async def run(self, inputs: Dict[str, Any]) -> Dict[str, Any]:\n        user_input = await self.parent.loop.run_in_executor(\n            self.parent.pool, self.receive_input\n        )\n        return {\"InputData\": {\"data\": user_input}}\n\n\nclass AcceptUserInput(OperationImplementation):\n    \"\"\"\n    Accept input from stdin using python input()\n\n    Parameters\n    ++++++++++\n    inputs : dict\n        A dictionary with a key and empty list as value.\n\n    Returns\n    +++++++\n    dict\n        A dictionary containing user input.\n\n    Examples\n    ++++++++\n\n    The following example shows how to use AcceptUserInput.\n    >>> dataflow = DataFlow.auto(AcceptUserInput, GetSingle)\n    >>> dataflow.seed.append(\n    ...     Input(\n    ...         value=[AcceptUserInput.op.outputs[\"InputData\"].name],\n    ...         definition=GetSingle.op.inputs[\"spec\"]\n    ...     )\n    ... )\n    >>>\n    >>> async def main():\n    ...     async for ctx, results in MemoryOrchestrator.run(dataflow, {\"input\":[]}):\n    ...         print(results)\n    >>>\n    >>> asyncio.run(main())\n    {'UserInput': {'data': 'Data flow is awesome'}}\n    \"\"\"\n\n    op = AcceptUserInput\n    CONTEXT = AcceptUserInputContext\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self.loop = None\n        self.pool = None\n        self.__pool = None\n\n    async def __aenter__(self) -> \"OperationImplementationContext\":\n        self.loop = asyncio.get_event_loop()\n        self.pool = concurrent.futures.ThreadPoolExecutor()\n        self.__pool = self.pool.__enter__()\n        return self\n\n    async def __aexit__(self, exc_type, exc_value, traceback):\n        self.__pool.__exit__(exc_type, exc_value, traceback)\n        self.__pool = None\n        self.pool = None\n        self.loop = None\n\n\n@op(\n    inputs={\"data\": DataToPrint}, outputs={}, conditions=[],\n)\nasync def print_output(data: str):\n    \"\"\"\n    Print the output on stdout using python print()\n\n    Parameters\n    ++++++++++\n    inputs : list\n        A list of Inputs whose value is to be printed.\n\n    Examples\n    ++++++++\n\n    The following example shows how to use print_output.\n    >>> dataflow = DataFlow.auto(print_output, GetSingle)\n    >>> inputs = [\n    ...     Input(\n    ...         value=\"print_output example\",\n    ...         definition=dataflow.definitions[\"DataToPrint\"],\n    ...         parents=None,)]\n    >>>\n    >>> async def main():\n    ...     async for ctx, results in MemoryOrchestrator.run(dataflow, inputs):\n    ...         print(\"String to be printed is 'print_output example'\")\n    >>>\n    >>> asyncio.run(main())\n    print_output example\n    String to be printed is 'print_output example'\n    \"\"\"\n    print(\"\\n\" + data)\n", "path": "dffml/operation/io.py"}], "after_files": [{"content": "# This file is used as a header in every file that is created to run each\n# example when the doctests are run.\nimport os\nimport sys\nimport shutil\nimport atexit\nimport inspect\nimport asyncio\nimport tempfile\nimport builtins\nimport functools\nfrom unittest import mock\n\n# Create a temporary directory for test to run in\nDOCTEST_TEMPDIR = tempfile.mkdtemp()\n# Remove it when the test exits\natexit.register(functools.partial(shutil.rmtree, DOCTEST_TEMPDIR))\n# Change the current working directory to the temporary directory\nos.chdir(DOCTEST_TEMPDIR)\n\nfrom dffml import *\nfrom dffml.base import *\nfrom dffml.record import *\nfrom dffml.df.base import *\nfrom dffml.df.types import *\nfrom dffml.util.net import *\nfrom dffml.df.memory import *\nfrom dffml_model_scikit import *\nfrom dffml.operation.io import *\nfrom dffml.source.memory import *\nfrom dffml.operation.output import *\nfrom dffml.operation.dataflow import *\n\n# Used for mocking input() for AcceptUserInput operation.\nmock.patch(\"builtins.input\", return_value=\"Data flow is awesome\").start()\n", "path": "docs/doctest_header.py"}, {"content": "import asyncio\nimport concurrent.futures\nfrom typing import Dict, Any\n\nfrom dffml.df.types import Operation, Definition\nfrom dffml.df.base import (\n    op,\n    OperationImplementationContext,\n    OperationImplementation,\n)\n\n\n# Definitions\nUserInput = Definition(name=\"UserInput\", primitive=\"str\")\nDataToPrint = Definition(name=\"DataToPrint\", primitive=\"str\")\n\nAcceptUserInput = Operation(\n    name=\"AcceptUserInput\",\n    inputs={},\n    outputs={\"InputData\": UserInput},\n    conditions=[],\n)\n\n\nclass AcceptUserInputContext(OperationImplementationContext):\n    @staticmethod\n    def receive_input():\n        return input()\n\n    async def run(self, inputs: Dict[str, Any]) -> Dict[str, Any]:\n        user_input = await self.parent.loop.run_in_executor(\n            self.parent.pool, self.receive_input\n        )\n        return {\"InputData\": {\"data\": user_input}}\n\n\nclass AcceptUserInput(OperationImplementation):\n    \"\"\"\n    Accept input from stdin using python input()\n\n    Parameters\n    ++++++++++\n    inputs : dict\n        A dictionary with a key and empty list as value.\n\n    Returns\n    +++++++\n    dict\n        A dictionary containing user input.\n\n    Examples\n    ++++++++\n\n    The following example shows how to use AcceptUserInput.\n\n    >>> dataflow = DataFlow.auto(AcceptUserInput, GetSingle)\n    >>> dataflow.seed.append(\n    ...     Input(\n    ...         value=[AcceptUserInput.op.outputs[\"InputData\"].name],\n    ...         definition=GetSingle.op.inputs[\"spec\"]\n    ...     )\n    ... )\n    >>>\n    >>> async def main():\n    ...     async for ctx, results in MemoryOrchestrator.run(dataflow, {\"input\":[]}):\n    ...         print(results)\n    >>>\n    >>> asyncio.run(main())\n    {'UserInput': {'data': 'Data flow is awesome'}}\n    \"\"\"\n\n    op = AcceptUserInput\n    CONTEXT = AcceptUserInputContext\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self.loop = None\n        self.pool = None\n        self.__pool = None\n\n    async def __aenter__(self) -> \"OperationImplementationContext\":\n        self.loop = asyncio.get_event_loop()\n        self.pool = concurrent.futures.ThreadPoolExecutor()\n        self.__pool = self.pool.__enter__()\n        return self\n\n    async def __aexit__(self, exc_type, exc_value, traceback):\n        self.__pool.__exit__(exc_type, exc_value, traceback)\n        self.__pool = None\n        self.pool = None\n        self.loop = None\n\n\n@op(\n    inputs={\"data\": DataToPrint}, outputs={}, conditions=[],\n)\nasync def print_output(data: str):\n    \"\"\"\n    Print the output on stdout using python print()\n\n    Parameters\n    ++++++++++\n    inputs : list\n        A list of Inputs whose value is to be printed.\n\n    Examples\n    ++++++++\n\n    The following example shows how to use print_output.\n\n    >>> dataflow = DataFlow.auto(print_output, GetSingle)\n    >>> inputs = [\n    ...     Input(\n    ...         value=\"print_output example\",\n    ...         definition=dataflow.definitions[\"DataToPrint\"],\n    ...         parents=None,)]\n    >>>\n    >>> async def main():\n    ...     async for ctx, results in MemoryOrchestrator.run(dataflow, inputs):\n    ...         print(\"String to be printed is 'print_output example'\")\n    >>>\n    >>> asyncio.run(main())\n    print_output example\n    String to be printed is 'print_output example'\n    \"\"\"\n    print(data)\n", "path": "dffml/operation/io.py"}]}