prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  docs: operations: model_predict example usage
  We need a doctestable example for the `model_predict`/`dffml.model.predict` operation.
  
  References: https://intel.github.io/dffml/master/plugins/dffml_operation.html#dffml-model-predict
  
  </issue>
  <code>
  [start of dffml/operation/model.py]
  1 from typing import Dict, Any
  2 
  3 from ..record import Record
  4 from ..base import config
  5 from ..model import Model
  6 from ..df.types import Definition
  7 from ..df.base import op
  8 
  9 
  10 @config
  11 class ModelPredictConfig:
  12     model: Model
  13 
  14     def __post_init__(self):
  15         if not isinstance(self.model, Model):
  16             raise TypeError(
  17                 "model should be an instance of `dffml.model.model.Model`"
  18             )
  19 
  20 
  21 @op(
  22     name="dffml.model.predict",
  23     inputs={
  24         "features": Definition(
  25             name="record_features", primitive="Dict[str, Any]"
  26         )
  27     },
  28     outputs={
  29         "prediction": Definition(
  30             name="model_predictions", primitive="Dict[str, Any]"
  31         )
  32     },
  33     config_cls=ModelPredictConfig,
  34     imp_enter={"model": (lambda self: self.config.model)},
  35     ctx_enter={"mctx": (lambda self: self.parent.model())},
  36 )
  37 async def model_predict(self, features: Dict[str, Any]) -> Dict[str, Any]:
  38     async def records():
  39         yield Record("", data={"features": features})
  40 
  41     async for record in self.mctx.predict(records()):
  42         return {"prediction": record.predictions()}
  43
  [end of dffml/operation/model.py]
  [start of docs/doctest_header.py]
  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 builtins
  11 import functools
  12 from unittest import mock
  13 
  14 # Create a temporary directory for test to run in
  15 DOCTEST_TEMPDIR = tempfile.mkdtemp()
  16 # Remove it when the test exits
  17 atexit.register(functools.partial(shutil.rmtree, DOCTEST_TEMPDIR))
  18 # Change the current working directory to the temporary directory
  19 os.chdir(DOCTEST_TEMPDIR)
  20 
  21 from dffml import *
  22 from dffml.base import *
  23 from dffml.record import *
  24 from dffml.df.base import *
  25 from dffml.df.types import *
  26 from dffml.util.net import *
  27 from dffml.df.memory import *
  28 from dffml_model_scikit import *
  29 from dffml.operation.io import *
  30 from dffml.source.memory import *
  31 from dffml.operation.output import *
  32 from dffml.operation.dataflow import *
  33 from dffml.operation.preprocess import *
  34 from dffml.operation.mapping import *
  35 
  36 # Used for mocking input() for AcceptUserInput operation.
  37 mock.patch("builtins.input", return_value="Data flow is awesome").start()
  38
  [end of docs/doctest_header.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/dffml/operation/model.py b/dffml/operation/model.py
  --- a/dffml/operation/model.py
  +++ b/dffml/operation/model.py
  @@ -35,6 +35,62 @@
       ctx_enter={"mctx": (lambda self: self.parent.model())},
   )
   async def model_predict(self, features: Dict[str, Any]) -> Dict[str, Any]:
  +    """
  +    Predict using dffml models.
  +
  +    Parameters
  +    ++++++++++
  +    features : dict
  +        A dictionary contaning feature name and feature value.
  +
  +    Returns
  +    +++++++
  +    dict
  +        A dictionary containing prediction.
  +
  +    Examples
  +    ++++++++
  +
  +    The following example shows how to use model_predict.
  +
  +    >>> slr_model = SLRModel(
  +    ...     features=Features(DefFeature("Years", int, 1)),
  +    ...     predict=DefFeature("Salary", int, 1),
  +    ... )
  +    >>> dataflow = DataFlow(
  +    ...     operations={
  +    ...         "prediction_using_model": model_predict,
  +    ...         "get_single": GetSingle,
  +    ...     },
  +    ...     configs={"prediction_using_model": ModelPredictConfig(model=slr_model)},
  +    ... )
  +    >>> dataflow.seed.append(
  +    ...     Input(
  +    ...         value=[model_predict.op.outputs["prediction"].name],
  +    ...         definition=GetSingle.op.inputs["spec"],
  +    ...     )
  +    ... )
  +    >>>
  +    >>> async def main():
  +    ...     await train(
  +    ...         slr_model,
  +    ...         {"Years": 0, "Salary": 10},
  +    ...         {"Years": 1, "Salary": 20},
  +    ...         {"Years": 2, "Salary": 30},
  +    ...         {"Years": 3, "Salary": 40},
  +    ...     )
  +    ...     inputs = [
  +    ...        Input(
  +    ...            value={"Years": 4}, definition=model_predict.op.inputs["features"],
  +    ...        )
  +    ...     ]
  +    ...     async for ctx, results in MemoryOrchestrator.run(dataflow, inputs):
  +    ...         print(results)
  +    >>>
  +    >>> asyncio.run(main())
  +    {'model_predictions': {'Salary': {'confidence': 1.0, 'value': 50.0}}}
  +    """
  +
       async def records():
           yield Record("", data={"features": features})
   
  diff --git a/docs/doctest_header.py b/docs/doctest_header.py
  --- a/docs/doctest_header.py
  +++ b/docs/doctest_header.py
  @@ -25,9 +25,11 @@
   from dffml.df.types import *
   from dffml.util.net import *
   from dffml.df.memory import *
  +from dffml.model.slr import *
   from dffml_model_scikit import *
   from dffml.operation.io import *
   from dffml.source.memory import *
  +from dffml.operation.model import *
   from dffml.operation.output import *
   from dffml.operation.dataflow import *
   from dffml.operation.preprocess import *
  
verification_info: {"golden_diff": "diff --git a/dffml/operation/model.py b/dffml/operation/model.py\n--- a/dffml/operation/model.py\n+++ b/dffml/operation/model.py\n@@ -35,6 +35,62 @@\n     ctx_enter={\"mctx\": (lambda self: self.parent.model())},\n )\n async def model_predict(self, features: Dict[str, Any]) -> Dict[str, Any]:\n+    \"\"\"\n+    Predict using dffml models.\n+\n+    Parameters\n+    ++++++++++\n+    features : dict\n+        A dictionary contaning feature name and feature value.\n+\n+    Returns\n+    +++++++\n+    dict\n+        A dictionary containing prediction.\n+\n+    Examples\n+    ++++++++\n+\n+    The following example shows how to use model_predict.\n+\n+    >>> slr_model = SLRModel(\n+    ...     features=Features(DefFeature(\"Years\", int, 1)),\n+    ...     predict=DefFeature(\"Salary\", int, 1),\n+    ... )\n+    >>> dataflow = DataFlow(\n+    ...     operations={\n+    ...         \"prediction_using_model\": model_predict,\n+    ...         \"get_single\": GetSingle,\n+    ...     },\n+    ...     configs={\"prediction_using_model\": ModelPredictConfig(model=slr_model)},\n+    ... )\n+    >>> dataflow.seed.append(\n+    ...     Input(\n+    ...         value=[model_predict.op.outputs[\"prediction\"].name],\n+    ...         definition=GetSingle.op.inputs[\"spec\"],\n+    ...     )\n+    ... )\n+    >>>\n+    >>> async def main():\n+    ...     await train(\n+    ...         slr_model,\n+    ...         {\"Years\": 0, \"Salary\": 10},\n+    ...         {\"Years\": 1, \"Salary\": 20},\n+    ...         {\"Years\": 2, \"Salary\": 30},\n+    ...         {\"Years\": 3, \"Salary\": 40},\n+    ...     )\n+    ...     inputs = [\n+    ...        Input(\n+    ...            value={\"Years\": 4}, definition=model_predict.op.inputs[\"features\"],\n+    ...        )\n+    ...     ]\n+    ...     async for ctx, results in MemoryOrchestrator.run(dataflow, inputs):\n+    ...         print(results)\n+    >>>\n+    >>> asyncio.run(main())\n+    {'model_predictions': {'Salary': {'confidence': 1.0, 'value': 50.0}}}\n+    \"\"\"\n+\n     async def records():\n         yield Record(\"\", data={\"features\": features})\n \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@@ -25,9 +25,11 @@\n from dffml.df.types import *\n from dffml.util.net import *\n from dffml.df.memory import *\n+from dffml.model.slr import *\n from dffml_model_scikit import *\n from dffml.operation.io import *\n from dffml.source.memory import *\n+from dffml.operation.model import *\n from dffml.operation.output import *\n from dffml.operation.dataflow import *\n from dffml.operation.preprocess import *\n", "issue": "docs: operations: model_predict example usage\nWe need a doctestable example for the `model_predict`/`dffml.model.predict` operation.\r\n\r\nReferences: https://intel.github.io/dffml/master/plugins/dffml_operation.html#dffml-model-predict\n", "before_files": [{"content": "from typing import Dict, Any\n\nfrom ..record import Record\nfrom ..base import config\nfrom ..model import Model\nfrom ..df.types import Definition\nfrom ..df.base import op\n\n\n@config\nclass ModelPredictConfig:\n    model: Model\n\n    def __post_init__(self):\n        if not isinstance(self.model, Model):\n            raise TypeError(\n                \"model should be an instance of `dffml.model.model.Model`\"\n            )\n\n\n@op(\n    name=\"dffml.model.predict\",\n    inputs={\n        \"features\": Definition(\n            name=\"record_features\", primitive=\"Dict[str, Any]\"\n        )\n    },\n    outputs={\n        \"prediction\": Definition(\n            name=\"model_predictions\", primitive=\"Dict[str, Any]\"\n        )\n    },\n    config_cls=ModelPredictConfig,\n    imp_enter={\"model\": (lambda self: self.config.model)},\n    ctx_enter={\"mctx\": (lambda self: self.parent.model())},\n)\nasync def model_predict(self, features: Dict[str, Any]) -> Dict[str, Any]:\n    async def records():\n        yield Record(\"\", data={\"features\": features})\n\n    async for record in self.mctx.predict(records()):\n        return {\"prediction\": record.predictions()}\n", "path": "dffml/operation/model.py"}, {"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 *\nfrom dffml.operation.preprocess import *\nfrom dffml.operation.mapping 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"}]}