Skip to content

Commit

Permalink
Fix mistakes in register example (#681)
Browse files Browse the repository at this point in the history
* Fix mistakes in register examples

* Fix indentation and use enum.

Co-authored-by: Padraic Shafer <[email protected]>

* Import enum

Co-authored-by: Padraic Shafer <[email protected]>

* Add structure

---------

Co-authored-by: Padraic Shafer <[email protected]>
  • Loading branch information
danielballan and padraic-shafer authored Mar 7, 2024
1 parent acfa2a2 commit 63b583b
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions docs/source/how-to/register.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=[],
)
Expand Down

0 comments on commit 63b583b

Please sign in to comment.