From 93e1a1241c2e82bfb5c6222233f87efbbff3b5be Mon Sep 17 00:00:00 2001 From: Rolf Krahl Date: Thu, 29 Aug 2024 20:44:37 +0200 Subject: [PATCH] Update the tutotial section "Upload and download files to and from IDS" to use the new format of the conditions argument when creating queries. --- doc/src/tutorial-ids.rst | 16 ++++++++-------- doc/tutorial/ids.py | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/doc/src/tutorial-ids.rst b/doc/src/tutorial-ids.rst index c71d221e..4a76fdf5 100644 --- a/doc/src/tutorial-ids.rst +++ b/doc/src/tutorial-ids.rst @@ -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 @@ -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'")]) >>> df_format = client.assertedSearch(query)[0] >>> for fname in ("greet-jdoe.txt", "greet-nbour.txt", "greet-rbeck.txt"): ... datafile = client.new("Datafile", @@ -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) @@ -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()) diff --git a/doc/tutorial/ids.py b/doc/tutorial/ids.py index f3156039..c525f85b 100644 --- a/doc/tutorial/ids.py +++ b/doc/tutorial/ids.py @@ -13,11 +13,11 @@ # -------------------- 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 @@ -25,7 +25,7 @@ # -------------------- -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", @@ -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) @@ -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())