tonik 0.1.20__tar.gz → 0.1.21__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tonik-0.1.20 → tonik-0.1.21}/PKG-INFO +1 -1
- {tonik-0.1.20 → tonik-0.1.21}/pixi.lock +2 -2
- {tonik-0.1.20 → tonik-0.1.21}/pyproject.toml +2 -1
- {tonik-0.1.20 → tonik-0.1.21}/src/tonik/storage.py +1 -1
- {tonik-0.1.20 → tonik-0.1.21}/src/tonik/xarray2zarr.py +9 -3
- {tonik-0.1.20 → tonik-0.1.21}/tests/test_save.py +18 -0
- {tonik-0.1.20 → tonik-0.1.21}/.devcontainer/devcontainer.json +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/.gitattributes +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/.gitignore +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/HOW_TO_RELEASE.md +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/LICENSE +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/README.md +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/grafana_example/Dockerfile_api +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/grafana_example/Dockerfile_grafana +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/grafana_example/dashboards/demo_dashboard.json +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/grafana_example/docker-compose.yml +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/grafana_example/grafana.ini +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/grafana_example/provisioning/dashboards/default.yaml +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/grafana_example/provisioning/datasources/default.yaml +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/mkdocs.yml +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/pyproject.toml~ +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/src/tonik/__init__.py +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/src/tonik/api.py +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/src/tonik/grafana_annotations.py +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/src/tonik/package_data/index.html +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/src/tonik/package_data/whakaari_labels.json +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/src/tonik/utils.py +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/src/tonik/xarray2netcdf.py +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/tests/backend_speed_test.py +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/tests/conftest.py +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/tests/test_api.py +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/tests/test_storage.py +0 -0
- {tonik-0.1.20 → tonik-0.1.21}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tonik
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.21
|
|
4
4
|
Summary: Store time series data as HDF5 files and access them through an API.
|
|
5
5
|
Project-URL: Homepage, https://tsc-tools.github.io/tonik
|
|
6
6
|
Project-URL: Issues, https://github.com/tsc-tools/tonik/issues
|
|
@@ -3681,8 +3681,8 @@ packages:
|
|
|
3681
3681
|
timestamp: 1763054914403
|
|
3682
3682
|
- pypi: ./
|
|
3683
3683
|
name: tonik
|
|
3684
|
-
version: 0.1.
|
|
3685
|
-
sha256:
|
|
3684
|
+
version: 0.1.21
|
|
3685
|
+
sha256: 8df82fc10e56aba3de54b9483f427f92a415574614dd09716f8cadc9c33a2510
|
|
3686
3686
|
requires_dist:
|
|
3687
3687
|
- h5py>=3.8
|
|
3688
3688
|
- datashader>=0.14
|
|
@@ -12,7 +12,7 @@ exclude = [
|
|
|
12
12
|
|
|
13
13
|
[project]
|
|
14
14
|
name = "tonik"
|
|
15
|
-
version = "0.1.
|
|
15
|
+
version = "0.1.21"
|
|
16
16
|
authors = [
|
|
17
17
|
{ name="Yannik Behr", email="y.behr@gns.cri.nz" },
|
|
18
18
|
{ name="Christof Mueller", email="c.mueller@gns.cri.nz" }
|
|
@@ -64,6 +64,7 @@ grafana_annotations = "tonik.grafana_annotations:main"
|
|
|
64
64
|
|
|
65
65
|
[tool.pytest.ini_options]
|
|
66
66
|
log_cli = true
|
|
67
|
+
addopts = "-s"
|
|
67
68
|
|
|
68
69
|
[tool.hatch.envs.test]
|
|
69
70
|
dependencies = [
|
|
@@ -18,7 +18,7 @@ LOGGING_CONFIG = {
|
|
|
18
18
|
"datefmt": "%Y-%m-%d %H:%M:%S", # How to display dates
|
|
19
19
|
},
|
|
20
20
|
"json": { # The formatter name
|
|
21
|
-
"()": "pythonjsonlogger.
|
|
21
|
+
"()": "pythonjsonlogger.json.JsonFormatter", # The class to instantiate!
|
|
22
22
|
# Json is more complex, but easier to read, display all attributes!
|
|
23
23
|
"format": """
|
|
24
24
|
asctime: %(asctime)s
|
|
@@ -267,7 +267,7 @@ def xarray2zarr(xds: xr.Dataset, path: str, mode: str = 'a', group='original',
|
|
|
267
267
|
continue
|
|
268
268
|
|
|
269
269
|
if xds_existing[timedim][0] > xds[timedim][-1]:
|
|
270
|
-
|
|
270
|
+
logger.debug("Prepending data to existing zarr store.")
|
|
271
271
|
xda_new = fill_time_gaps_between_datasets(xds_existing[feature].isel({timedim: 0}),
|
|
272
272
|
xds[feature], mode='p')
|
|
273
273
|
xda_new = _build_append_payload_full_chunks(
|
|
@@ -277,7 +277,7 @@ def xarray2zarr(xds: xr.Dataset, path: str, mode: str = 'a', group='original',
|
|
|
277
277
|
write_empty_chunks=True)
|
|
278
278
|
|
|
279
279
|
elif xds_existing[timedim][-1] < xds[timedim][0]:
|
|
280
|
-
|
|
280
|
+
logger.debug("Appending data to existing zarr store.")
|
|
281
281
|
xda_new = fill_time_gaps_between_datasets(xds_existing[feature].isel({timedim: -1}),
|
|
282
282
|
xds[feature], mode='a')
|
|
283
283
|
xda_new = _build_append_payload_full_chunks(
|
|
@@ -286,13 +286,19 @@ def xarray2zarr(xds: xr.Dataset, path: str, mode: str = 'a', group='original',
|
|
|
286
286
|
append_dim=timedim)
|
|
287
287
|
|
|
288
288
|
elif xds_existing[timedim][0] > xds[timedim][0] and xds_existing[timedim][-1] < xds[timedim][-1]:
|
|
289
|
-
|
|
289
|
+
logger.debug(
|
|
290
|
+
"Data in zarr store contained in new data. Rewriting zarr store.")
|
|
290
291
|
xda_new = _build_append_payload_full_chunks(
|
|
291
292
|
xds[feature], 'a', nchunks)
|
|
292
293
|
xda_new.to_zarr(fout, group=group, mode='w',
|
|
293
294
|
write_empty_chunks=True)
|
|
294
295
|
|
|
295
296
|
else:
|
|
297
|
+
logger.debug("Data in zarr store overlaps with new data.")
|
|
298
|
+
logger.debug(
|
|
299
|
+
f"Endtime of existing data: {xds_existing[timedim][-1].values}")
|
|
300
|
+
logger.debug(f"Starttime of new data: {xds[timedim][0].values}")
|
|
301
|
+
xds_existing = xds_existing.drop_duplicates(timedim, keep='last')
|
|
296
302
|
overlap = xds_existing[timedim].where(
|
|
297
303
|
xds_existing[timedim] == xds[timedim])
|
|
298
304
|
xds[feature].loc[{timedim: overlap}].to_zarr(
|
|
@@ -169,6 +169,24 @@ def test_xarray2netcdf_multi_access(tmp_path_factory):
|
|
|
169
169
|
group='original', engine='h5netcdf')
|
|
170
170
|
xarray2netcdf(xdf2, temp_dir)
|
|
171
171
|
|
|
172
|
+
@pytest.mark.slow
|
|
173
|
+
def test_netcdf_attribute_bug(tmp_path_factory):
|
|
174
|
+
"""
|
|
175
|
+
Test to replicate behaviour when attribute is updated more than
|
|
176
|
+
2^16 times.
|
|
177
|
+
"""
|
|
178
|
+
temp_dir = tmp_path_factory.mktemp('test_netcdf_attribute_bug')
|
|
179
|
+
g = Storage('test_experiment', rootdir=temp_dir, backend='netcdf')
|
|
180
|
+
c = g.get_substore('MDR', '00', 'HHZ')
|
|
181
|
+
tstart = datetime(2022, 7, 18, 8, 0, 0)
|
|
182
|
+
for i in range(70000):
|
|
183
|
+
if i % 1000 == 0:
|
|
184
|
+
print(f'Iteration {i}')
|
|
185
|
+
xdf = generate_test_data(tstart=tstart, dim=1, intervals=3, freq='1h')
|
|
186
|
+
xdf.attrs['last_update'] = str(tstart + timedelta(hours=3))
|
|
187
|
+
tstart += timedelta(days=1)
|
|
188
|
+
c.save(xdf)
|
|
189
|
+
|
|
172
190
|
|
|
173
191
|
def test_xarray2zarr(tmp_path_factory):
|
|
174
192
|
xdf = generate_test_data(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|