From 99cd7fc258607334c61bb874e181d85179ee21bf Mon Sep 17 00:00:00 2001 From: Eugene M Date: Fri, 9 Aug 2024 10:03:52 -0400 Subject: [PATCH 1/9] ENH: Add data type to sparse --- tiled/adapters/sparse.py | 3 +++ tiled/client/container.py | 2 ++ tiled/server/pydantic_sparse.py | 2 ++ tiled/server/router.py | 1 + tiled/structures/sparse.py | 8 ++++++++ 5 files changed, 16 insertions(+) diff --git a/tiled/adapters/sparse.py b/tiled/adapters/sparse.py index 60b122d5c..5aa53a90c 100644 --- a/tiled/adapters/sparse.py +++ b/tiled/adapters/sparse.py @@ -8,6 +8,7 @@ from ..structures.core import Spec, StructureFamily from ..structures.sparse import COOStructure +from ..structures.array import BuiltinDtype from .array import slice_and_shape_from_block_and_chunks from .protocols import AccessPolicy from .type_alliases import JSON, NDSlice @@ -49,6 +50,7 @@ def from_arrays( dims=dims, shape=shape, chunks=tuple((dim,) for dim in shape), + data_type=BuiltinDtype.from_numpy_dtype(data.dtype), resizable=False, ) return cls( @@ -133,6 +135,7 @@ def from_global_ref( dims=dims, shape=shape, chunks=chunks, + data_type=BuiltinDtype.from_numpy_dtype(data.dtype), resizable=False, ) return cls( diff --git a/tiled/client/container.py b/tiled/client/container.py index 7a87ce507..51b466ba4 100644 --- a/tiled/client/container.py +++ b/tiled/client/container.py @@ -887,12 +887,14 @@ def write_sparse( >>> x.write_block(coords=[[0, 1]], data=[6.7, 1.2], block=(1,)) """ from ..structures.sparse import COOStructure + from ..structures.array import BuiltinDtype structure = COOStructure( shape=shape, # This method only supports single-chunk COO arrays. chunks=tuple((dim,) for dim in shape), dims=dims, + data_type=BuiltinDtype.from_numpy_dtype(data.dtype), ) client = self.new( StructureFamily.sparse, diff --git a/tiled/server/pydantic_sparse.py b/tiled/server/pydantic_sparse.py index 145f272d0..59883e94a 100644 --- a/tiled/server/pydantic_sparse.py +++ b/tiled/server/pydantic_sparse.py @@ -3,11 +3,13 @@ import pydantic from ..structures.sparse import SparseLayout +from ..structures.array import BuiltinDtype, StructDtype class COOStructure(pydantic.BaseModel): shape: Tuple[int, ...] # tuple of ints like (3, 3) chunks: Tuple[Tuple[int, ...], ...] # tuple-of-tuples-of-ints like ((3,), (3,)) + data_type: Optional[Union[BuiltinDtype, StructDtype]] = None dims: Optional[Tuple[str, ...]] = None # None or tuple of names like ("x", "y") resizable: Union[bool, Tuple[bool, ...]] = False layout: SparseLayout = SparseLayout.COO diff --git a/tiled/server/router.py b/tiled/server/router.py index a81a2fea3..c469190d7 100644 --- a/tiled/server/router.py +++ b/tiled/server/router.py @@ -456,6 +456,7 @@ async def array_full( """ Fetch a slice of array-like data. """ + breakpoint() structure_family = entry.structure_family # Deferred import because this is not a required dependency of the server # for some use cases. diff --git a/tiled/structures/sparse.py b/tiled/structures/sparse.py index 354d150d7..91ec0ee51 100644 --- a/tiled/structures/sparse.py +++ b/tiled/structures/sparse.py @@ -1,6 +1,7 @@ import enum from dataclasses import dataclass from typing import Optional, Tuple, Union +from .array import BuiltinDtype, StructDtype class SparseLayout(str, enum.Enum): @@ -13,6 +14,7 @@ class SparseLayout(str, enum.Enum): class COOStructure: chunks: Tuple[Tuple[int, ...], ...] # tuple-of-tuples-of-ints like ((3,), (3,)) shape: Tuple[int, ...] # tuple of ints like (3, 3) + data_type: Optional[Union[BuiltinDtype, StructDtype]] = None dims: Optional[Tuple[str, ...]] = None # None or tuple of names like ("x", "y") resizable: Union[bool, Tuple[bool, ...]] = False layout: SparseLayout = SparseLayout.COO @@ -20,7 +22,13 @@ class COOStructure: @classmethod def from_json(cls, structure): + data_type = structure.get("data_type", None) + if "fields" in data_type: + data_type = StructDtype.from_json(data_type) + else: + data_type = BuiltinDtype.from_json(data_type) return cls( + data_type=data_type, chunks=tuple(map(tuple, structure["chunks"])), shape=tuple(structure["shape"]), dims=structure["dims"], From 1fbb021a92b47fdbe008d839d0d43dd490f28a54 Mon Sep 17 00:00:00 2001 From: Eugene M Date: Fri, 6 Sep 2024 10:58:39 -0400 Subject: [PATCH 2/9] FIX: assignment error --- tiled/structures/sparse.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tiled/structures/sparse.py b/tiled/structures/sparse.py index 91ec0ee51..ea773ce3b 100644 --- a/tiled/structures/sparse.py +++ b/tiled/structures/sparse.py @@ -23,7 +23,7 @@ class COOStructure: @classmethod def from_json(cls, structure): data_type = structure.get("data_type", None) - if "fields" in data_type: + if data_type is not None and "fields" in data_type: data_type = StructDtype.from_json(data_type) else: data_type = BuiltinDtype.from_json(data_type) From 1ec2425f1350e6b402ce7622c368f04765c9c3ab Mon Sep 17 00:00:00 2001 From: Eugene M Date: Fri, 6 Sep 2024 11:12:05 -0400 Subject: [PATCH 3/9] MNT: clean and lint --- tiled/adapters/sparse.py | 2 +- tiled/client/container.py | 2 +- tiled/server/pydantic_sparse.py | 2 +- tiled/server/router.py | 1 - tiled/structures/sparse.py | 1 + 5 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tiled/adapters/sparse.py b/tiled/adapters/sparse.py index 5aa53a90c..c6771f942 100644 --- a/tiled/adapters/sparse.py +++ b/tiled/adapters/sparse.py @@ -6,9 +6,9 @@ import sparse from numpy._typing import NDArray +from ..structures.array import BuiltinDtype from ..structures.core import Spec, StructureFamily from ..structures.sparse import COOStructure -from ..structures.array import BuiltinDtype from .array import slice_and_shape_from_block_and_chunks from .protocols import AccessPolicy from .type_alliases import JSON, NDSlice diff --git a/tiled/client/container.py b/tiled/client/container.py index 51b466ba4..2434185ee 100644 --- a/tiled/client/container.py +++ b/tiled/client/container.py @@ -886,8 +886,8 @@ def write_sparse( >>> x.write_block(coords=[[2, 4]], data=[3.1, 2.8], block=(0,)) >>> x.write_block(coords=[[0, 1]], data=[6.7, 1.2], block=(1,)) """ - from ..structures.sparse import COOStructure from ..structures.array import BuiltinDtype + from ..structures.sparse import COOStructure structure = COOStructure( shape=shape, diff --git a/tiled/server/pydantic_sparse.py b/tiled/server/pydantic_sparse.py index 59883e94a..6c7d35e05 100644 --- a/tiled/server/pydantic_sparse.py +++ b/tiled/server/pydantic_sparse.py @@ -2,8 +2,8 @@ import pydantic -from ..structures.sparse import SparseLayout from ..structures.array import BuiltinDtype, StructDtype +from ..structures.sparse import SparseLayout class COOStructure(pydantic.BaseModel): diff --git a/tiled/server/router.py b/tiled/server/router.py index c469190d7..a81a2fea3 100644 --- a/tiled/server/router.py +++ b/tiled/server/router.py @@ -456,7 +456,6 @@ async def array_full( """ Fetch a slice of array-like data. """ - breakpoint() structure_family = entry.structure_family # Deferred import because this is not a required dependency of the server # for some use cases. diff --git a/tiled/structures/sparse.py b/tiled/structures/sparse.py index ea773ce3b..da50c3a7b 100644 --- a/tiled/structures/sparse.py +++ b/tiled/structures/sparse.py @@ -1,6 +1,7 @@ import enum from dataclasses import dataclass from typing import Optional, Tuple, Union + from .array import BuiltinDtype, StructDtype From 808ebcbc39f2b136866d0a9f4ac9eaf480588511 Mon Sep 17 00:00:00 2001 From: Eugene M Date: Fri, 6 Sep 2024 11:18:10 -0400 Subject: [PATCH 4/9] MNT: update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52d581718..39488ebc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ Write the date in place of the "Unreleased" in the case a new version is release # Changelog +## v0.1.0b9 (Unreleased) + +### Added + +- `dtype` property for sparse arrays in `COOAdapter` and `COOStructure`. + ## v0.1.0b8 (2024-09-06) ### Fixed From 57137b154b7b474e4facc1d4f9dbd51b40ca7179 Mon Sep 17 00:00:00 2001 From: Eugene M Date: Fri, 6 Sep 2024 13:36:26 -0400 Subject: [PATCH 5/9] FIX: tests with COOStructure --- tiled/_tests/test_protocols.py | 8 ++++++-- tiled/_tests/test_writing.py | 9 ++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tiled/_tests/test_protocols.py b/tiled/_tests/test_protocols.py index e54921cd5..a458ae106 100644 --- a/tiled/_tests/test_protocols.py +++ b/tiled/_tests/test_protocols.py @@ -247,9 +247,13 @@ def test_sparseadapter_protocol(mocker: MockFixture) -> None: mock_call4 = mocker.patch.object(CustomSparseAdapter, "specs") mock_call5 = mocker.patch.object(CustomSparseAdapter, "metadata") - structure = COOStructure(shape=(2 * 5,), chunks=((5, 5),)) - array = numpy.random.rand(2, 512, 512) + + structure = COOStructure( + shape=(2 * 5,), + chunks=((5, 5),), + data_type=BuiltinDtype.from_numpy_dtype(array.dtype), + ) blocks: Dict[Tuple[int, ...], Tuple[NDArray[Any], Any]] = {(1,): (array, (1,))} metadata: JSON = {"foo": "bar"} anyslice = (1, 1, 1) diff --git a/tiled/_tests/test_writing.py b/tiled/_tests/test_writing.py index 571aaad59..320dba4e3 100644 --- a/tiled/_tests/test_writing.py +++ b/tiled/_tests/test_writing.py @@ -26,6 +26,7 @@ from ..mimetypes import PARQUET_MIMETYPE from ..queries import Key from ..server.app import build_app +from ..structures.array import BuiltinDtype from ..structures.core import Spec, StructureFamily from ..structures.data_source import DataSource from ..structures.sparse import COOStructure @@ -245,7 +246,13 @@ def test_write_sparse_chunked(tree): "sparse", [ DataSource( - structure=COOStructure(shape=(2 * N,), chunks=((N, N),)), + structure=COOStructure( + shape=(2 * N,), + chunks=((N, N),), + data_type=BuiltinDtype.from_numpy_dtype( + numpy.dtype("float64") + ), + ), structure_family="sparse", ) ], From 3256dcc1189c8881ee86181f1bc8223a06e33ca9 Mon Sep 17 00:00:00 2001 From: Eugene M Date: Wed, 23 Oct 2024 17:32:29 -0400 Subject: [PATCH 6/9] ENH: add indx_data_type for sparse arrays --- CHANGELOG.md | 2 +- tiled/adapters/sparse.py | 2 ++ tiled/client/container.py | 1 + tiled/server/pydantic_sparse.py | 3 ++- tiled/structures/sparse.py | 5 ++++- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06447c117..faf9ca78d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Write the date in place of the "Unreleased" in the case a new version is release ### Added -- `dtype` property for sparse arrays in `COOAdapter` and `COOStructure`. +- `data_type` and `indx_data_type` properties for sparse arrays in `COOAdapter` and `COOStructure`. ## v0.1.0b10 (2024-10-11) diff --git a/tiled/adapters/sparse.py b/tiled/adapters/sparse.py index c6771f942..a69743dc6 100644 --- a/tiled/adapters/sparse.py +++ b/tiled/adapters/sparse.py @@ -51,6 +51,7 @@ def from_arrays( shape=shape, chunks=tuple((dim,) for dim in shape), data_type=BuiltinDtype.from_numpy_dtype(data.dtype), + indx_data_type=BuiltinDtype.from_numpy_dtype(coords.dtype), resizable=False, ) return cls( @@ -136,6 +137,7 @@ def from_global_ref( shape=shape, chunks=chunks, data_type=BuiltinDtype.from_numpy_dtype(data.dtype), + indx_data_type=BuiltinDtype.from_numpy_dtype(coords.dtype), resizable=False, ) return cls( diff --git a/tiled/client/container.py b/tiled/client/container.py index 2434185ee..e22ed9083 100644 --- a/tiled/client/container.py +++ b/tiled/client/container.py @@ -895,6 +895,7 @@ def write_sparse( chunks=tuple((dim,) for dim in shape), dims=dims, data_type=BuiltinDtype.from_numpy_dtype(data.dtype), + indx_data_type=BuiltinDtype.from_numpy_dtype(coords.dtype), ) client = self.new( StructureFamily.sparse, diff --git a/tiled/server/pydantic_sparse.py b/tiled/server/pydantic_sparse.py index 6c7d35e05..0d041296f 100644 --- a/tiled/server/pydantic_sparse.py +++ b/tiled/server/pydantic_sparse.py @@ -2,7 +2,7 @@ import pydantic -from ..structures.array import BuiltinDtype, StructDtype +from ..structures.array import BuiltinDtype, StructDtype, Endianness, Kind from ..structures.sparse import SparseLayout @@ -10,6 +10,7 @@ class COOStructure(pydantic.BaseModel): shape: Tuple[int, ...] # tuple of ints like (3, 3) chunks: Tuple[Tuple[int, ...], ...] # tuple-of-tuples-of-ints like ((3,), (3,)) data_type: Optional[Union[BuiltinDtype, StructDtype]] = None + indx_data_type: BuiltinDtype = BuiltinDtype(Endianness("little"), Kind("u"), 8) # numpy 'uint' dtype dims: Optional[Tuple[str, ...]] = None # None or tuple of names like ("x", "y") resizable: Union[bool, Tuple[bool, ...]] = False layout: SparseLayout = SparseLayout.COO diff --git a/tiled/structures/sparse.py b/tiled/structures/sparse.py index da50c3a7b..bceb1b1f3 100644 --- a/tiled/structures/sparse.py +++ b/tiled/structures/sparse.py @@ -2,7 +2,7 @@ from dataclasses import dataclass from typing import Optional, Tuple, Union -from .array import BuiltinDtype, StructDtype +from .array import BuiltinDtype, StructDtype, Endianness, Kind class SparseLayout(str, enum.Enum): @@ -16,6 +16,7 @@ class COOStructure: chunks: Tuple[Tuple[int, ...], ...] # tuple-of-tuples-of-ints like ((3,), (3,)) shape: Tuple[int, ...] # tuple of ints like (3, 3) data_type: Optional[Union[BuiltinDtype, StructDtype]] = None + indx_data_type: BuiltinDtype = BuiltinDtype(Endianness("little"), Kind("u"), 8) # numpy 'uint' dtype dims: Optional[Tuple[str, ...]] = None # None or tuple of names like ("x", "y") resizable: Union[bool, Tuple[bool, ...]] = False layout: SparseLayout = SparseLayout.COO @@ -28,8 +29,10 @@ def from_json(cls, structure): data_type = StructDtype.from_json(data_type) else: data_type = BuiltinDtype.from_json(data_type) + indx_data_type = structure.get("indx_data_type", {"endianness":"little", "kind":"u", "itemsize":8}) return cls( data_type=data_type, + indx_data_type=BuiltinDtype.from_json(indx_data_type), chunks=tuple(map(tuple, structure["chunks"])), shape=tuple(structure["shape"]), dims=structure["dims"], From c76e4bed2a1100ea2f133c7a3e01442665e1850c Mon Sep 17 00:00:00 2001 From: Eugene M Date: Wed, 23 Oct 2024 17:45:51 -0400 Subject: [PATCH 7/9] MNT: rename indx_data_type to coord_data_type --- CHANGELOG.md | 2 +- tiled/adapters/sparse.py | 4 ++-- tiled/client/container.py | 2 +- tiled/server/pydantic_sparse.py | 2 +- tiled/structures/sparse.py | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index faf9ca78d..0f1a373fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ Write the date in place of the "Unreleased" in the case a new version is release ### Added -- `data_type` and `indx_data_type` properties for sparse arrays in `COOAdapter` and `COOStructure`. +- `data_type` and `coord_data_type` properties for sparse arrays in `COOAdapter` and `COOStructure`. ## v0.1.0b10 (2024-10-11) diff --git a/tiled/adapters/sparse.py b/tiled/adapters/sparse.py index a69743dc6..0bb62172c 100644 --- a/tiled/adapters/sparse.py +++ b/tiled/adapters/sparse.py @@ -51,7 +51,7 @@ def from_arrays( shape=shape, chunks=tuple((dim,) for dim in shape), data_type=BuiltinDtype.from_numpy_dtype(data.dtype), - indx_data_type=BuiltinDtype.from_numpy_dtype(coords.dtype), + coord_data_type=BuiltinDtype.from_numpy_dtype(coords.dtype), resizable=False, ) return cls( @@ -137,7 +137,7 @@ def from_global_ref( shape=shape, chunks=chunks, data_type=BuiltinDtype.from_numpy_dtype(data.dtype), - indx_data_type=BuiltinDtype.from_numpy_dtype(coords.dtype), + coord_data_type=BuiltinDtype.from_numpy_dtype(coords.dtype), resizable=False, ) return cls( diff --git a/tiled/client/container.py b/tiled/client/container.py index e22ed9083..bb20ec2f0 100644 --- a/tiled/client/container.py +++ b/tiled/client/container.py @@ -895,7 +895,7 @@ def write_sparse( chunks=tuple((dim,) for dim in shape), dims=dims, data_type=BuiltinDtype.from_numpy_dtype(data.dtype), - indx_data_type=BuiltinDtype.from_numpy_dtype(coords.dtype), + coord_data_type=BuiltinDtype.from_numpy_dtype(coords.dtype), ) client = self.new( StructureFamily.sparse, diff --git a/tiled/server/pydantic_sparse.py b/tiled/server/pydantic_sparse.py index 0d041296f..8785daddc 100644 --- a/tiled/server/pydantic_sparse.py +++ b/tiled/server/pydantic_sparse.py @@ -10,7 +10,7 @@ class COOStructure(pydantic.BaseModel): shape: Tuple[int, ...] # tuple of ints like (3, 3) chunks: Tuple[Tuple[int, ...], ...] # tuple-of-tuples-of-ints like ((3,), (3,)) data_type: Optional[Union[BuiltinDtype, StructDtype]] = None - indx_data_type: BuiltinDtype = BuiltinDtype(Endianness("little"), Kind("u"), 8) # numpy 'uint' dtype + coord_data_type: BuiltinDtype = BuiltinDtype(Endianness("little"), Kind("u"), 8) # numpy 'uint' dtype dims: Optional[Tuple[str, ...]] = None # None or tuple of names like ("x", "y") resizable: Union[bool, Tuple[bool, ...]] = False layout: SparseLayout = SparseLayout.COO diff --git a/tiled/structures/sparse.py b/tiled/structures/sparse.py index bceb1b1f3..13a8c2bcd 100644 --- a/tiled/structures/sparse.py +++ b/tiled/structures/sparse.py @@ -16,7 +16,7 @@ class COOStructure: chunks: Tuple[Tuple[int, ...], ...] # tuple-of-tuples-of-ints like ((3,), (3,)) shape: Tuple[int, ...] # tuple of ints like (3, 3) data_type: Optional[Union[BuiltinDtype, StructDtype]] = None - indx_data_type: BuiltinDtype = BuiltinDtype(Endianness("little"), Kind("u"), 8) # numpy 'uint' dtype + coord_data_type: BuiltinDtype = BuiltinDtype(Endianness("little"), Kind("u"), 8) # numpy 'uint' dtype dims: Optional[Tuple[str, ...]] = None # None or tuple of names like ("x", "y") resizable: Union[bool, Tuple[bool, ...]] = False layout: SparseLayout = SparseLayout.COO @@ -29,10 +29,10 @@ def from_json(cls, structure): data_type = StructDtype.from_json(data_type) else: data_type = BuiltinDtype.from_json(data_type) - indx_data_type = structure.get("indx_data_type", {"endianness":"little", "kind":"u", "itemsize":8}) + coord_data_type = structure.get("coord_data_type", {"endianness":"little", "kind":"u", "itemsize":8}) return cls( data_type=data_type, - indx_data_type=BuiltinDtype.from_json(indx_data_type), + coord_data_type=BuiltinDtype.from_json(coord_data_type), chunks=tuple(map(tuple, structure["chunks"])), shape=tuple(structure["shape"]), dims=structure["dims"], From 720f89147fe2e2fdb56b0210033e9c4bc99287db Mon Sep 17 00:00:00 2001 From: Eugene M Date: Wed, 23 Oct 2024 18:02:16 -0400 Subject: [PATCH 8/9] MNT: clean up --- alembic.ini | 116 ---------------------------------------------------- 1 file changed, 116 deletions(-) delete mode 100644 alembic.ini diff --git a/alembic.ini b/alembic.ini deleted file mode 100644 index ef81aa59d..000000000 --- a/alembic.ini +++ /dev/null @@ -1,116 +0,0 @@ -# A generic, single database configuration. - -[alembic] -# path to migration scripts -# Use forward slashes (/) also on windows to provide an os agnostic path -script_location = /Users/eugene/code/tiled/tiled/catalog/migrations - -# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s -# Uncomment the line below if you want the files to be prepended with date and time -# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file -# for all available tokens -# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s - -# sys.path path, will be prepended to sys.path if present. -# defaults to the current working directory. -prepend_sys_path = . - -# timezone to use when rendering the date within the migration file -# as well as the filename. -# If specified, requires the python>=3.9 or backports.zoneinfo library. -# Any required deps can installed by adding `alembic[tz]` to the pip requirements -# string value is passed to ZoneInfo() -# leave blank for localtime -# timezone = - -# max length of characters to apply to the "slug" field -# truncate_slug_length = 40 - -# set to 'true' to run the environment during -# the 'revision' command, regardless of autogenerate -# revision_environment = false - -# set to 'true' to allow .pyc and .pyo files without -# a source .py file to be detected as revisions in the -# versions/ directory -# sourceless = false - -# version location specification; This defaults -# to catalog/migrations/versions. When using multiple version -# directories, initial revisions must be specified with --version-path. -# The path separator used here should be the separator specified by "version_path_separator" below. -# version_locations = %(here)s/bar:%(here)s/bat:catalog/migrations/versions - -# version path separator; As mentioned above, this is the character used to split -# version_locations. The default within new alembic.ini files is "os", which uses os.pathsep. -# If this key is omitted entirely, it falls back to the legacy behavior of splitting on spaces and/or commas. -# Valid values for version_path_separator are: -# -# version_path_separator = : -# version_path_separator = ; -# version_path_separator = space -version_path_separator = os # Use os.pathsep. Default configuration used for new projects. - -# set to 'true' to search source files recursively -# in each "version_locations" directory -# new in Alembic version 1.10 -# recursive_version_locations = false - -# the output encoding used when revision files -# are written from script.py.mako -# output_encoding = utf-8 - -# sqlalchemy.url = driver://user:pass@localhost/dbname -sqlalchemy.url = sqlite+aiosqlite:////Users/eugene/code/demo_stream_documents/catalog/catalog.db - -[post_write_hooks] -# post_write_hooks defines scripts or Python functions that are run -# on newly generated revision scripts. See the documentation for further -# detail and examples - -# format using "black" - use the console_scripts runner, against the "black" entrypoint -# hooks = black -# black.type = console_scripts -# black.entrypoint = black -# black.options = -l 79 REVISION_SCRIPT_FILENAME - -# lint with attempts to fix using "ruff" - use the exec runner, execute a binary -# hooks = ruff -# ruff.type = exec -# ruff.executable = %(here)s/.venv/bin/ruff -# ruff.options = --fix REVISION_SCRIPT_FILENAME - -# Logging configuration -[loggers] -keys = root,sqlalchemy,alembic - -[handlers] -keys = console - -[formatters] -keys = generic - -[logger_root] -level = WARN -handlers = console -qualname = - -[logger_sqlalchemy] -level = WARN -handlers = -qualname = sqlalchemy.engine - -[logger_alembic] -level = INFO -handlers = -qualname = alembic - -[handler_console] -class = StreamHandler -args = (sys.stderr,) -level = NOTSET -formatter = generic - -[formatter_generic] -format = %(levelname)-5.5s [%(name)s] %(message)s -datefmt = %H:%M:%S \ No newline at end of file From 7f67f76922fb6e7a2081036d8868315c289e47c4 Mon Sep 17 00:00:00 2001 From: Eugene M Date: Wed, 23 Oct 2024 18:10:54 -0400 Subject: [PATCH 9/9] MNT: lint --- tiled/server/pydantic_sparse.py | 6 ++++-- tiled/structures/sparse.py | 10 +++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/tiled/server/pydantic_sparse.py b/tiled/server/pydantic_sparse.py index 8785daddc..7d6113e2d 100644 --- a/tiled/server/pydantic_sparse.py +++ b/tiled/server/pydantic_sparse.py @@ -2,7 +2,7 @@ import pydantic -from ..structures.array import BuiltinDtype, StructDtype, Endianness, Kind +from ..structures.array import BuiltinDtype, Endianness, Kind, StructDtype from ..structures.sparse import SparseLayout @@ -10,7 +10,9 @@ class COOStructure(pydantic.BaseModel): shape: Tuple[int, ...] # tuple of ints like (3, 3) chunks: Tuple[Tuple[int, ...], ...] # tuple-of-tuples-of-ints like ((3,), (3,)) data_type: Optional[Union[BuiltinDtype, StructDtype]] = None - coord_data_type: BuiltinDtype = BuiltinDtype(Endianness("little"), Kind("u"), 8) # numpy 'uint' dtype + coord_data_type: Optional[BuiltinDtype] = BuiltinDtype( + Endianness("little"), Kind("u"), 8 + ) # numpy 'uint' dtype dims: Optional[Tuple[str, ...]] = None # None or tuple of names like ("x", "y") resizable: Union[bool, Tuple[bool, ...]] = False layout: SparseLayout = SparseLayout.COO diff --git a/tiled/structures/sparse.py b/tiled/structures/sparse.py index 13a8c2bcd..a84e67499 100644 --- a/tiled/structures/sparse.py +++ b/tiled/structures/sparse.py @@ -2,7 +2,7 @@ from dataclasses import dataclass from typing import Optional, Tuple, Union -from .array import BuiltinDtype, StructDtype, Endianness, Kind +from .array import BuiltinDtype, Endianness, Kind, StructDtype class SparseLayout(str, enum.Enum): @@ -16,7 +16,9 @@ class COOStructure: chunks: Tuple[Tuple[int, ...], ...] # tuple-of-tuples-of-ints like ((3,), (3,)) shape: Tuple[int, ...] # tuple of ints like (3, 3) data_type: Optional[Union[BuiltinDtype, StructDtype]] = None - coord_data_type: BuiltinDtype = BuiltinDtype(Endianness("little"), Kind("u"), 8) # numpy 'uint' dtype + coord_data_type: Optional[BuiltinDtype] = BuiltinDtype( + Endianness("little"), Kind("u"), 8 + ) # numpy 'uint' dtype dims: Optional[Tuple[str, ...]] = None # None or tuple of names like ("x", "y") resizable: Union[bool, Tuple[bool, ...]] = False layout: SparseLayout = SparseLayout.COO @@ -29,7 +31,9 @@ def from_json(cls, structure): data_type = StructDtype.from_json(data_type) else: data_type = BuiltinDtype.from_json(data_type) - coord_data_type = structure.get("coord_data_type", {"endianness":"little", "kind":"u", "itemsize":8}) + coord_data_type = structure.get( + "coord_data_type", {"endianness": "little", "kind": "u", "itemsize": 8} + ) return cls( data_type=data_type, coord_data_type=BuiltinDtype.from_json(coord_data_type),