You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: octue/resources/child.py
+18-7Lines changed: 18 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -63,26 +63,32 @@ def ask(
63
63
record_messages=True,
64
64
save_diagnostics="SAVE_DIAGNOSTICS_ON_CRASH", # This is repeated as a string here to avoid a circular import.
65
65
question_uuid=None,
66
+
push_endpoint=None,
67
+
bigquery_table_id=None,
66
68
timeout=86400,
67
69
maximum_heartbeat_interval=300,
68
70
):
69
-
"""Ask the child a question and wait for its answer - i.e. send it input values and/or an input manifest and
70
-
wait for it to analyse them and return output values and/or an output manifest. The input values and manifest
71
-
must conform to the schema in the child's twine.
72
-
73
-
:param any|None input_values: any input values for the question
74
-
:param octue.resources.manifest.Manifest|None input_manifest: an input manifest of any datasets needed for the question
71
+
"""Ask the child either:
72
+
- A synchronous (ask-and-wait) question and wait for it to return an output. Questions are synchronous if
73
+
neither the `push_endpoint` or the `bigquery_table_id` argument is provided.
74
+
- An asynchronous (fire-and-forget) question and return immediately. To make a question asynchronous, provide
75
+
either the `push_endpoint` or `bigquery_table_id` argument.
76
+
77
+
:param any|None input_values: any input values for the question, conforming with the schema in the child's twine
78
+
:param octue.resources.manifest.Manifest|None input_manifest: an input manifest of any datasets needed for the question, conforming with the schema in the child's twine
75
79
:param list(dict)|None children: a list of children for the child to use instead of its default children (if it uses children). These should be in the same format as in an app's app configuration file and have the same keys.
76
80
:param bool subscribe_to_logs: if `True`, subscribe to logs from the child and handle them with the local log handlers
77
81
:param bool allow_local_files: if `True`, allow the input manifest to contain references to local files - this should only be set to `True` if the child will have access to these local files
78
82
:param callable|None handle_monitor_message: a function to handle monitor messages (e.g. send them to an endpoint for plotting or displaying) - this function should take a single JSON-compatible python primitive as an argument (note that this could be an array or object)
79
83
:param bool record_messages: if `True`, record messages received from the child in the `received_messages` property
80
84
: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
81
85
:param str|None question_uuid: the UUID to use for the question if a specific one is needed; a UUID is generated if not
86
+
: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`
87
+
:param str|None bigquery_table_id: if answers to the questions should be written to BigQuery, provide the ID of the table here (e.g. "your-project.your-dataset.your-table") (the returned subscription will be a BigQuery subscription); if not, leave this as `None`
82
88
:param float timeout: time in seconds to wait for an answer before raising a timeout error
83
89
:param float|int maximum_heartbeat_interval: the maximum amount of time (in seconds) allowed between child heartbeats before an error is raised
84
90
:raise TimeoutError: if the timeout is exceeded while waiting for an answer
85
-
:return dict: a dictionary containing the keys "output_values" and "output_manifest"
91
+
:return dict|None: for a synchronous question, a dictionary containing the keys "output_values" and "output_manifest"; for an asynchronous question, `None`
0 commit comments