webknossos-libs
webknossos-libs copied to clipboard
Enable metadata access for remote datasets.
Description:
- Implements getters and setters for the new metadata field in remote datasets and folders.
Issues:
- fixes #1148
Todos:
Make sure to delete unnecessary points or to check all before merging:
-
[x] Updated Changelog
-
[x] Considered adding this to the Examples
-
[x] blocked by https://github.com/scalableminds/webknossos/pull/7886
How to test:
Just run the example in accessing_metadata.py and enter your webknossos token when asked. After execution, the dataset l4_sample and the folder Datasets/Demo-Datasets should have an entry with metadata.
I first tried
dataset.metadata["test"] = "asdf", which did not error, but also did have any effect. Do you think it would be simple to support this case as well?
As it was currently just a dict neither freezing nor overwriting __setitem__ is super easy without unwanted side effects. I implemented a subclass of dict now, that fetches data on each access and updates the data when the dict is updated. This might be more intuitive, but it is also slower. I guess we don't want to update the metadata very often, so this might be okay. What is your opinion on this approach?
Interesting idea! I like this access pattern from the user perspective. However, I don’t know enough about python and its conventions to fully know what unwanted side-effects this specialized dict may have :thinking: Also I’m not certain I can review its implementation. Maybe we can get a second opinion? Maybe @daniel-wer could also have a look?