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

How to handle "multiple output" #25

Closed
1 task
fmigneault opened this issue Mar 25, 2019 · 9 comments · Fixed by #662
Closed
1 task

How to handle "multiple output" #25

fmigneault opened this issue Mar 25, 2019 · 9 comments · Fixed by #662
Labels
feature/CWL Issue related to CWL support process/wps1 Issue related to WPS 1.x processes support process/wps2 Issue related to WPS 2.x processes support process/wps3 Issue related to WPS 3.x (REST-JSON) processes support triage/investigate Exploration tasks or issues requirering more analysis triage/question Further information is requested

Comments

@fmigneault
Copy link
Collaborator

fmigneault commented Mar 25, 2019

According to owslib.wps, minOccurs/maxOccurs can only be parsed for inputs, outputs are always a single reference or literal data.

In pywps, the outputs have a reference to min_occurs/max_occurs because of inheritance from base classes. They are also returned in their json property.

For CWL, there is no restriction to have multiple outputs (array of string, file, etc.).
Actually, when using a regex glob: *.<ext> pattern, a list of results is automatically created with all matches.

How can we produce the CWL <-> WPS conversion in these cases?
Also, should we enforce explicit values of minOccurs/maxOccurs :

  • minOccurs="1" enforced since there should always be an output
    update: since CWL allows optional outputs (eg: File?), minOccurs=0|1 should be set according to nullable detection
  • maxOccurs="1" | "<number>" | "unbounded", with "1" being the default (same reason as min), or one of "<number>" | "unbounded" if specified during deployment

ref #17
relates to opengeospatial/ogcapi-processes#37

To Do

@fmigneault fmigneault added triage/question Further information is requested process/wps1 Issue related to WPS 1.x processes support process/wps2 Issue related to WPS 2.x processes support triage/investigate Exploration tasks or issues requirering more analysis feature/CWL Issue related to CWL support process/wps3 Issue related to WPS 3.x (REST-JSON) processes support labels Mar 25, 2019
@tomLandry
Copy link

Unsure if that answers your question, but please take a look at metalinks: bird-house/emu#64. First implementation here: bird-house/emu@1d6125f

This is a recommendation from ADES&EMS best practices ER: https://docs.opengeospatial.org/per/18-050r1.html#_multiple_outputs

@fmigneault
Copy link
Collaborator Author

@fmigneault
Copy link
Collaborator Author

implementation in pywps:
geopython/pywps#298

@tomLandry
Copy link

@fmigneault Multiple outputs is an "evaluation aspect" of the OGC EO Pilot project. Thus we need to prioritize this relatively high. See https://portal.opengeospatial.org/files/?artifact_id=90733#_application_execution_multiple_outputs

@fmigneault
Copy link
Collaborator Author

@fmigneault
Copy link
Collaborator Author

Another possible solution using STAC #103

@fmigneault
Copy link
Collaborator Author

For reference, some kind of multiple-output handling is already accomplished for WPS-REST interface when a job output is a JSON file listing an array of URL references :

def _get_multi_json_references(output):
# type: (owslib.wps.Output) -> Optional[List[JSON]]
"""
Since WPS standard does not allow to return multiple values for a single output,
a lot of process actually return a json array containing references to these outputs.
This function goal is to detect this particular format.
:return: An array of HTTP(S) references if the specified output is effectively a JSON containing that,
``None`` otherwise.
"""
# Check for the json datatype and mimetype
if output.dataType == WPS_COMPLEX_DATA and output.mimeType == CONTENT_TYPE_APP_JSON:
# If the json data is referenced read it's content
if output.reference:
json_data_str = _read_reference(output.reference)
# Else get the data directly
else:
json_data_str = _get_data(output)
# Load the actual json dict
json_data = json.loads(json_data_str)
if isinstance(json_data, list):
for data_value in json_data:
if not is_reference(data_value):
return None
return json_data
return None

@fmigneault
Copy link
Collaborator Author

Follow up on opengeospatial/ogcapi-processes#225
This would enforce that only single value are allowed as output (with default handling).

If an output needs to be a JSON list, it should provide in the process description the schema of that output accordingly.
In such case, the output could be loaded and validated to render directly as list (or more complex format).
Requires full support of #245

@ChaamC
Copy link
Contributor

ChaamC commented Dec 1, 2021

Optional outputs (minOccurs=0|1) would be useful for the asv project, which produces an output file only if a certain input argument is found. Using the optional output has been tested with cwl and was working well (returns a null value for the parameter if the file is not created.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/CWL Issue related to CWL support process/wps1 Issue related to WPS 1.x processes support process/wps2 Issue related to WPS 2.x processes support process/wps3 Issue related to WPS 3.x (REST-JSON) processes support triage/investigate Exploration tasks or issues requirering more analysis triage/question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants