Skip to content

Commit

Permalink
Merge pull request #769 from crim-ca/various-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fmigneault authored Nov 26, 2024
2 parents e2a5e7a + 9a44ab6 commit df041c0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ Changes:

Fixes:
------
- Fix race condition between workflow step early input staging cleanup on successful step status update.
Due to the ``_update_status`` method of ``pywps`` performing cleanup when propagating a successful completion of
a step within a workflow, the parent workflow was marked as succeeded (`XML` status document), and any step executed
after the successful one that were depending on the workflow inputs could result in not-found file references if it
was staged by the previous step.
- Fix optional ``title`` in metadata causing failing HTML rendering of the `Process` description if omitted.
- Fix HTML ``Content-Type`` header erroneously set for JSON-only (for now) ``GET /jobs/{jobId}`` as similar endpoints.
- Fix `CWL` ``enum`` type mishandling ``symbols`` containing a colon (``:``) character (e.g.: a list of allowed times)
leading to their invalid interpretation as namespaced strings (i.e.: ``<ns>:<value>``), in turn failing validation
and breaking the resulting `CWL`. Such ``enum`` will be patched with updated ``symbols`` prefixed by ``#`` to respect
Expand Down
12 changes: 9 additions & 3 deletions weaver/processes/wps_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -1939,8 +1939,8 @@ def update_effective_user(self):
level=logging.WARNING if (app_euid == "0" or app_egid == "0") else logging.INFO,
)

def update_status(self, message, progress, status, error=None):
# type: (str, Number, AnyStatusType, Optional[Exception]) -> None
def update_status(self, message, progress, status, error=None, step=False):
# type: (str, Number, AnyStatusType, Optional[Exception], bool) -> None
"""
Updates the :mod:`pywps` real job status from a specified parameters.
"""
Expand All @@ -1961,7 +1961,7 @@ def update_status(self, message, progress, status, error=None):
# therefore, use the '_update_status' to enforce the status
# using protected method also avoids weird overrides of progress
# percent on failure and final 'success' status
self.response._update_status(pywps_status_id, message, self.percent) # noqa: W0212
self.response._update_status(pywps_status_id, message, self.percent, clean=not step) # noqa: W0212

if isinstance(error, Exception):
self.exception_message(exception_type=type(error), exception=error,
Expand All @@ -1979,11 +1979,17 @@ def step_update_status(self,
status, # type: AnyStatusType
error=None, # type: Optional[Exception]
): # type: (...) -> None
# ensure the status of the current workflow is not changed to 'success' if up a step-update
# setting to 'success' will report the wrong value in the status XML document
# this would also trigger cleanup, which would remove an staged file needed by a future step
if status == Status.SUCCEEDED:
status = Status.RUNNING
self.update_status(
message=f"[provider: {target_host}, step: {step_name}] - {str(message).strip()}",
progress=map_progress(progress, start_step_progress, end_step_progress),
status=status,
error=error,
step=True,
)

def log(self, level, message, *args, **kwargs):
Expand Down
6 changes: 5 additions & 1 deletion weaver/wps_restapi/jobs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,11 @@ def get_job_status_schema(request):

def make_headers(resolved_schema):
# type: (JobStatusSchemaType) -> HeadersType
content_type = clean_media_type_format(content_accept, strip_parameters=True)
content_type = clean_media_type_format(content_accept.split(",")[0], strip_parameters=True)
# FIXME: support HTML or XML
# (allow transparently for browsers types since Accept did not raise earlier, and no other supported yet)
if content_type in ContentType.ANY_XML | {ContentType.TEXT_HTML}:
content_type = ContentType.APP_JSON
content_profile = f"{content_type}; profile={resolved_schema}"
content_headers = {"Content-Type": content_profile}
if resolved_schema == JobStatusSchema.OGC:
Expand Down
10 changes: 9 additions & 1 deletion weaver/wps_restapi/templates/responses/util.mako
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,15 @@ NOTE: class 'language-json' used by the 'ajax/libs/highlight.js' library inserte
<dl class="indent">
%for meta in metadata:
<dt>
${meta.title}
<div class="field-key">
%if "title" in meta:
Title: ${meta.title}
%elif "role" in meta:
Role: ${meta.role}
%else:
Rel: ${meta.rel}
%endif
</div>
</dt>
<dd>
%if "href" in meta:
Expand Down

0 comments on commit df041c0

Please sign in to comment.