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

Properly handle glob patterns and corresponding WPS apps #24

Closed
fmigneault opened this issue Mar 21, 2019 · 1 comment
Closed

Properly handle glob patterns and corresponding WPS apps #24

fmigneault opened this issue Mar 21, 2019 · 1 comment
Assignees
Labels
feature/CWL Issue related to CWL support triage/enhancement New feature or request

Comments

@fmigneault
Copy link
Collaborator

fmigneault commented Mar 21, 2019

When a CWL output glob pattern (ex: glob: "*.nc") is employed, the output of the WPS app should automatically define maxOccurs="unbounded", or any overriding maxOccurs value specified in the Deploy body.

Also, this output should be considered as an array (list), so that wps_package collects multiple files/data here:

def make_outputs(self, cwl_result):
# type: (CWL_Results) -> None
"""
Maps `CWL` result outputs to corresponding `WPS` outputs.
"""
for output_id in self.request.outputs: # iterate over original WPS outputs, extra such as logs are dropped
# TODO: adjust output for glob patterns (https://github.com/crim-ca/weaver/issues/24)
if isinstance(cwl_result[output_id], list) and not isinstance(self.response.outputs[output_id], list):
if len(cwl_result[output_id]) > 1:
self.logger.warning(
"Dropping additional output values (%s total), only 1 supported per identifier.",
len(cwl_result[output_id])
)
# provide more details than poorly descriptive IndexError
if not len(cwl_result[output_id]):
raise PackageExecutionError(
"Process output '{}' expects at least one value but none was found. "
"Possible incorrect glob pattern definition in CWL Application Package.".format(output_id)
)
cwl_result[output_id] = cwl_result[output_id][0] # expect only one output
if "location" not in cwl_result[output_id] and os.path.isfile(str(cwl_result[output_id])):
raise PackageTypeError("Process output '{}' defines CWL type other than 'File'. ".format(output_id) +
"Application output results must use 'File' type to return file references.")
if "location" in cwl_result[output_id]:
self.make_location_output(cwl_result, output_id)
continue
# data output
self.response.outputs[output_id].data = cwl_result[output_id]
self.response.outputs[output_id].as_reference = False
self.logger.info("Resolved WPS output [%s] as literal data", output_id)

We could explore the use of a builtin app array2single for cases where glob is used to collect an expected unique output.

When an unique file glob pattern is used (ex: glob: "output.nc"), then the process should automatically define maxOccurs=1 and the wps_package output should resolve any CWL glob list (as required) to an unique reference.

Furthermore, the specific extension could be employed to automatically set mediaType if not provided with more specific values.

Relates to #25

@fmigneault fmigneault self-assigned this Mar 21, 2019
@fmigneault fmigneault added triage/enhancement New feature or request feature/CWL Issue related to CWL support labels Mar 21, 2019
@fmigneault
Copy link
Collaborator Author

Regardless of glob pattern, multiple items should instead be detected via the File[] or type: array, item: File notation.
A generic * glob could still be used to collect a single File (just that any name is valid), such as a randomly generated file name.

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 triage/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant