Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support run result previews #34

Merged
merged 2 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
2 changes: 2 additions & 0 deletions pipeline/schemas/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class RunGet(BaseModel):
data: DataGet
blocking: Optional[bool] = False
result: Optional[FileGet]
#: JSON-serialised runnable return value, if available
result_preview: Optional[str]
error: Optional[RunError]

class Config:
Expand Down