Skip to content

Commit e6e0c74

Browse files
committed
Merge branch 'main' into update_datatable
2 parents de03403 + e8b3d16 commit e6e0c74

File tree

158 files changed

+1209
-648
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+1209
-648
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ repos:
1717
rev: 23.10.1
1818
hooks:
1919
- id: black
20+
exclude: .*.zarr/
2021
- repo: https://github.com/pre-commit/mirrors-prettier
2122
rev: v3.0.3
2223
hooks:
2324
- id: prettier
25+
exclude: .*.zarr/
2426
- repo: https://github.com/asottile/blacken-docs
2527
rev: 1.16.0
2628
hooks:
@@ -45,11 +47,16 @@ repos:
4547
hooks:
4648
- id: detect-private-key
4749
- id: check-ast
50+
exclude: .*.zarr/
4851
- id: end-of-file-fixer
52+
exclude: .*.zarr/
4953
- id: mixed-line-ending
5054
args: [--fix=lf]
55+
exclude: .*.zarr/
5156
- id: trailing-whitespace
57+
exclude: .*.zarr/
5258
- id: check-case-conflict
59+
exclude: .*.zarr/
5360
- repo: https://github.com/PyCQA/autoflake
5461
rev: v2.2.1
5562
hooks:

_static/img/speed.png

28.5 KB
Loading

notebooks.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,17 @@ Many different technologies can be visualised out-of-the-box. See below for a co
148148
149149
notebooks/examples/technology_cosmx.ipynb
150150
151+
.. grid-item::
152+
153+
.. container:: custom-card
154+
155+
.. image:: _static/img/speed.png
156+
:target: notebooks/examples/speed_up_illustration.html
157+
158+
.. toctree::
159+
:maxdepth: 1
160+
161+
notebooks/examples/speed_up_illustration.ipynb
162+
151163
152164
```

notebooks/developers_resources/storage_format/Readme.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,35 @@ This directory contains notebooks that operate on lightweight datasets.
1414
- Each notebook covers a particular aspect of the storage specification and ~~all the~~ _the main (work in progress)_ edge cases of the specification are covered in at least one of the notebooks.
1515
- All the notebooks are run every 24h (work in progress, automatic run temporarily disabled) against the `main` branch of the `spatialdata` repository. Each notebook creates a dataset, writes it to disk, reloads it in memory, rewrites it to disk to check for consistency, reloads it again in memory and plots it.
1616
- The disk storage is committed to GitHub so that the output of each daily run is associated to a commit, the commit message is "autorun: storage format; spatialdata from <commit hash> <optional (commit tag)>". Examples of commit messages are:
17-
- `autorun: storage format; spatialdata from al29fak`
17+
- `autorun: storage format; spatialdata from al29fak (v0.0.12.q020ke.dev)`
1818
- `autorun: storage format; spatialdata from fa096da (v0.0.12)`
1919
- The `.zarr` data produced by every run is available in the current directory, in the commit corresponding to the run.
20-
- The data is also [uploaded to S3](https://refined-github-html-preview.kidonng.workers.dev/scverse/spatialdata-notebooks/raw/dev_notebooks/notebooks/developers_resources/storage_format/index.html), both as Zarr directories and as zipped files.
20+
- The data is also [uploaded to S3](https://refined-github-html-preview.kidonng.workers.dev/scverse/spatialdata-notebooks/raw/main/notebooks/developers_resources/storage_format/index.html), both as Zarr directories and as zipped files (upload to S3 temporarily disable, please download the data from the GitHub repository).
2121

2222
## How to use this repository
2323

2424
Practically, a third party tool (e.g. R reader, format converter, JavaScript data visualizer, etc.) that runs correctly on the lightweight datasets from this repository, should be guaranteed to run correctly on any SpatialData dataset.
2525

2626
We recommend the following.
2727

28-
- Implement your readers on the data from the latest run available (look for the latest commit with message `autorun: storage format; ...`).
28+
- Implement your readers on the data from the latest commit available
2929
- Set up an automated test (e.g. daily) that gets the latest converted data (you can use a `git pull` or download the data from S3) and runs your code on it.
30-
- If your reader fails, you can inspect the corresponding commit in this repository to see what has changed in the storage specification; in particular, you may find useful to compare different commits using the GitHub compare function, accessible with the following syntax: https://github.com/scverse/spatialdata-notebooks/compare/267adb1..5847084
30+
- If your reader fails, you can inspect the corresponding commit in this repository to see what has changed in the storage specification; in particular:
31+
- you may find useful to compare different commits using the GitHub compare function, accessible with the following syntax: https://github.com/scverse/spatialdata-notebooks/compare/f55f89a..d8e4d55;
32+
- you may want to compare the latest commit with one of the commits using the spaitaldata version (or a closely related dev version), of the one that you used when implementing the readers; the versions are specified in the commit messages as described before.
33+
34+
Furthermore, you can look at the on-disk versioning. Each element specifies the encoding that has been used for writing; you can find this in the .zattrs file ([example, see the end](https://github.com/scverse/spatialdata-notebooks/blob/main/notebooks/developers_resources/storage_format/transformation_affine.zarr/points/blobs_points/.zattrs)).
35+
A global version for the `SpatialData` object that gets bumped every time something changes at the top-level (or every time the encoding of an element changes) is not available yet, but [its implementation is tracked here](https://github.com/scverse/spatialdata/issues/356).
3136

3237
## Important technical notes
3338

3439
- The most crucial part of the metadata is stored, for each spatial element, in the `.zattr` file. [Example](transformation_identity.zarr/images/blobs_image/.zattrs).
3540
- The `zmetadata` in the root folder stores redundant information and is used for storage systems that do not support `ls` operations (e.g. S3). [Example](transformation_identity.zarr/zmetadata).
3641
- Please keep in mind that the data that we generate daily are produced against the latest `main` and not the latest release. This means that in the event of a format change (which should anyway happen less and less frequently as the frameworks become more mature), this does not immediately translate into a bug for the user. In fact, the user will still be using the latest release version for a while, giving time to developers to update the tools before the users are affected.
3742
- When the format will become more mature we will provide converters between previous versions of the format. Luckily, heavy data like images and labels are stable from NGFF v0.4, therefore the converters will mostly perform lightweight conversions of the metadata and relatively small conversions of the geometries.
43+
44+
# TODOs:
45+
46+
- [ ] re-enable daily runs, and remove "work in progress" notice from the readme.
47+
- [ ] merge the transformations notebooks into one
48+
- [ ] re-enable upload to S3, and remove "work in progress" notice from the readme.

notebooks/developers_resources/storage_format/__template__.ipynb

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,20 @@
3636
{
3737
"cell_type": "code",
3838
"execution_count": null,
39-
"id": "094509a1-86fb-4aa6-b920-11e34ed43e1c",
39+
"id": "4804890f-bd05-4d59-b83c-939f8429cf16",
40+
"metadata": {},
41+
"outputs": [],
42+
"source": [
43+
"import warnings\n",
44+
"\n",
45+
"# warnings clutter the diffs of notebooks\n",
46+
"warnings.filterwarnings(\"ignore\")"
47+
]
48+
},
49+
{
50+
"cell_type": "code",
51+
"execution_count": null,
52+
"id": "f57d4446-f975-4b44-a78c-0583258b9b92",
4053
"metadata": {},
4154
"outputs": [],
4255
"source": [
@@ -46,7 +59,7 @@
4659
{
4760
"cell_type": "code",
4861
"execution_count": null,
49-
"id": "332c9c62-7451-4d8e-ba9e-13c12131c312",
62+
"id": "8e37f99e-8bd7-45d1-8b12-b29f8d2dcf81",
5063
"metadata": {},
5164
"outputs": [],
5265
"source": [
@@ -113,7 +126,7 @@
113126
"name": "python",
114127
"nbconvert_exporter": "python",
115128
"pygments_lexer": "ipython3",
116-
"version": "3.10.12"
129+
"version": "3.10.13"
117130
}
118131
},
119132
"nbformat": 4,

notebooks/developers_resources/storage_format/io_utils.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
import os
23
import shutil
34
import tempfile
@@ -8,6 +9,34 @@
89
from spatialdata._io._utils import _are_directories_identical
910

1011

12+
class DisableLogger:
13+
"""
14+
Context manager that temporarily disables specific logging messages.
15+
16+
Parameters
17+
----------
18+
level
19+
The logging level to disable. It can be a numeric level or a string representation
20+
of the level as defined in the logging module.
21+
22+
Examples
23+
--------
24+
from logging import INFO
25+
26+
with DisableLogger(INFO):
27+
logging.info('This will not be logged')
28+
"""
29+
30+
def __init__(self, level):
31+
self.level = level
32+
33+
def __enter__(self):
34+
logging.disable(self.level)
35+
36+
def __exit__(self, exit_type, exit_value, exit_traceback):
37+
logging.disable(logging.NOTSET)
38+
39+
1140
def delete_old_data(name: str) -> None:
1241
"""
1342
Safely delete an old Zarr store, it if exists.
@@ -58,7 +87,12 @@ def write_sdata_and_check_consistency(sdata: sd.SpatialData, name: str) -> None:
5887
with tempfile.TemporaryDirectory() as tmpdir:
5988
sdata2 = sd.read_zarr(f1)
6089
f2 = os.path.join(tmpdir, f"{name}2.zarr")
61-
sdata2.write(f2)
90+
with DisableLogger(logging.INFO):
91+
# remove the message
92+
# INFO The Zarr file used for backing will now change from multiple_elements.zarr to
93+
# /tmp/tmp15sd47gc/multiple_elements2.zarr
94+
# which otherwise appears in the git diff
95+
sdata2.write(f2)
6296
assert _are_directories_identical(f1, f2)
6397

6498
shutil.make_archive(f1, "zip", f1)

notebooks/developers_resources/storage_format/multiple_elements.ipynb

Lines changed: 39 additions & 81 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"zarr_format": 2
3-
}
3+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"zarr_format": 2
3-
}
3+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/images/blobs_image/.zattrs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@
9090
"version": "0.4"
9191
}
9292
]
93-
}
93+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"zarr_format": 2
3-
}
3+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/images/blobs_image/0/.zarray

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
64
2323
],
2424
"zarr_format": 2
25-
}
25+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/images/blobs_multiscale_image/.zattrs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,4 @@
116116
"version": "0.4"
117117
}
118118
]
119-
}
119+
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"zarr_format": 2
3-
}
3+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/images/blobs_multiscale_image/0/.zarray

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
64
2323
],
2424
"zarr_format": 2
25-
}
25+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/images/blobs_multiscale_image/1/.zarray

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
32
2323
],
2424
"zarr_format": 2
25-
}
25+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/images/blobs_multiscale_image/2/.zarray

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
16
2323
],
2424
"zarr_format": 2
25-
}
25+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/labels/.zattrs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
"blobs_labels",
44
"blobs_multiscale_labels"
55
]
6-
}
6+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"zarr_format": 2
3-
}
3+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/labels/blobs_labels/.zattrs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@
6767
"version": "0.4"
6868
}
6969
]
70-
}
70+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"zarr_format": 2
3-
}
3+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/labels/blobs_labels/0/.zarray

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
64
2121
],
2222
"zarr_format": 2
23-
}
23+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/labels/blobs_multiscale_labels/.zattrs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,4 @@
9191
"version": "0.4"
9292
}
9393
]
94-
}
94+
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"zarr_format": 2
3-
}
3+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/labels/blobs_multiscale_labels/0/.zarray

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
64
2121
],
2222
"zarr_format": 2
23-
}
23+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/labels/blobs_multiscale_labels/1/.zarray

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
32
2121
],
2222
"zarr_format": 2
23-
}
23+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/labels/blobs_multiscale_labels/2/.zarray

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
16
2121
],
2222
"zarr_format": 2
23-
}
23+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"zarr_format": 2
3-
}
3+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/points/blobs_points/.zattrs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@
4141
"instance_key": "instance_id",
4242
"version": "0.1"
4343
}
44-
}
44+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"zarr_format": 2
3-
}
3+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"zarr_format": 2
3-
}
3+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/shapes/blobs_circles/.zattrs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@
4343
},
4444
"version": "0.1"
4545
}
46-
}
46+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"zarr_format": 2
3-
}
3+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/shapes/blobs_circles/Index/.zarray

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
5
1919
],
2020
"zarr_format": 2
21-
}
21+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/shapes/blobs_circles/coords/.zarray

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
2
2121
],
2222
"zarr_format": 2
23-
}
23+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/shapes/blobs_circles/radius/.zarray

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
5
1919
],
2020
"zarr_format": 2
21-
}
21+
}

notebooks/developers_resources/storage_format/multiple_elements.zarr/shapes/blobs_multipolygons/.zattrs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@
4343
},
4444
"version": "0.1"
4545
}
46-
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"zarr_format": 2
3-
}
3+
}

0 commit comments

Comments
 (0)