Skip to content

Commit 3dc86aa

Browse files
authored
MRG: Merge pull request #660 from octue/improve-ask-multiple
Enable question chaining
2 parents 450a280 + 95fc245 commit 3dc86aa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2508
-1918
lines changed

docs/requirements.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Required by the python script for building documentation
22
poetry==1.2.0b2
3-
Sphinx>=4,<5
3+
Sphinx>=5,<8
44
sphinx-rtd-theme>=1,<2
5-
sphinx-tabs>=3,<4
6-
sphinx-toolbox==3.0.0
5+
sphinx-tabs>=3.4.0,<4
6+
sphinx-toolbox>=3,<4
77
git+https://github.com/octue/octue-sdk-python.git@main

docs/source/asking_questions.rst

+20-23
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,23 @@ access the event store and run:
9696
9797
events = get_events(
9898
table_id="your-project.your-dataset.your-table",
99-
sender="octue/test-service:1.0.0",
10099
question_uuid="53353901-0b47-44e7-9da3-a3ed59990a71",
101100
)
102101
103102
104103
**Options**
105104

105+
- ``question_uuid`` - Retrieve events from this specific question
106+
- ``parent_question_uuid`` - Retrieve events from questions triggered by the same parent question (this doesn't include the parent question's events)
107+
- ``originator_question_uuid`` - Retrieve events for the entire tree of questions triggered by an originator question (a question asked manually through ``Child.ask``; this does include the originator question's events)
106108
- ``kind`` - Only retrieve this kind of event if present (e.g. "result")
107109
- ``include_backend_metadata`` - If ``True``, retrieve information about the service backend that produced the event
108110
- ``limit`` - If set to a positive integer, limit the number of events returned to this
109111

112+
.. note::
113+
114+
Only one of ``question_uuid``, ``parent_question_uuid``, and ``originator_question_uuid`` can be provided at one time.
115+
110116

111117
.. collapse:: See an example output here...
112118

@@ -116,8 +122,8 @@ access the event store and run:
116122
[
117123
{
118124
"event": {
119-
"datetime": "2024-03-06T15:44:18.156044",
120-
"kind": "delivery_acknowledgement"
125+
"kind": "delivery_acknowledgement",
126+
"datetime": "2024-03-06T15:44:18.156044"
121127
},
122128
},
123129
{
@@ -149,21 +155,10 @@ access the event store and run:
149155
},
150156
{
151157
"event": {
152-
"datetime": "2024-03-06T15:46:18.167424",
153-
"kind": "heartbeat"
158+
"kind": "heartbeat",
159+
"datetime": "2024-03-06T15:46:18.167424"
154160
},
155-
"attributes": {
156-
"datetime": "2024-04-11T10:46:48.236064",
157-
"uuid": "a9de11b1-e88f-43fa-b3a4-40a590c3443f",
158-
"order": "7",
159-
"question_uuid": "d45c7e99-d610-413b-8130-dd6eef46dda6",
160-
"originator": "octue/test-service:1.0.0",
161-
"sender": "octue/test-service:1.0.0",
162-
"sender_type": "CHILD",
163-
"sender_sdk_version": "0.51.0",
164-
"recipient": "octue/another-service:3.2.1"
165-
}
166-
}
161+
},
167162
{
168163
"event": {
169164
"kind": "result",
@@ -203,23 +198,25 @@ raised and no answers are returned.
203198
{"input_values": {"height": 7, "width": 32}},
204199
)
205200
>>> [
206-
{"output_values": {"some": "output"}, "output_manifest": None},
207-
{"output_values": {"another": "result"}, "output_manifest": None},
208-
{"output_values": {"different": "result"}, "output_manifest": None},
201+
({"output_values": {"some": "output"}, "output_manifest": None}, '2681ef4e-4ab7-4cf9-8783-aad982d5e324'),
202+
({"output_values": {"another": "result"}, "output_manifest": None}, '474923bd-14b6-4f4c-9bfe-8148358f35cd'),
203+
({"output_values": {"different": "result"}, "output_manifest": None}, '9a50daae-2328-4728-9ddd-b2252474f118'),
209204
]
210205
211206
This method uses multithreading, allowing all the questions to be asked at once instead of one after another.
212207

213208
**Options**
214209

215210
- If ``raise_errors=False`` is provided, answers are returned for all successful questions while unraised errors are
216-
returned for unsuccessful ones
211+
logged and returned for unsuccessful ones
217212
- If ``raise_errors=False`` is provided with ``max_retries > 0``, failed questions are retried up to this number of
218213
times
219214
- If ``raise_errors=False`` is provided with ``max_retries > 0`` and ``prevent_retries_when`` is set to a list of
220215
exception types, failed questions are retried except for those whose exception types are in the list
221-
- The maximum number of threads that can be used to ask questions in parallel can be set via the ``max_workers``
222-
argument. This has no effect on the total number of questions that can be asked via ``Child.ask_multiple``.
216+
- ``max_workers``: The maximum number of threads that can be used to ask questions in parallel can be set via this
217+
argument. It has no effect on the total number of questions that can be asked via ``Child.ask_multiple``.
218+
- ``log_errors``: If `True` and ``raise_errors=False``, any errors remaining once retries are exhausted are logged in
219+
addition to being returned
223220

224221

225222
Asking a question within a service

docs/source/dataset.rst

+7-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ Working with a dataset is the same whether it's local or cloud-based.
3737
3838
from octue.resources import Dataset
3939
40-
dataset = Dataset(path="path/to/dataset", recursive=True)
40+
dataset = Dataset(path="path/to/dataset")
4141
42-
dataset = Dataset(path="gs://my-bucket/path/to/dataset", recursive=True)
42+
dataset = Dataset(path="gs://my-bucket/path/to/dataset")
43+
44+
45+
.. warning::
46+
47+
Datasets recurse all subdirectories by default unless ``recursive=False`` is set.
4348

4449

4550
Upload a dataset

0 commit comments

Comments
 (0)