Skip to content

Commit d0d6609

Browse files
committed
DOC: Add python code to getting started guide
skipci
1 parent a651472 commit d0d6609

File tree

1 file changed

+47
-7
lines changed

1 file changed

+47
-7
lines changed

docs/index.md

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Before you begin, ensure you:
1414

1515
<!-- prettier-ignore-start -->
1616

17-
- Are familiar with Python
17+
- Are familiar with Python and/or the command line
1818
- Have the following tools installed:
1919
- Python >= 3.10
2020
- The `octue` python library / CLI (see [installation instructions](installation.md))
@@ -35,7 +35,7 @@ No authentication is needed to run the example data service. To authenticate for
3535

3636
### Send a question
3737

38-
The following shell command asks a question to the local example data service:
38+
The following command asks a question to the local example data service.
3939

4040
=== "CLI"
4141

@@ -45,23 +45,57 @@ The following shell command asks a question to the local example data service:
4545

4646
!!! tip
4747

48-
To ask a question to a real data service, the command is almost the same:
48+
To ask a question to a real data service, use the `remote` subcommand and specify the ID of the service:
4949

5050
```shell
51-
octue twined question ask remote --input-values='{"some": "data"}'
51+
octue twined question ask remote some-org/a-service:1.2.0 --input-values='{"some": "data"}'
5252
```
5353

5454
=== "Python"
5555

56-
```shell
56+
!!! info
57+
58+
A child is a Twined service you ask a question to (in the sense of child and parent nodes in a tree; this only
59+
becomes important when services use other Twined services as part of their analysis).
60+
61+
```python
62+
from octue.twined.resources import Child
5763

64+
child = Child(
65+
id="local/example:latest",
66+
backend={
67+
"name": "GCPPubSubBackend",
68+
"project_id": "example-project",
69+
},
70+
)
71+
72+
answer, question_uuid = child.ask(input_values={"some": "data"})
5873
```
5974

75+
!!! tip
76+
77+
To ask a question to a real data service, just specify its ID and project ID:
78+
79+
```python
80+
from octue.twined.resources import Child
81+
82+
child = Child(
83+
id="some-org/a-service:1.2.0",
84+
backend={
85+
"name": "GCPPubSubBackend",
86+
"project_id": "some-org",
87+
},
88+
)
89+
90+
answer, question_uuid = child.ask(input_values={"some": "data"})
91+
```
92+
6093
### Receive an answer
6194

6295
=== "CLI"
6396

64-
The output from asking a question usually contains log messages followed by the answer as [JSON](https://en.wikipedia.org/wiki/JSON):
97+
The output is automatically written to the command line. It contains log messages followed by the answer as
98+
[JSON](https://en.wikipedia.org/wiki/JSON):
6599

66100
```text
67101
[2025-09-23 18:20:13,513 | WARNING | octue.resources.dataset] <Dataset('cleaned_met_mast_data')> is empty at instantiation time (path 'cleaned_met_mast_data').
@@ -88,8 +122,14 @@ The following shell command asks a question to the local example data service:
88122

89123
=== "Python"
90124

91-
```shell
125+
```python
126+
answer
92127

128+
>>> {
129+
"kind": "result",
130+
"output_values": {"some": "output", "heights": [1, 2, 3, 4, 5]},
131+
"output_manifest": {"id": "2e1fb3e4-2f86-4eb2-9c2f-5785d36c6df9", "name": null, "datasets": {"cleaned_met_mast_data": "/var/folders/9p/25hhsy8j4wv66ck3yylyz97c0000gn/T/tmps_qcb4yw"}},
132+
}
93133
```
94134

95135
## Next steps

0 commit comments

Comments
 (0)