Created
July 16, 2024 10:47
-
-
Save lmmx/6c08d0dac4721075ed681b56c428cdf3 to your computer and use it in GitHub Desktop.
Example of running an idempotent pipeline using Pydantic validation for control flow (using `OnErrorOmit`)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pydantic import BaseModel, FilePath, NewPath, OnErrorOmit | |
class Step(BaseModel): | |
source: FilePath | |
dest: NewPath | |
class Pipeline(BaseModel): | |
steps: list[OnErrorOmit[Step]] | |
def run_pipeline(): | |
steps = [dict(source=f"{letter}.in", dest=f"{letter}.out") for letter in "ab"] | |
for step in steps: | |
print(f"Prepared step: {step}") | |
pipeline = Pipeline(steps=steps) | |
for step in pipeline.steps: | |
print(f"Running {step=}") |
Author
lmmx
commented
Jul 16, 2024
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment