tonik 0.1.7__tar.gz → 0.1.9__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.
@@ -4,6 +4,8 @@
4
4
  "name": "Python 3",
5
5
  // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6
6
  "image": "mcr.microsoft.com/devcontainers/python:1-3.10-bullseye",
7
+ //"image": "mcr.microsoft.com/devcontainers/python:1-3.9-bullseye",
8
+
7
9
 
8
10
  // Features to add to the dev container. More info: https://containers.dev/features.
9
11
  // "features": {},
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: tonik
3
- Version: 0.1.7
3
+ Version: 0.1.9
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
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "tonik"
7
- version = "0.1.7"
7
+ version = "0.1.9"
8
8
  authors = [
9
9
  { name="Yannik Behr", email="y.behr@gns.cri.nz" },
10
10
  { name="Christof Mueller", email="c.mueller@gns.cri.nz" }
@@ -3,7 +3,7 @@ import os
3
3
  import sys
4
4
  from argparse import ArgumentParser
5
5
  from datetime import datetime
6
- from typing import Annotated, List, Union
6
+ from typing import Annotated, List, Union, Optional
7
7
  from urllib.parse import unquote
8
8
 
9
9
  import datashader as dsh
@@ -20,12 +20,8 @@ from .storage import Storage
20
20
 
21
21
  logger = logging.getLogger(__name__)
22
22
 
23
- if sys.version_info >= (3, 10):
24
- # For Python 3.10 and above, use the new union operator '|'
25
- SubdirType = Annotated[list[str] | None, Query()]
26
- else:
27
- # For Python 3.9 and below, use Union from typing
28
- SubdirType = Annotated[Union[List[str], None], Query()]
23
+ SubdirType = Annotated[Union[List[str], None], Query()]
24
+ InventoryReturnType = Union[list, dict]
29
25
 
30
26
 
31
27
  class TonikAPI:
@@ -64,21 +60,20 @@ class TonikAPI:
64
60
  def feature(self,
65
61
  group: str,
66
62
  name: str,
67
- starttime: str = None,
68
- endtime: str = None,
63
+ starttime: Union[str, None],
64
+ endtime: Union[str, None],
65
+ subdir: SubdirType = None,
69
66
  resolution: str = 'full',
70
67
  verticalres: int = 10,
71
68
  log: bool = False,
72
- normalise: bool = False,
73
- subdir: SubdirType = None):
69
+ normalise: bool = False):
74
70
  _st = self.preprocess_datetime(starttime)
75
71
  _et = self.preprocess_datetime(endtime)
76
72
  g = Storage(group, rootdir=self.rootdir,
77
73
  starttime=_st, endtime=_et,
78
74
  create=False)
79
- if subdir is None:
80
- c = g
81
- else:
75
+ c = g
76
+ if subdir:
82
77
  c = g.get_substore(*subdir)
83
78
  try:
84
79
  feat = c(name)
@@ -147,7 +142,7 @@ class TonikAPI:
147
142
  d, units='hours since 1970-01-01 00:00:00.0', calendar='gregorian')
148
143
  return freq, dates, spec
149
144
 
150
- def inventory(self, group: str, subdir: SubdirType = None, tree: bool = True) -> list | dict:
145
+ def inventory(self, group: str, subdir: SubdirType = None, tree: bool = True) -> InventoryReturnType:
151
146
  sg = Storage(group, rootdir=self.rootdir, create=False)
152
147
  try:
153
148
  c = sg.get_substore(*subdir)
@@ -36,7 +36,7 @@ def xarray2zarr(xds: xr.Dataset, path: str, mode: str = 'a', group='original'):
36
36
  else:
37
37
  try:
38
38
  xds_existing = xr.open_zarr(fout, group=group)
39
- except PathNotFoundError:
39
+ except (PathNotFoundError, FileNotFoundError):
40
40
  xds[feature].to_zarr(fout, group=group, mode='a')
41
41
  continue
42
42
  if xds_existing.datetime[0] > xds.datetime[0] or xds_existing.datetime[-1] > xds.datetime[-1]:
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