File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
libs/executors/garf/executors Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 1919import pydantic
2020import smart_open
2121import yaml
22+ from garf .executors import exceptions
2223from garf .executors .execution_context import ExecutionContext
2324
2425
26+ class GarfWorkflowError (exceptions .GarfExecutorError ):
27+ """Workflow specific exception."""
28+
29+
2530class QueryPath (pydantic .BaseModel ):
2631 """Path file with query."""
2732
@@ -57,7 +62,7 @@ class ExecutionStep(ExecutionContext):
5762 """
5863
5964 fetcher : str | None = None
60- alias : str | None = None
65+ alias : str | None = pydantic . Field ( default = None , pattern = r'^[a-zA-Z0-9_]+$' )
6166 queries : list [QueryPath | QueryDefinition ] | None = None
6267
6368 @property
@@ -84,7 +89,10 @@ def from_file(cls, path: str | pathlib.Path | os.PathLike[str]) -> Workflow:
8489 """Builds workflow from local or remote yaml file."""
8590 with smart_open .open (path , 'r' , encoding = 'utf-8' ) as f :
8691 data = yaml .safe_load (f )
87- return Workflow (steps = data .get ('steps' ))
92+ try :
93+ return Workflow (** data )
94+ except pydantic .ValidationError as e :
95+ raise GarfWorkflowError (f'Incorrect workflow:\n { e } ' ) from e
8896
8997 def save (self , path : str | pathlib .Path | os .PathLike [str ]) -> str :
9098 """Saves workflow to local or remote yaml file."""
You can’t perform that action at this time.
0 commit comments