Skip to content

Switch to event-driven infrastructure and improve support for asynchronous questions #632

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 170 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
b21676a
REF: Factor out making minimal dictionary
cortadocodes Mar 5, 2024
a5ee14a
DOC: Improve `create-push-subscription` CLI command help text
cortadocodes Mar 5, 2024
f05b10d
REF: Factor out creating push subscription
cortadocodes Mar 5, 2024
8049a3c
FEA: Add ability to create BigQuery subscriptions
cortadocodes Mar 5, 2024
b45f07a
ENH: Get subscription project name from topic by default
cortadocodes Mar 5, 2024
9c785a5
ENH: Raise error if attempting to pull a BigQuery subscription
cortadocodes Mar 5, 2024
3e9919a
ENH: Add ability to ask questions with BigQuery subscription
cortadocodes Mar 5, 2024
ea4cda3
REF: Factor out sending question message in `Service.ask`
cortadocodes Mar 5, 2024
414699e
TST: Test error raised if trying to pull a BigQuery subscription
cortadocodes Mar 5, 2024
2cc8bbf
OPS: Add test BigQuery dataset to terraform config
cortadocodes Mar 5, 2024
fe2dafb
ENH: Allow asking of asynchronous questions via `Child.ask`
cortadocodes Mar 5, 2024
3c3f929
FIX: Await successful publishing of question messages
cortadocodes Mar 6, 2024
1def7ef
DEP: Add `google-cloud-bigquery`
cortadocodes Mar 6, 2024
cdac7bf
DEP: Upgrade `coolname`
cortadocodes Mar 6, 2024
0ee0584
OPS: Add bigquery IAM roles to terraform config
cortadocodes Mar 6, 2024
63be56a
DEP: Add `db-dtypes` for converting bigquery rows to dataframes
cortadocodes Mar 6, 2024
a817f32
FEA: Add function for getting events from BigQuery
cortadocodes Mar 6, 2024
639102e
FIX: Fix `api_access_endpoint` usage in `mock_generate_signed_url`
cortadocodes Mar 6, 2024
06123db
FIX: Add new `Child.ask` arguments to mock and emulator
cortadocodes Mar 6, 2024
4079703
ENH: Allow choice of BigQuery table fields returned
cortadocodes Mar 6, 2024
6c4479e
ENH: Allow choice of event kinds to return from BigQuery
cortadocodes Mar 6, 2024
344e9fb
REF: Remove excess whitespace from BigQuery queries
cortadocodes Mar 6, 2024
e5f184d
TST: Test BigQuery queries
cortadocodes Mar 6, 2024
b719895
OPS: Remove default bigquery table expiry
cortadocodes Mar 6, 2024
f4e8ceb
ENH: Sort events from BigQuery by message number
cortadocodes Mar 6, 2024
488957e
FIX: Always include attributes with events from bigquery
cortadocodes Mar 6, 2024
5187bf7
REF: Factor out event handlers into `EventHandler` class
cortadocodes Mar 6, 2024
9987f81
REF: Move `validation` module into `octue.cloud.events` subpackage
cortadocodes Mar 6, 2024
1bc9407
REF: Factor out more from message handler into event handler
cortadocodes Mar 6, 2024
4721bec
ENH: Rename "data" column to "event" when getting from bigquery
cortadocodes Mar 6, 2024
a98196d
FIX: Convert JSON to python primitives when getting from bigquery
cortadocodes Mar 6, 2024
6e6916a
FEA: Add event replayer
cortadocodes Mar 6, 2024
69997b5
REF: Rename `event_handler` module to `handler`
cortadocodes Mar 6, 2024
3504583
REF: Rename `EventHandler` to `AbstractEventHandler`
cortadocodes Mar 6, 2024
533065a
REF: Rename `OrderedMessageHandler` to `PubSubEventHandler`
cortadocodes Mar 6, 2024
585e0a8
REF: Rename `handle_messages` method to `handle_events`
cortadocodes Mar 6, 2024
9d25f0a
REF: Rename "message" to "event" in event handler classes
cortadocodes Mar 6, 2024
b4ce92c
REF: Rename `PubSubEventHandler` to `GoogleCloudPubSubEventHandler`
cortadocodes Mar 11, 2024
c61f5d9
REF: Rename `GooglePubSubHandler` to `GoogleCloudPubSubHandler`
cortadocodes Mar 11, 2024
945e466
ENH: Allow skipping of non-result events in event handler
cortadocodes Mar 11, 2024
c44b80c
ENH: Send/get sender SRUID in/from event attributes
cortadocodes Mar 11, 2024
bd00029
TST: Rename test module
cortadocodes Mar 11, 2024
30f59d7
REF: Factor out getting question UUID into `AbstractEventHandler`
cortadocodes Mar 11, 2024
68f7f3c
FIX: Update usage of event handler in `Service`
cortadocodes Mar 11, 2024
30bec30
FIX: Extract new `sender` attribute from Pub/Sub messages
cortadocodes Mar 11, 2024
3a5970c
ENH: Return download path from `Dataset.download`
cortadocodes Mar 11, 2024
6d98a29
FEA: Add `Manifest.download` method
cortadocodes Mar 11, 2024
0b0266b
ENH: Use version `0.8.3` of the service communication event schema
cortadocodes Mar 11, 2024
e1e77b6
FIX: Set `sender` to "REMOTE" when not specified
cortadocodes Mar 11, 2024
958fbef
ENH: Include question UUID in delivery acknowledgement log message
cortadocodes Mar 11, 2024
13b9041
CHO: Update licence year to 2024
cortadocodes Mar 14, 2024
5bb5fea
OPS: Add cloud function and update bigquery table in terraform config
cortadocodes Mar 18, 2024
a8ba6f9
ENH: Allow `sender_type=None` in `create_push_subscription`
cortadocodes Mar 19, 2024
06d029e
ENH: Allow specifying a filter in `create-push-subscription` CLI command
cortadocodes Mar 19, 2024
7c80690
DOC: Improve CLI command help message
cortadocodes Mar 19, 2024
c5285b3
OPS: Use reusable workflows
cortadocodes Mar 19, 2024
79732f7
ENH: Add ability to add suffix to subscription name in CLI
cortadocodes Mar 19, 2024
b840e18
WIP: Add commented out pub/sub trigger for cloud function
cortadocodes Mar 21, 2024
199a339
OPS: Fix workflow description
cortadocodes Mar 21, 2024
78ca79a
TST: Fix test description
cortadocodes Mar 21, 2024
c08dba1
REF: Improve clarity of `AbstractEventHandler`
cortadocodes Mar 21, 2024
696ee99
DOC: Add docstrings to `EventReplayer`
cortadocodes Mar 21, 2024
e6ef7a7
REF: Rename `extract_event_and_attributes_from_pub_sub`
cortadocodes Mar 21, 2024
74fb897
REF: Improve clarity of `GoogleCloudPubSubEventHandler`
cortadocodes Mar 21, 2024
1bd36fe
DOC: Add missing param to docstring
cortadocodes Mar 21, 2024
00ae871
REF: Replace `bigquery_table_id` argument with `asynchronous`
cortadocodes Mar 21, 2024
49e6af4
DOC: Add class-string to `AbstractEventHandler`
cortadocodes Mar 21, 2024
86632cf
REF: Move pub/sub event handler into `octue.cloud.pub_sub.events`
cortadocodes Mar 21, 2024
0eb1dfe
FIX: Ensure push subscription always returned from `Service.ask`
cortadocodes Mar 21, 2024
811cc94
TST: Remove ordering from test pass criteria for `Manifest.download`
cortadocodes Mar 21, 2024
afe5ffa
TST: Test `get_sruid_from_pub_sub_resource_name`
cortadocodes Mar 21, 2024
4526148
ENH: Add recipient and originator event attributes
cortadocodes Mar 22, 2024
47c8af2
FIX: Require all question event attributes
cortadocodes Mar 27, 2024
55eee94
ENH: Give every event a UUID
cortadocodes Mar 27, 2024
f2cb0e2
REF: Rename `message_number` to `ordering_key`
cortadocodes Mar 27, 2024
ed64727
FIX: Only update earliest waiting message number if waiting messages
cortadocodes Mar 27, 2024
4daa88e
ENH: Add mandatory originator, sender, and recipient event attributes
cortadocodes Mar 27, 2024
78117e2
FIX: Rename `ordering_key` to `order`
cortadocodes Mar 27, 2024
17e6dfa
REF: Rename `version` attribute to `sender_sdk_version`
cortadocodes Mar 28, 2024
f61f38a
FIX: Avoid getting earliest waiting message if there isn't one
cortadocodes Mar 28, 2024
562d2b4
FIX: Avoid silently failing if `question_uuid` attribute missing
cortadocodes Mar 28, 2024
95da7cd
REF: Move `OCTUE_SERVICES_NAMESPACE` to package root
cortadocodes Mar 28, 2024
76127e9
FEA: Allow specification of services namespace via `octue.yaml`
cortadocodes Mar 28, 2024
9e7a772
REF: Remove adding of services namespace to topics and subscriptions
cortadocodes Mar 28, 2024
da93219
REF: Rename `OCTUE_SERVICES_NAMESPACE`
cortadocodes Mar 28, 2024
059cab3
ENH: Add services namespace to `GCPPubSubBackend`
cortadocodes Mar 28, 2024
263377e
FEA: Publish/subscribe to single topic in `Service`
cortadocodes Mar 28, 2024
6ec4f5e
REF: Switch back to unsplit SRUIDs in event attributes
cortadocodes Mar 28, 2024
22befcc
FIX: Add correct recipient to event attributes
cortadocodes Mar 28, 2024
974f52c
FIX: Avoid circular imports
cortadocodes Mar 28, 2024
7c7bf51
ENH: Update Pub/Sub emulators to use a single topic
cortadocodes Mar 28, 2024
807ae75
TST: Update pub/sub event tests
cortadocodes Apr 2, 2024
f22b635
TST: Update pub/sub logging tests
cortadocodes Apr 2, 2024
166d1a2
TST: Update service tests
cortadocodes Apr 2, 2024
df62601
FIX: Fix event order
cortadocodes Apr 2, 2024
e3a1b3f
TST: Uncomment service tests
cortadocodes Apr 2, 2024
414a75f
OPS: Add `octue.services` topic
cortadocodes Apr 2, 2024
a572b54
TST: Update more tests
cortadocodes Apr 2, 2024
da45d91
FIX: Shorten answer subscription filter
cortadocodes Apr 2, 2024
1140979
TST: Update child emulator tests
cortadocodes Apr 8, 2024
6ea4668
ENH: Update CLI command to use single topic per workspace
cortadocodes Apr 8, 2024
e61013a
DOC: Update docstrings
cortadocodes Apr 8, 2024
7472cd9
ENH: Use latest services communication schema
cortadocodes Apr 8, 2024
57cff9e
FIX: Update `get_sruid_from_pub_sub_resource_name`
cortadocodes Apr 8, 2024
feadb81
TST: Remove unnecessary `octue.services`
cortadocodes Apr 8, 2024
a25d919
REF: Move event counter out of `Topic` and into `Service`
cortadocodes Apr 8, 2024
09fc809
REF: Move unrelated code out of thread lock
cortadocodes Apr 8, 2024
e401a71
REF: Factor out services topic in `Service`
cortadocodes Apr 8, 2024
1e5d634
OPS: Update bigquery table and event handler cloud function
cortadocodes Apr 8, 2024
5b89aaf
FIX: Restore answer subscription names to previous format
cortadocodes Apr 9, 2024
ddf7100
DOC: Update `Service` docstrings
cortadocodes Apr 9, 2024
82db91e
TST: Simplify `GoogleCloudPubSubHandler` tests
cortadocodes Apr 9, 2024
c5075b4
ENH: Make `Topic`'s representation consistent with `Subscription`'s
cortadocodes Apr 9, 2024
2b96b82
TST: Update pub/sub event handler tests
cortadocodes Apr 9, 2024
f221b8e
TST: Simplify pub/sub event handler tests
cortadocodes Apr 9, 2024
c77f7f4
TST: Factor out patching to start of services test class
cortadocodes Apr 9, 2024
38d687f
TST: Factor out service patching in pub/sub event handler tests
cortadocodes Apr 9, 2024
19632f3
FIX: Allow services to be instantiated without GCP credentials
cortadocodes Apr 9, 2024
0fc802b
TST: Factor out service patching in child tests
cortadocodes Apr 9, 2024
aa37402
ENH: Add string representation to `MockMessageWrapper`
cortadocodes Apr 9, 2024
426e765
FIX: Fix race condition in event emission order
cortadocodes Apr 9, 2024
67a2490
REF: Rename `receiving_service` to `recipient`
cortadocodes Apr 9, 2024
242d097
REF: Rename `Service._send_message` to `Service._emit_event`
cortadocodes Apr 9, 2024
4a5ba60
REF: Make services prefix a constant
cortadocodes Apr 9, 2024
0fcdc97
REF: Rename `Service.emit_event` to `Service._emit_event`
cortadocodes Apr 9, 2024
7ccb020
TST: Test error is raised if service topic is missing
cortadocodes Apr 9, 2024
a54c04b
TST: Update cloud deployment test
cortadocodes Apr 9, 2024
bc4224c
MRG: Merge pull request #639 from octue/use-single-topic-per-workspace
cortadocodes Apr 9, 2024
18dcd7c
DOC: Add missing word to docstring
cortadocodes Apr 9, 2024
a9981f5
CHO: Remove BigQuery subscription abilities
cortadocodes Apr 9, 2024
19dc241
DOC: Correct docstring
cortadocodes Apr 9, 2024
d73b0d3
REF: Improve `AbstractEventHandler` docstring and rename attribute
cortadocodes Apr 10, 2024
32d9ded
REF: Improve clarity of `AbstractEventHandler`
cortadocodes Apr 10, 2024
43f7292
FIX: Handle invalid events correctly
cortadocodes Apr 10, 2024
da845f9
ENH: Make `EventReplayer` clearer and improve logging
cortadocodes Apr 10, 2024
fc8e3b6
TST: Test `EventHandler` with no, no valid, or no result events
cortadocodes Apr 10, 2024
0d09f77
FIX: Simplify Pub/Sub event extraction and avoid pre-validation errors
cortadocodes Apr 10, 2024
664d42c
ENH: Improve `GoogleCloudPubSubEventHandler` docstrings and logs
cortadocodes Apr 10, 2024
0adf534
ENH: Improve log messages and docstrings in `Service`
cortadocodes Apr 10, 2024
de329a7
ENH: Return push subscriptions from `Child.ask`
cortadocodes Apr 10, 2024
f713d40
REF: Rename `service_id` to `recipient`
cortadocodes Apr 10, 2024
a606952
DOC: Update child docstring
cortadocodes Apr 10, 2024
7070f01
TST: Restore unmodified service tests
cortadocodes Apr 10, 2024
273dcd9
TST: Add assertion to test
cortadocodes Apr 10, 2024
2e9547a
TST: Improve `GoogleCloudPubSubEventHandler` tests
cortadocodes Apr 10, 2024
ad8e26a
OPS: Update bigquery table and cloud function
cortadocodes Apr 10, 2024
17996a1
ENH: Update `get_events` function for new event store schema
cortadocodes Apr 10, 2024
ca610aa
OPS: Use fixed event handler cloud function
cortadocodes Apr 10, 2024
ad39bda
REF: Rename `received/record_messages` to `received/record_events`
cortadocodes Apr 10, 2024
64b888a
REF: Factor out resetting event handlers
cortadocodes Apr 10, 2024
9ec3f1f
REF: Move earliest waiting event number calculation into superclass
cortadocodes Apr 10, 2024
f1992ca
ENH: Add `datetime` attribute to all events
cortadocodes Apr 11, 2024
8448560
OPS: Upgrade to latest event store format
cortadocodes Apr 11, 2024
61ebe47
ENH: Use latest services communication schema
cortadocodes Apr 11, 2024
480f0ae
ENH: Add new event store fields to `get_events` function
cortadocodes Apr 11, 2024
a5930e4
REF: Update `ChildEmulator` to use `event` instead of `message`
cortadocodes Apr 11, 2024
2d708fd
TST: Create `octue.services` mock topic once per test run
cortadocodes Apr 11, 2024
2677114
TST: Fix tests
cortadocodes Apr 11, 2024
b8d26fb
TST: Update test class names
cortadocodes Apr 11, 2024
75ca18b
ENH: Issue deprecation warning if using `messages` for child emulator
cortadocodes Apr 11, 2024
1016831
DOC: Document `Manifest.download` method
cortadocodes Apr 11, 2024
2f36b98
DOC: Update `Child` docstrings
cortadocodes Apr 11, 2024
26532f8
DOC: Document asynchronous questions and answer retrieval
cortadocodes Apr 11, 2024
933b4ec
DOC: Update copyright year in `conf.py`
cortadocodes Apr 11, 2024
7ff11b8
DOC: Fix docs typos
cortadocodes Apr 11, 2024
c83303f
DOC: Update child emulator documentation
cortadocodes Apr 11, 2024
14481ac
OPS: Update codecov GitHub actions and provide token
cortadocodes Apr 11, 2024
9ae506e
CHO: Add version compatibility data
cortadocodes Apr 11, 2024
a759b4c
DOC: Remove version compatbility information for versions `<0.40.0`
cortadocodes Apr 11, 2024
cbe5eb6
DOC: Update inter-service compatibility doc
cortadocodes Apr 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,10 @@ on:
jobs:
check-semantic-version:
if: "!contains(github.event.head_commit.message, 'skipci')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: octue/[email protected]
with:
path: pyproject.toml
breaking_change_indicated_by: minor
uses: octue/workflows/.github/workflows/check-semantic-version.yml@main
with:
path: pyproject.toml
breaking_change_indicated_by: minor

run-tests:
if: "!contains(github.event.head_commit.message, 'skipci')"
Expand Down Expand Up @@ -68,10 +63,11 @@ jobs:
run: tox -vv -e py

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: coverage.xml
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

test-publish:
if: "!contains(github.event.head_commit.message, 'skipci')"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ jobs:
run: tox -vv -e py

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: coverage.xml
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}

outputs:
package_version: ${{ steps.get-package-version.outputs.PACKAGE_VERSION }}
Expand Down
22 changes: 7 additions & 15 deletions .github/workflows/update-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,13 @@

name: update-pull-request

on: pull_request
on: [pull_request]

jobs:
description:
if: "!contains(github.event.pull_request.body, '<!--- SKIP AUTOGENERATED NOTES --->')"
runs-on: ubuntu-latest
steps:
- uses: octue/[email protected]
id: pr-description
with:
pull_request_url: ${{ github.event.pull_request.url }}
api_token: ${{ secrets.GITHUB_TOKEN }}

- name: Update pull request body
uses: riskledger/update-pr-description@v2
with:
body: ${{ steps.pr-description.outputs.pull_request_description }}
token: ${{ secrets.GITHUB_TOKEN }}
uses: octue/workflows/.github/workflows/generate-pull-request-description.yml@main
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: read
pull-requests: write
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ octue-sdk-python Application SDK for python-based apps on the Octue platform

MIT License

Copyright (c) 2017-2022 Octue Ltd
Copyright (c) 2017-2024 Octue Ltd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
150 changes: 140 additions & 10 deletions docs/source/asking_questions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,27 @@
Asking services questions
=========================

How to ask a question
=====================
What is a question?
===================
A question is a set of data (input values and/or an input manifest) sent to a child for processing/analysis. Questions
can be:

- **Synchronous ("ask-and-wait"):** A question whose answer is waited for in real time

- **Asynchronous ("fire-and-forget"):** A question whose answer is not waited for and is instead retrieved later. There
are two types:

- **Regular:** Responses to these questions are automatically stored in an event store where they can be :ref:`retrieved using the Octue SDK <retrieving_asynchronous_answers>`

- **Push endpoint:** Responses to these questions are pushed to an HTTP endpoint for asynchronous handling using Octue's
`django-twined <https://django-twined.readthedocs.io/en/latest/>`_ or custom logic in your own webserver.

Questions are always asked to a *revision* of a service. You can ask a service a question if you have its
:ref:`SRUID <sruid_definition>`, project name, and the necessary permissions. The question is formed of input values
and/or an input manifest.
:ref:`SRUID <sruid_definition>`, project name, and the necessary permissions.


Asking a question
=================

.. code-block:: python

Expand Down Expand Up @@ -47,19 +63,133 @@ You can also set the following options when you call :mod:`Child.ask <octue.reso
- ``subscribe_to_logs`` - if true, the child will forward its logs to you
- ``allow_local_files`` - if true, local files/datasets are allowed in any input manifest you supply
- ``handle_monitor_message`` - if provided a function, it will be called on any monitor messages from the child
- ``record_messages_to`` – if given a path to a JSON file, messages received from the parent while it processes the question are saved to it
- ``record_events`` – if ``True``, events received from the parent while it processes the question are saved to the ``Child.received_events`` property
- ``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 the analysis fails
- ``question_uuid`` - if provided, the question will use this UUID instead of a generated one
- ``push_endpoint`` - if provided, the result and other events produced during the processing of the question will be pushed to this HTTP endpoint (a URL)
- ``asynchronous`` - if ``True``, don't wait for an answer to the question (the result and other events can be :ref:`retrieved from the event store later <retrieving_asynchronous_answers>`)
- ``timeout`` - how long in seconds to wait for an answer (``None`` by default - i.e. don't time out)

Exceptions raised by a child
----------------------------
If a child raises an exception while processing your question, the exception will always be forwarded and re-raised in
your local service or python session. You can handle exceptions in whatever way you like.

If setting a timeout, bear in mind that the question has to reach the child, the child has to run its analysis on
the inputs sent to it (this most likely corresponds to the dominant part of the wait time), and the answer has to be
sent back to the parent. If you're not sure how long a particular analysis might take, it's best to set the timeout to
``None`` initially or ask the owner/maintainer of the child for an estimate.
Timeouts
--------
If setting a timeout, bear in mind that the question has to reach the child, the child has to run its analysis on the
inputs sent to it (this will most likely make up the dominant part of the wait time), and the answer has to be sent back
to the parent. If you're not sure how long a particular analysis might take, it's best to set the timeout to ``None``
initially or ask the owner/maintainer of the child for an estimate.


.. _retrieving_asynchronous_answers:

Retrieving answers to asynchronous questions
============================================
To retrieve results and other events from the processing of a question later, make sure you have the permissions to
access the event store and run:

.. code-block:: python

from octue.cloud.pub_sub.bigquery import get_events

events = get_events(
table_id="your-project.your-dataset.your-table",
sender="octue/test-service:1.0.0",
question_uuid="53353901-0b47-44e7-9da3-a3ed59990a71",
)


**Options**

- ``kind`` - Only retrieve this kind of event if present (e.g. "result")
- ``include_attributes`` - If ``True``, retrieve all the events' attributes as well
- ``include_backend_metadata`` - If ``True``, retrieve information about the service backend that produced the event
- ``limit`` - If set to a positive integer, limit the number of events returned to this


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

.. code-block:: python

>>> events
[
{
"event": {
"datetime": "2024-03-06T15:44:18.156044",
"kind": "delivery_acknowledgement"
},
},
{
"event": {
"kind": "log_record",
"log_record": {
"args": null,
"created": 1709739861.5949728,
"exc_info": null,
"exc_text": null,
"filename": "app.py",
"funcName": "run",
"levelname": "INFO",
"levelno": 20,
"lineno": 28,
"module": "app",
"msecs": 594.9728488922119,
"msg": "Finished example analysis.",
"name": "app",
"pathname": "/workspace/example_service_cloud_run/app.py",
"process": 2,
"processName": "MainProcess",
"relativeCreated": 8560.13798713684,
"stack_info": null,
"thread": 68328473233152,
"threadName": "ThreadPoolExecutor-0_2"
}
},
},
{
"event": {
"datetime": "2024-03-06T15:46:18.167424",
"kind": "heartbeat"
},
"attributes": {
"datetime": "2024-04-11T10:46:48.236064",
"uuid": "a9de11b1-e88f-43fa-b3a4-40a590c3443f",
"order": "7",
"question_uuid": "d45c7e99-d610-413b-8130-dd6eef46dda6",
"originator": "octue/test-service:1.0.0",
"sender": "octue/test-service:1.0.0",
"sender_type": "CHILD",
"sender_sdk_version": "0.51.0",
"recipient": "octue/another-service:3.2.1"
}
}
{
"event": {
"kind": "result",
"output_manifest": {
"datasets": {
"example_dataset": {
"files": [
"gs://octue-sdk-python-test-bucket/example_output_datasets/example_dataset/output.dat"
],
"id": "419bff6b-08c3-4c16-9eb1-5d1709168003",
"labels": [],
"name": "divergent-strange-gharial-of-pizza",
"path": "https://storage.googleapis.com/octue-sdk-python-test-bucket/example_output_datasets/example_dataset/.signed_metadata_files/divergent-strange-gharial-of-pizza",
"tags": {}
}
},
"id": "a13713ae-f207-41c6-9e29-0a848ced6039",
"name": null
},
"output_values": [1, 2, 3, 4, 5]
},
},
]

----

Asking multiple questions in parallel
=====================================
Expand All @@ -81,7 +211,7 @@ raised and no answers are returned.

This method uses multithreading, allowing all the questions to be asked at once instead of one after another.

Options:
**Options**

- If ``raise_errors=False`` is provided, answers are returned for all successful questions while unraised errors are
returned for unsuccessful ones
Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
# General information about the project.
project = "Octue SDK (Python)"
author = "Octue Ltd"
copyright = "2022, Octue Ltd"
copyright = "2024, Octue Ltd"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
Loading
Loading