Define models
Maturity labels
- Now: Stable and supported in current releases.
- Preview: Usable today, but behavior and APIs may evolve.
- Planned: Not yet implemented.
Note
Status: Now
Quick patterns
Pattern 1: Model[T] directly
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/envs/latest/lib/python3.10/site-packages/markdown_exec/_internal/formatters/python.py", line 71, in _run_python
exec_python(code, code_block_id, exec_globals)
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/envs/latest/lib/python3.10/site-packages/markdown_exec/_internal/formatters/_exec_python.py", line 8, in exec_python
exec(compiled, exec_globals) # noqa: S102
File "<code block: n35>", line 1, in <module>
import omnipy as om
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/checkouts/latest/src/omnipy/__init__.py", line 193, in <module>
from omnipy.hub.runtime import runtime
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/checkouts/latest/src/omnipy/hub/runtime.py", line 3, in <module>
from omnipy.components.prefect.engine.prefect import PrefectEngine
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/checkouts/latest/src/omnipy/components/prefect/engine/prefect.py", line 28, in <module>
class PrefectEngine(TaskRunnerEngine,
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/checkouts/latest/src/omnipy/components/prefect/engine/prefect.py", line 96, in PrefectEngine
def _init_task(self, task: IsTask, call_func: Callable) -> PrefectTask: # noqa: C901
NameError: name 'PrefectTask' is not defined
Pattern 2: subclass for reusable names
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/envs/latest/lib/python3.10/site-packages/markdown_exec/_internal/formatters/python.py", line 71, in _run_python
exec_python(code, code_block_id, exec_globals)
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/envs/latest/lib/python3.10/site-packages/markdown_exec/_internal/formatters/_exec_python.py", line 8, in exec_python
exec(compiled, exec_globals) # noqa: S102
File "<code block: n36>", line 1, in <module>
import omnipy as om
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/checkouts/latest/src/omnipy/__init__.py", line 193, in <module>
from omnipy.hub.runtime import runtime
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/checkouts/latest/src/omnipy/hub/runtime.py", line 3, in <module>
from omnipy.components.prefect.engine.prefect import PrefectEngine
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/checkouts/latest/src/omnipy/components/prefect/engine/prefect.py", line 28, in <module>
class PrefectEngine(TaskRunnerEngine,
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/checkouts/latest/src/omnipy/components/prefect/engine/prefect.py", line 96, in PrefectEngine
def _init_task(self, task: IsTask, call_func: Callable) -> PrefectTask: # noqa: C901
NameError: name 'PrefectTask' is not defined
Pattern 3: nested type parameters
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/envs/latest/lib/python3.10/site-packages/markdown_exec/_internal/formatters/python.py", line 71, in _run_python
exec_python(code, code_block_id, exec_globals)
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/envs/latest/lib/python3.10/site-packages/markdown_exec/_internal/formatters/_exec_python.py", line 8, in exec_python
exec(compiled, exec_globals) # noqa: S102
File "<code block: n37>", line 1, in <module>
import omnipy as om
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/checkouts/latest/src/omnipy/__init__.py", line 193, in <module>
from omnipy.hub.runtime import runtime
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/checkouts/latest/src/omnipy/hub/runtime.py", line 3, in <module>
from omnipy.components.prefect.engine.prefect import PrefectEngine
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/checkouts/latest/src/omnipy/components/prefect/engine/prefect.py", line 28, in <module>
class PrefectEngine(TaskRunnerEngine,
File "/home/docs/checkouts/readthedocs.org/user_builds/omnipy/checkouts/latest/src/omnipy/components/prefect/engine/prefect.py", line 96, in PrefectEngine
def _init_task(self, task: IsTask, call_func: Callable) -> PrefectTask: # noqa: C901
NameError: name 'PrefectTask' is not defined
Links
- How-to: Parse strategies
- How-to: Parametrized models