From 63b583be42fbe69349cee9b3be01a7a056e5eb04 Mon Sep 17 00:00:00 2001 From: Dan Allan Date: Thu, 7 Mar 2024 08:12:56 -0500 Subject: [PATCH] Fix mistakes in register example (#681) * Fix mistakes in register examples * Fix indentation and use enum. Co-authored-by: Padraic Shafer <76011594+padraic-shafer@users.noreply.github.com> * Import enum Co-authored-by: Padraic Shafer <76011594+padraic-shafer@users.noreply.github.com> * Add structure --------- Co-authored-by: Padraic Shafer <76011594+padraic-shafer@users.noreply.github.com> --- docs/source/how-to/register.md | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/docs/source/how-to/register.md b/docs/source/how-to/register.md index 762eca8e7..62411c72f 100644 --- a/docs/source/how-to/register.md +++ b/docs/source/how-to/register.md @@ -76,22 +76,37 @@ Use the Python client, as in this example. ```py from tiled.client import from_uri -from tiled.client.data_source import Asset, DataSource from tiled.structures.core import StructureFamily +from tiled.structures.data_source import Asset, DataSource, Management +from tiled.structures.array import ArrayStructure, BuiltinDtype # You can pass the api_key in explicitly as shown here, but for security, it # is best to set the API key in the environment variable TILED_API_KEY, which # from_uri(...) will automatically detect and use. client = from_uri("http://localhost:8000", api_key="...") +structure = ArrayStructure( + dtype=BuiltinDtype.from_numpy_dtype(numpy.int32), + shape=(2, 512, 512), + chunks=((1, 1), (512,), (512,)), + dims=("time", "x", "y"), # optional +) + # POST /api/v1/register/{path} client.new( structure_family=StructureFamily.array, - data_sources=DataSource( - assets=[Asset(data_uri="file:///...", num=1), Asset(data_uri="file:///...", num=2)], - mimetype="multipart/related;type=image/tiff", - structure_family=StructureFamily.array, - ), + data_sources=[ + DataSource( + management=Management.external, + mimetype="multipart/related;type=image/tiff", + structure_family=StructureFamily.array, + structure=structure, + assets=[ + Asset(data_uri="file:///...", num=1), + Asset(data_uri="file:///...", num=2), + ], + ), + ], metadata={}, specs=[], )