Examples#
Class#
from ewokscore import Task
class MyTask(
Task,
input_names=["a", "b", "c"],
optional_input_names=["d", "e"],
output_names=["result", "error"],
):
"""My task documentation"""
def run(self):
pass
.. ewokstasks:: ewokssphinx.tests.dummy_tasks
:task-type: class
MyTask#
My task documentation
- Identifier:
ewokssphinx.tests.dummy_tasks.MyTask- Task type:
- class
- Inputs:
- a*
- b*
- c*
- d
- e
- Outputs:
- error
- result
Class with pydantic model#
from ewokscore import Task
from ewokscore.model import BaseInputModel
from ewokscore.model import BaseOutputModel
from pydantic import Field
class Inputs(BaseInputModel):
planet: str = "Earth"
latitude: int = Field(examples=[-90, 0, 90])
longitude: float = Field(
description="Longitude of the GPS point. **In degrees.**", examples=[-90, 0, 90]
)
class Outputs(BaseOutputModel):
location: str = Field(
..., description="Name of the closest city or location to the given coordinates"
)
error: Exception | None
class FindLocation(
Task,
input_model=Inputs,
output_model=Outputs,
):
"""Finds a location given the GPS coordinates"""
def run(self):
pass
.. ewokstasks:: ewokssphinx.tests.dummy_tasks_pydantic
:task-type: class
FindLocation#
Finds a location given the GPS coordinates
- Identifier:
ewokssphinx.tests.dummy_tasks_pydantic.FindLocation- Task type:
- class
- Inputs:
- planet :
str= Earth - latitude* :
int - Examples:
- -90
- 0
- 90
- longitude* :
float Longitude of the GPS point. In degrees.
Examples:- -90
- 0
- 90
- planet :
- Outputs:
- location :
str Name of the closest city or location to the given coordinates
- error :
Exception | None
- location :
Tip
To use attribute docstrings instead of description to document the fields, set the use_attribute_docstrings of the ConfigDict to True
from ewokscore.model import BaseInputModel
from pydantic import ConfigDict
class Inputs(BaseInputModel):
model_config = ConfigDict(use_attribute_docstrings=True)
planet: str = "Earth"
"""The planet on which the search will be made"""
...
Method#
def my_other_task(f, g, h=None):
pass
def run(i, j=None, k=None):
"""Run task documentation"""
pass
.. ewokstasks:: ewokssphinx.tests.dummy_tasks
:task-type: method
Ppfmethod#
def run(i, j=None, k=None):
"""Run task documentation"""
pass
.. ewokstasks:: ewokssphinx.tests.dummy_tasks
:task-type: ppfmethod
dummy_tasks#
Run task documentation
- Identifier:
ewokssphinx.tests.dummy_tasks.run- Task type:
- ppfmethod
- Inputs:
- i*
- j
- k
- Outputs:
- return_value