Skip to content

Conversation

@QSparks
Copy link
Contributor

@QSparks QSparks commented Mar 26, 2025

Adds support for cancelling running WPS processes. Upgrades to PyWPS v4.6.0 for improved job queue handling and adds finer-resolution progress updates via R console callbacks.

cancel_process.py

  • New cancel endpoint (POST /wps/cancel-process) that:
    • Sends SIGINT to the running process
    • Retrieves tracked response and calls response.clean()
    • Updates DB status (WPS_STATUS.FAILED)

response_tracker.py

  • In-memory registry to track active response objects by UUID

utils.py

  • Integrated R console progress monitor:
    • Parses R output to update WPS progress bar
    • Detects cancellation mid-process, interrupts R via stop(...)
    • Triggers cleanup via response.clean() if cancelled
  • Added update_status_with_check() to avoid updating progress on cancelled/failed jobs
  • Includes a fallback raise_if_failed() for missed cancellations

Other

  • Upgrades to latest pywps and nchelpers
  • Updated WSGI config for the new endpoint.
  • Adds docs/cancellation.md with usage instructions.

@QSparks QSparks requested a review from Nospamas March 26, 2025 23:08
@QSparks QSparks self-assigned this Mar 26, 2025
Copy link

@Nospamas Nospamas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (Pending CI tests passing?) 👍

return error(f"Failed to update status: {str(e)}", "500 Internal Server Error")
finally:
session.close()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, good error handling 👍

@QSparks
Copy link
Contributor Author

QSparks commented Apr 1, 2025

LGTM (Pending CI tests passing?) 👍

CI fixed with updates to ClimDown finishing some refactoring that was already underway with the ci-climatex branch & validating process errors via WPS-compliant response body instead of relying on stderr in wps-tools.

Copy link

@Nospamas Nospamas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

requirements.txt Outdated
rpy2==3.3.6
werkzeug==1.0.1
wps-tools[r]==2.1.2
wps-tools @ git+https://github.com/pacificclimate/wps-tools.git@i60-file-url-handling#egg=wps-tools
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably don't forget to release this one and use the version number once its ready :)

@QSparks QSparks merged commit 8391acb into ci-climatex-demo Apr 3, 2025
4 checks passed
@QSparks QSparks mentioned this pull request Nov 24, 2025
1 task
QSparks added a commit that referenced this pull request Dec 12, 2025
* Add and update CI/demo notebooks
* Update CI environment: Python versions, system deps, packages, Dockerfile, and Black workflow
* Add cancel endpoint, R progress monitor, and upgrade PyWPS (#68)
* Maintenance updates  (#69)
* Add USE_PYPROJECT option in black workflow
* Use ClimDown v2.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants