-
Notifications
You must be signed in to change notification settings - Fork 44
Add provenance output support to execute() response #768
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2,6 +2,8 @@ | |||||||||||||
import logging | ||||||||||||||
from pathlib import Path | ||||||||||||||
from typing import Callable, Dict, List, Optional, Union | ||||||||||||||
import os | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
import numpy as np | ||||||||||||||
import xarray as xr | ||||||||||||||
|
@@ -270,6 +272,7 @@ def execute( | |||||||||||||
*, | ||||||||||||||
validate: Optional[bool] = None, | ||||||||||||||
auto_decode: bool = True, | ||||||||||||||
return_provenance: bool = False, | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are adding a custom argument here to a more public API of cube = local_connection.load_collection(...)
res = cube.execute() the latter |
||||||||||||||
) -> xr.DataArray: | ||||||||||||||
""" | ||||||||||||||
Execute locally the process graph and return the result as an xarray.DataArray. | ||||||||||||||
|
@@ -282,4 +285,16 @@ def execute( | |||||||||||||
if auto_decode is not True: | ||||||||||||||
raise ValueError("LocalConnection requires auto_decode=True") | ||||||||||||||
process_graph = as_flat_graph(process_graph) | ||||||||||||||
return OpenEOProcessGraph(process_graph).to_callable(PROCESS_REGISTRY)() | ||||||||||||||
pg = OpenEOProcessGraph(process_graph) | ||||||||||||||
|
||||||||||||||
# Return the result and get the workflow provinance (yprov4wfs) | ||||||||||||||
result = pg.to_callable(PROCESS_REGISTRY)() | ||||||||||||||
workflow = pg.workflow | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as far as I understand this depends on a new feature of openeo-pg-parser-networkx, so the minimum version of this dependency has to be bumped at Lines 47 to 52 in ee18290
|
||||||||||||||
|
||||||||||||||
# To save the provenance file in the specific path use: | ||||||||||||||
# workflow.prov_to_json(directory_path=save_path) | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's useful to have this as comment here. If this is for users, it should be in the docblock |
||||||||||||||
|
||||||||||||||
if return_provenance: | ||||||||||||||
return result, workflow | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This custom return should be documented in the docblock and return annotation There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that being said, I'm not a big fan of the pattern of returning different data structures (tuple of two things instead of a single |
||||||||||||||
else: | ||||||||||||||
return result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason this is added?