Skip to content

Commit

Permalink
FIX: Ensure push subscription always returned from Service.ask
Browse files Browse the repository at this point in the history
skipci
  • Loading branch information
cortadocodes committed Mar 21, 2024
1 parent 86632cf commit 0eb1dfe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions octue/cloud/pub_sub/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,9 @@ def ask(
:param str save_diagnostics: must be one of {"SAVE_DIAGNOSTICS_OFF", "SAVE_DIAGNOSTICS_ON_CRASH", "SAVE_DIAGNOSTICS_ON"}; if turned on, allow the input values and manifest (and its datasets) to be saved by the child either all the time or just if it fails while processing them
:param str|None question_uuid: the UUID to use for the question if a specific one is needed; a UUID is generated if not
:param str|None push_endpoint: if answers to the question should be pushed to an endpoint, provide its URL here (the returned subscription will be a push subscription); if not, leave this as `None`
:param bool asynchronous: if `True`, don't create an answer subscription
:param bool asynchronous: if `True` and not using a push endpoint, don't create an answer subscription
:param float|None timeout: time in seconds to keep retrying sending the question
:return (octue.cloud.pub_sub.subscription.Subscription|None, str): the answer subscription (if the question is synchronous) and question UUID
:return (octue.cloud.pub_sub.subscription.Subscription|None, str): the answer subscription (if the question is synchronous or a push endpoint was used) and question UUID
"""
service_namespace, service_name, service_revision_tag = split_service_id(service_id)

Expand Down Expand Up @@ -332,7 +332,7 @@ def ask(

question_uuid = question_uuid or str(uuid.uuid4())

if asynchronous:
if asynchronous and not push_endpoint:
answer_subscription = None
else:
answer_subscription = Subscription(
Expand Down
2 changes: 1 addition & 1 deletion octue/resources/child.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def ask(
:param float timeout: time in seconds to wait for an answer before raising a timeout error
:param float|int maximum_heartbeat_interval: the maximum amount of time (in seconds) allowed between child heartbeats before an error is raised
:raise TimeoutError: if the timeout is exceeded while waiting for an answer
:return dict|None: for a synchronous question, a dictionary containing the keys "output_values" and "output_manifest"; for an asynchronous question, `None`
:return dict|None: for a synchronous question, a dictionary containing the keys "output_values" and "output_manifest" from the result; for an asynchronous question, `None`
"""
subscription, _ = self._service.ask(
service_id=self.id,
Expand Down

0 comments on commit 0eb1dfe

Please sign in to comment.