Skip to content

Commit

Permalink
Show run result preview in Pipeline API example.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexpearce committed Feb 3, 2022
1 parent 511832a commit 5d8b885
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion examples/api_pipeline_run.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import json

from dotenv import load_dotenv

from pipeline import Pipeline, PipelineCloud, Variable, pipeline_function
Expand All @@ -24,4 +26,10 @@ def add_lol(a: str) -> str:
test_pipeline = Pipeline.get_pipeline("AddLol")
upload_output = api.upload_pipeline(test_pipeline)

print(api.run_pipeline(upload_output, "Hi I like to")["run_state"])
run_result = api.run_pipeline(upload_output, "Hi I like to")
print("Run state:", run_result["run_state"])
try:
result_preview = json.loads(run_result["result_preview"])
except (TypeError, json.JSONDecodeError):
result_preview = "unavailable"
print("Run result:", result_preview)

0 comments on commit 5d8b885

Please sign in to comment.