Skip to content

Commit

Permalink
Update the tutotial section "Upload and download files to and from
Browse files Browse the repository at this point in the history
IDS" to use the new format of the conditions argument when creating
queries.
  • Loading branch information
RKrahl committed Aug 29, 2024
1 parent 38decc0 commit 93e1a12
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions doc/src/tutorial-ids.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ We need a dataset in ICAT that the uploaded files should be put into,
so let's create one::

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

>>> query = Query(client, "DatafileFormat", conditions={"name": "= 'Text'"})
>>> query = Query(client, "DatafileFormat", conditions=[("name", "= 'Text'")])

Check failure on line 70 in doc/src/tutorial-ids.rst

View workflow job for this annotation

GitHub Actions / doc8

D001

Line too long
>>> df_format = client.assertedSearch(query)[0]
>>> for fname in ("greet-jdoe.txt", "greet-nbour.txt", "greet-rbeck.txt"):
... datafile = client.new("Datafile",
Expand Down Expand Up @@ -131,10 +131,10 @@ Download files
We can request a download of a set of data using the
:meth:`~icat.client.Client.getData` method::

>>> query = Query(client, "Datafile", conditions={
... "name": "= 'greet-jdoe.txt'",
... "dataset.name": "= 'greetings'"
... })
>>> query = Query(client, "Datafile", conditions=[
... ("name", "= 'greet-jdoe.txt'"),
... ("dataset.name", "= 'greetings'"),
... ])
>>> df = client.assertedSearch(query)[0]
>>> data = client.getData([df])
>>> type(data)
Expand All @@ -153,7 +153,7 @@ with the requested files::

>>> from io import BytesIO
>>> from zipfile import ZipFile
>>> query = Query(client, "Dataset", conditions={"name": "= 'greetings'"})
>>> query = Query(client, "Dataset", conditions=[("name", "= 'greetings'")])
>>> ds = client.assertedSearch(query)[0]
>>> data = client.getData([ds])
>>> buffer = BytesIO(data.read())
Expand Down
16 changes: 8 additions & 8 deletions doc/tutorial/ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
# --------------------

from icat.query import Query
query = Query(client, "Investigation", conditions={"name": "= '12100409-ST'"})
query = Query(client, "Investigation", conditions=[("name", "= '12100409-ST'")])
investigation = client.assertedSearch(query)[0]
dataset = client.new("Dataset")
dataset.investigation = investigation
query = Query(client, "DatasetType", conditions={"name": "= 'other'"})
query = Query(client, "DatasetType", conditions=[("name", "= 'other'")])
dataset.type = client.assertedSearch(query)[0]
dataset.name = "greetings"
dataset.complete = False
dataset.create()

# --------------------

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

# Download files

query = Query(client, "Datafile", conditions={
"name": "= 'greet-jdoe.txt'",
"dataset.name": "= 'greetings'"
})
query = Query(client, "Datafile", conditions=[
("name", "= 'greet-jdoe.txt'"),
("dataset.name", "= 'greetings'"),
])
df = client.assertedSearch(query)[0]
data = client.getData([df])
type(data)
Expand All @@ -49,7 +49,7 @@

from io import BytesIO
from zipfile import ZipFile
query = Query(client, "Dataset", conditions={"name": "= 'greetings'"})
query = Query(client, "Dataset", conditions=[("name", "= 'greetings'")])
ds = client.assertedSearch(query)[0]
data = client.getData([ds])
buffer = BytesIO(data.read())
Expand Down

0 comments on commit 93e1a12

Please sign in to comment.