|
|
@@ -5,6 +5,7 @@ Entry point for cipy library, re-exporting all of the default items
|
|
|
import logging
|
|
|
import types
|
|
|
import typing
|
|
|
+import sys
|
|
|
|
|
|
import pydantic
|
|
|
|
|
|
@@ -44,6 +45,7 @@ __all__ = [
|
|
|
"Workflow",
|
|
|
"compute",
|
|
|
"context",
|
|
|
+ "outputs",
|
|
|
"required",
|
|
|
]
|
|
|
|
|
|
@@ -69,3 +71,13 @@ def compute(arg: typing.Callable[[Context], typing.Any], /) -> typing.Any:
|
|
|
based on the runtime CI context.
|
|
|
"""
|
|
|
return pydantic.Field(default=Factory(arg))
|
|
|
+
|
|
|
+
|
|
|
+def outputs(**fields: types.UnionType | type[typing.Any]) -> Outputs:
|
|
|
+ frame = sys._getframe(1)
|
|
|
+ return pydantic.create_model( # type: ignore[call-overload]
|
|
|
+ f"__{frame.f_lineno}_AnonymousOutputs",
|
|
|
+ __base__=Outputs,
|
|
|
+ __module__=frame.f_globals["__name__"],
|
|
|
+ **{k: typing.Annotated[t, pydantic.Field(default=None)] for k, t in fields.items()}
|
|
|
+ )()
|