-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write block tutorial #696
base: main
Are you sure you want to change the base?
Write block tutorial #696
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a very informative and useful addition to the tutorials. There are some inline comments ranging from copy editing to structural considerations.
docs/source/tutorials/writing.md
Outdated
ArrayStructure(data_type=BuiltinDtype(endianness='not_applicable', kind=<Kind.integer: 'i'>, itemsize=1), chunks=((1, 1, 1, 1, 1), (32,), (32,)), shape=(5, 32, 32), dims=None, resizable=False) | ||
|
||
# Allocate a new array client in tiled | ||
>>> array_client = client.new(structure_family="array", structure=structure, key ="stacked_result", metadata={"color": "yellow", "barcode": 13}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which version of Tiled is this suggested for? With the current most up-to-date Tiled in the main branch I get the following error.
TypeError: Container.new() got an unexpected keyword argument 'structure'
You may want to consider defining array_client
the following way instead.
>>> from tiled.structures.data_source import DataSource
>>> data_source = DataSource(structure=structure, structure_family="array")
>>> array_client = client.new(structure_family="array", data_sources=[data_source], key ="stacked_result", metadata={"color": "yellow", "barcode": 13})
Also, PEP8:
>>> array_client = client.new(structure_family="array", structure=structure, key ="stacked_result", metadata={"color": "yellow", "barcode": 13}) | |
>>> array_client = client.new(structure_family="array", structure=structure, key="stacked_result", metadata={"color": "yellow", "barcode": 13}) |
Finally, for @danielballan, would it be useful to put this part in a utility function and return the client
for this particular use case (where we know the eventual array size but don't have the full array yet). Then the user can use that client to write chunks in streaming fashion without having to fiddle with the lower level client.new()
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. To answer the first part: I am using tiled == 0.1.0a113
at this moment, and it worked out fine on my local end.
I will test the suggested DataSource
and see if it's compatible with my pipeline. Will follow up on a new comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow up: I went through the release notes, the DataSource
is introduced in version 0.1.0a115
, so within my development environment (0.1.0a113) I was not able to run the suggested code.
To accommodate this, I will add both approaches and comment with notes about tiled version. This could serve as a temporary solution until a more advanced high level version come into the play.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should write the tutorial to the most recent version of tiled, given that it is still in alpha.
Co-authored-by: Hiran Wijesinghe <[email protected]>
This small PR adds a demonstration of the
write_block
functionality to the writing tutorial, as suggested in #693.Key components covered in the code block:
ArrayStructure
ArrayClient
write_block
with specific indexTo follow the flow of the original tutorial, the session has been added right after the demonstration of
write_array
under the head of "Write data", please feel free to make changes as needed.