Skip to content

Commit

Permalink
Merge pull request #413 from Renumics/feature/pydantic-v2
Browse files Browse the repository at this point in the history
Feature/pydantic v2
  • Loading branch information
druzsan committed Feb 6, 2024
2 parents c7b4ac9 + c7baed0 commit 32aef9a
Show file tree
Hide file tree
Showing 53 changed files with 151 additions and 121 deletions.
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repos:

# "official" pre-commit hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: trailing-whitespace
exclude: \.secret\.
Expand All @@ -42,22 +42,22 @@ repos:

# third-pary hooks
- repo: https://github.com/psf/black
rev: 23.1.0
rev: 24.1.1
hooks:
- id: black
- id: black-jupyter
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
rev: v4.0.0-alpha.8
hooks:
- id: prettier
exclude: (\.secret\.)|(pnpm-lock.yaml)
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v8.34.0
rev: v9.0.0-alpha.2
hooks:
- id: eslint
files: src
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.21.0
rev: 0.28.0
hooks:
- id: check-github-actions
- id: check-github-workflows
Expand All @@ -67,6 +67,6 @@ repos:
- id: shellcheck
- id: shfmt
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
rev: 0.7.1
hooks:
- id: nbstripout
66 changes: 37 additions & 29 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ diskcache = "*"
appdirs = "*"
databases = { version = "*", extras = ["aiosqlite"] }
rsa = "*"
packaging = "*"
prettytable = "*"
networkx = "*"
trimesh = "*"
Expand Down Expand Up @@ -93,23 +92,23 @@ datasets = { extras = ["audio"], version = "^2.12.0" }
pydantic-settings = "^2.0.3"
pycatch22 = { version = "!=0.4.4", optional = true }
transformers = "^4.35.2"
packaging = "*"

[tool.poetry.extras]
descriptors = ["pycatch22"]
all = ["pycatch22"]

[tool.poetry.group.dev.dependencies]
mypy = "*"
mypy = "^1.8.0"
types-setuptools = "^57.4.14"
types-requests = "^2.27.20"
black = "^22.3.0"
black = "^24.1.1"
pytest = "^7.4.2"
ipython = "^8.10.0"
jupyter = "^1.0.0"
watchdog = "^2.1.7"
argh = "^0.26.2"
typed-ast = "^1.5.3"
packaging = "^21.3"
nbmake = "^1.3.0"
selenium = "^4.1.3, <4.10"
diffimg = "^0.3.0"
Expand Down
1 change: 1 addition & 0 deletions renumics/spotlight/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
Replaced at build time.
"""

__version__ = "0.0.0"
1 change: 1 addition & 0 deletions renumics/spotlight/analysis/registry.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Manage data analyzers available for spotlights automatic dataset analysis.
"""

from typing import Set

from .typing import DataAnalyzer
Expand Down
6 changes: 3 additions & 3 deletions renumics/spotlight/backend/apis/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ async def _() -> List[Plugin]:
name=p.name,
priority=p.priority,
dev=p.dev,
entrypoint=f"../api/plugins/{p.name}/main.js"
if p.frontend_entrypoint
else None,
entrypoint=(
f"../api/plugins/{p.name}/main.js" if p.frontend_entrypoint else None
),
)
for p in plugins
]
Expand Down
1 change: 1 addition & 0 deletions renumics/spotlight/backend/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Spotlight Frontend Configuration
"""

import json
from typing import Dict, Optional, Union, cast

Expand Down
1 change: 0 additions & 1 deletion renumics/spotlight/data_source/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
through add_datasource or the @datasource decorator.
"""


from .data_source import ColumnMetadata, DataSource
from .decorator import datasource
from .registry import add_datasource, create_datasource
Expand Down
41 changes: 17 additions & 24 deletions renumics/spotlight/dataset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ def _check_valid_array(


class Dataset:

"""
Spotlight dataset.
"""
Expand Down Expand Up @@ -394,18 +393,15 @@ def __delitem__(self, item: Union[str, IndexType, Indices1dType]) -> None:
@overload
def __getitem__(
self, item: Union[str, Tuple[str, Indices1dType], Tuple[Indices1dType, str]]
) -> np.ndarray:
...
) -> np.ndarray: ...

@overload
def __getitem__(self, item: IndexType) -> Dict[str, Optional[OutputType]]:
...
def __getitem__(self, item: IndexType) -> Dict[str, Optional[OutputType]]: ...

@overload
def __getitem__(
self, item: Union[Tuple[str, IndexType], Tuple[IndexType, str]]
) -> Optional[OutputType]:
...
) -> Optional[OutputType]: ...

def __getitem__(
self,
Expand Down Expand Up @@ -464,20 +460,19 @@ def __setitem__(
self,
item: Union[str, Tuple[str, Indices1dType], Tuple[Indices1dType, str]],
value: Union[ColumnInputType, Iterable[ColumnInputType]],
) -> None:
...
) -> None: ...

@overload
def __setitem__(self, item: IndexType, value: Dict[str, ColumnInputType]) -> None:
...
def __setitem__(
self, item: IndexType, value: Dict[str, ColumnInputType]
) -> None: ...

@overload
def __setitem__(
self,
item: Union[Tuple[str, IndexType], Tuple[IndexType, str]],
value: ColumnInputType,
) -> None:
...
) -> None: ...

def __setitem__(
self,
Expand Down Expand Up @@ -636,16 +631,14 @@ def keys(self) -> List[str]:
return list(self._column_names)

@overload
def iterrows(self) -> Iterable[Dict[str, Optional[OutputType]]]:
...
def iterrows(self) -> Iterable[Dict[str, Optional[OutputType]]]: ...

@overload
def iterrows(
self, column_names: Union[str, Iterable[str]]
) -> Union[
Iterable[Dict[str, Optional[OutputType]]], Iterable[Optional[OutputType]]
]:
...
]: ...

def iterrows(
self, column_names: Optional[Union[str, Iterable[str]]] = None
Expand Down Expand Up @@ -1903,12 +1896,10 @@ def insert_row(self, index: IndexType, values: Dict[str, ColumnInputType]) -> No
self._update_generation_id()

@overload
def pop(self, item: str) -> np.ndarray:
...
def pop(self, item: str) -> np.ndarray: ...

@overload
def pop(self, item: IndexType) -> Dict[str, Optional[OutputType]]:
...
def pop(self, item: IndexType) -> Dict[str, Optional[OutputType]]: ...

def pop(
self, item: Union[str, IndexType]
Expand Down Expand Up @@ -2178,9 +2169,11 @@ def get_column_attributes(self, name: str) -> Dict[str, Any]:

attrs.update(
{
attribute_name: attribute_type(column_attrs[attribute_name])
if attribute_type is not object
else column_attrs[attribute_name]
attribute_name: (
attribute_type(column_attrs[attribute_name])
if attribute_type is not object
else column_attrs[attribute_name]
)
for attribute_name, attribute_type in allowed_attributes.items()
if attribute_name in column_attrs
}
Expand Down
1 change: 1 addition & 0 deletions renumics/spotlight/dataset/descriptors/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""make descriptor methods more available
"""

import warnings
from typing import Optional, Tuple

Expand Down
1 change: 0 additions & 1 deletion renumics/spotlight/dtypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
The main usage of the dtypes is customizing the [`spotlight.show`](../#show()).
"""


from datetime import datetime
from typing import Any, Dict, Iterable, Optional, Tuple, Union

Expand Down
12 changes: 6 additions & 6 deletions renumics/spotlight/dtypes/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,12 @@ def __init__(self, value: NormalizedValue, dtype: dtypes.DType) -> None:
N = TypeVar("N", bound=NormalizedValue)

Converter = Callable[[N, dtypes.DType], ConvertedValue]
_converters_table: Dict[
Type[NormalizedValue], Dict[str, List[Converter]]
] = defaultdict(lambda: defaultdict(list))
_simple_converters_table: Dict[
Type[NormalizedValue], Dict[str, List[Converter]]
] = defaultdict(lambda: defaultdict(list))
_converters_table: Dict[Type[NormalizedValue], Dict[str, List[Converter]]] = (
defaultdict(lambda: defaultdict(list))
)
_simple_converters_table: Dict[Type[NormalizedValue], Dict[str, List[Converter]]] = (
defaultdict(lambda: defaultdict(list))
)


def register_converter(
Expand Down
1 change: 0 additions & 1 deletion renumics/spotlight/dtypes/legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class Category:


class Window:

"""
A pair of two timestamps in seconds which can be later projected onto
continuous data (only `renumics.spotlight.dtypes.Audio`
Expand Down
Loading

0 comments on commit 32aef9a

Please sign in to comment.