Skip to content

Commit

Permalink
improved doc example
Browse files Browse the repository at this point in the history
  • Loading branch information
Yifan Zhang committed Dec 13, 2021
1 parent 58b0602 commit 0b0255b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,19 @@ can produce one output for each input, or no output.

.. code-block:: python
>>> from pydantic import BaseModel
>>> from pipeline import Processor as Worker, ProcessorSettings as Settings
>>>
>>> class Input(BaseModel):
... key: int
... temperature: float
>>>
>>> class Output(BaseModel):
... key: int
... processed: bool
... is_hot: bool
>>>
>>> class MyProcessor(Worker):
... def process(self, input):
... return Output(key=input.key, processed=True)
... def process(self, content, key):
... is_hot = (content.temperature > 25)
... return Output(is_hot=is_hot)
>>>
>>> settings = Settings(name='processor', version='0.1.0', description='')
>>> processor = MyProcessor(settings, input_class=Input, output_class=Output)
Expand Down

0 comments on commit 0b0255b

Please sign in to comment.