Skip to content

Commit 93e1a12

Browse files
committed
Update the tutotial section "Upload and download files to and from
IDS" to use the new format of the conditions argument when creating queries.
1 parent 38decc0 commit 93e1a12

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

doc/src/tutorial-ids.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ We need a dataset in ICAT that the uploaded files should be put into,
5454
so let's create one::
5555

5656
>>> from icat.query import Query
57-
>>> query = Query(client, "Investigation", conditions={"name": "= '12100409-ST'"})
57+
>>> query = Query(client, "Investigation", conditions=[("name", "= '12100409-ST'")])
5858
>>> investigation = client.assertedSearch(query)[0]
5959
>>> dataset = client.new("Dataset")
6060
>>> dataset.investigation = investigation
61-
>>> query = Query(client, "DatasetType", conditions={"name": "= 'other'"})
61+
>>> query = Query(client, "DatasetType", conditions=[("name", "= 'other'")])
6262
>>> dataset.type = client.assertedSearch(query)[0]
6363
>>> dataset.name = "greetings"
6464
>>> dataset.complete = False
@@ -67,7 +67,7 @@ so let's create one::
6767
For each of the files, we create a new datafile object and call the
6868
:meth:`~icat.client.Client.putData` method to upload it::
6969

70-
>>> query = Query(client, "DatafileFormat", conditions={"name": "= 'Text'"})
70+
>>> query = Query(client, "DatafileFormat", conditions=[("name", "= 'Text'")])
7171
>>> df_format = client.assertedSearch(query)[0]
7272
>>> for fname in ("greet-jdoe.txt", "greet-nbour.txt", "greet-rbeck.txt"):
7373
... datafile = client.new("Datafile",
@@ -131,10 +131,10 @@ Download files
131131
We can request a download of a set of data using the
132132
:meth:`~icat.client.Client.getData` method::
133133

134-
>>> query = Query(client, "Datafile", conditions={
135-
... "name": "= 'greet-jdoe.txt'",
136-
... "dataset.name": "= 'greetings'"
137-
... })
134+
>>> query = Query(client, "Datafile", conditions=[
135+
... ("name", "= 'greet-jdoe.txt'"),
136+
... ("dataset.name", "= 'greetings'"),
137+
... ])
138138
>>> df = client.assertedSearch(query)[0]
139139
>>> data = client.getData([df])
140140
>>> type(data)
@@ -153,7 +153,7 @@ with the requested files::
153153

154154
>>> from io import BytesIO
155155
>>> from zipfile import ZipFile
156-
>>> query = Query(client, "Dataset", conditions={"name": "= 'greetings'"})
156+
>>> query = Query(client, "Dataset", conditions=[("name", "= 'greetings'")])
157157
>>> ds = client.assertedSearch(query)[0]
158158
>>> data = client.getData([ds])
159159
>>> buffer = BytesIO(data.read())

doc/tutorial/ids.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
# --------------------
1414

1515
from icat.query import Query
16-
query = Query(client, "Investigation", conditions={"name": "= '12100409-ST'"})
16+
query = Query(client, "Investigation", conditions=[("name", "= '12100409-ST'")])
1717
investigation = client.assertedSearch(query)[0]
1818
dataset = client.new("Dataset")
1919
dataset.investigation = investigation
20-
query = Query(client, "DatasetType", conditions={"name": "= 'other'"})
20+
query = Query(client, "DatasetType", conditions=[("name", "= 'other'")])
2121
dataset.type = client.assertedSearch(query)[0]
2222
dataset.name = "greetings"
2323
dataset.complete = False
2424
dataset.create()
2525

2626
# --------------------
2727

28-
query = Query(client, "DatafileFormat", conditions={"name": "= 'Text'"})
28+
query = Query(client, "DatafileFormat", conditions=[("name", "= 'Text'")])
2929
df_format = client.assertedSearch(query)[0]
3030
for fname in ("greet-jdoe.txt", "greet-nbour.txt", "greet-rbeck.txt"):
3131
datafile = client.new("Datafile",
@@ -36,10 +36,10 @@
3636

3737
# Download files
3838

39-
query = Query(client, "Datafile", conditions={
40-
"name": "= 'greet-jdoe.txt'",
41-
"dataset.name": "= 'greetings'"
42-
})
39+
query = Query(client, "Datafile", conditions=[
40+
("name", "= 'greet-jdoe.txt'"),
41+
("dataset.name", "= 'greetings'"),
42+
])
4343
df = client.assertedSearch(query)[0]
4444
data = client.getData([df])
4545
type(data)
@@ -49,7 +49,7 @@
4949

5050
from io import BytesIO
5151
from zipfile import ZipFile
52-
query = Query(client, "Dataset", conditions={"name": "= 'greetings'"})
52+
query = Query(client, "Dataset", conditions=[("name", "= 'greetings'")])
5353
ds = client.assertedSearch(query)[0]
5454
data = client.getData([ds])
5555
buffer = BytesIO(data.read())

0 commit comments

Comments
 (0)