From f3e982049feb1e9b4a033eb6ca5d41baf6c8d229 Mon Sep 17 00:00:00 2001 From: FrancescoIngv Date: Mon, 2 Feb 2026 15:29:06 +0100 Subject: [PATCH 1/2] Implement OGC API - Processes, Requirement 25, for jobControlOptions async-execute only, and no user preference (Issue #2231) --- pygeoapi/api/processes.py | 4 +-- pygeoapi/process/manager/base.py | 42 +++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/pygeoapi/api/processes.py b/pygeoapi/api/processes.py index d6a477edf..286990999 100644 --- a/pygeoapi/api/processes.py +++ b/pygeoapi/api/processes.py @@ -14,7 +14,7 @@ # Copyright (c) 2022 John A Stevenson and Colin Blackburn # Copyright (c) 2023 Ricardo Garcia Silva # Copyright (c) 2024 Bernhard Mallinger -# Copyright (c) 2024 Francesco Martinelli +# Copyright (c) 2026 Francesco Martinelli # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -524,7 +524,7 @@ def execute_process(api: API, request: APIRequest, else: response2 = response - if execution_mode == RequestedProcessExecutionMode.respond_async: + if (headers.get('Preference-Applied', '') == RequestedProcessExecutionMode.respond_async.value): LOGGER.debug('Asynchronous mode detected, returning statusInfo') response2 = { 'jobID': job_id, diff --git a/pygeoapi/process/manager/base.py b/pygeoapi/process/manager/base.py index d3d3285b0..c72eb2f62 100644 --- a/pygeoapi/process/manager/base.py +++ b/pygeoapi/process/manager/base.py @@ -6,7 +6,7 @@ # # Copyright (c) 2024 Tom Kralidis # (c) 2023 Ricardo Garcia Silva -# (c) 2024 Francesco Martinelli +# (c) 2026 Francesco Martinelli # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation @@ -393,9 +393,10 @@ def execute_process( 'requested_response': requested_response } + job_control_options = processor.metadata.get( + 'jobControlOptions', []) + if execution_mode == RequestedProcessExecutionMode.respond_async: - job_control_options = processor.metadata.get( - 'jobControlOptions', []) # client wants async - do we support it? process_supports_async = ( ProcessExecutionMode.async_execute.value in job_control_options @@ -414,17 +415,30 @@ def execute_process( 'Preference-Applied': ( RequestedProcessExecutionMode.wait.value) } - elif execution_mode == RequestedProcessExecutionMode.wait: - # client wants sync - pygeoapi implicitly supports sync mode - LOGGER.debug('Synchronous execution') - handler = self._execute_handler_sync - response_headers = { - 'Preference-Applied': RequestedProcessExecutionMode.wait.value} - else: # client has no preference - # according to OAPI - Processes spec we ought to respond with sync - LOGGER.debug('Synchronous execution') - handler = self._execute_handler_sync - response_headers = None + else: # client has no preference or clients wants sync + # do we support sync? + process_supports_sync = ( + ProcessExecutionMode.sync_execute.value in job_control_options + ) + if not process_supports_sync: + LOGGER.debug('Asynchronous execution') + handler = self._execute_handler_async + response_headers = { + 'Preference-Applied': ( + RequestedProcessExecutionMode.respond_async.value) + } + else: + # according to OAPI - Processes spec we ought to + # respond with sync + LOGGER.debug('Synchronous execution') + handler = self._execute_handler_sync + if execution_mode == RequestedProcessExecutionMode.wait: + response_headers = None + else: + response_headers = { + 'Preference-Applied': ( + RequestedProcessExecutionMode.wait.value) + } # Add Job before returning any response. current_status = JobStatus.accepted From 62347a9a187f52929cb8a5cbcb3090995a41db57 Mon Sep 17 00:00:00 2001 From: FrancescoIngv Date: Mon, 2 Feb 2026 15:32:49 +0100 Subject: [PATCH 2/2] Minor fix --- pygeoapi/api/processes.py | 2 +- pygeoapi/process/manager/base.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pygeoapi/api/processes.py b/pygeoapi/api/processes.py index 286990999..26e279189 100644 --- a/pygeoapi/api/processes.py +++ b/pygeoapi/api/processes.py @@ -524,7 +524,7 @@ def execute_process(api: API, request: APIRequest, else: response2 = response - if (headers.get('Preference-Applied', '') == RequestedProcessExecutionMode.respond_async.value): + if (headers.get('Preference-Applied', '') == RequestedProcessExecutionMode.respond_async.value): # noqa LOGGER.debug('Asynchronous mode detected, returning statusInfo') response2 = { 'jobID': job_id, diff --git a/pygeoapi/process/manager/base.py b/pygeoapi/process/manager/base.py index c72eb2f62..159e753f2 100644 --- a/pygeoapi/process/manager/base.py +++ b/pygeoapi/process/manager/base.py @@ -433,7 +433,7 @@ def execute_process( LOGGER.debug('Synchronous execution') handler = self._execute_handler_sync if execution_mode == RequestedProcessExecutionMode.wait: - response_headers = None + response_headers = None else: response_headers = { 'Preference-Applied': (