Skip to content

Commit

Permalink
Merge pull request #9 from NeurodataWithoutBorders/dev
Browse files Browse the repository at this point in the history
CI tests via gh actions
  • Loading branch information
magland authored Mar 15, 2024
2 parents af7ffc7 + 50a277c commit e84ada0
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 8 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: integration tests

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
name: integration tests
steps:
- uses: actions/checkout@v1
- name: Install
run: pip install -e .
- name: Install packages needed for tests
# pyright 1.1.336 can produce annoying errors
run: pip install pytest pytest-cov pyright==1.1.335
- name: Run pyright
run: cd lindi && pyright
- name: Run tests and collect coverage
run: pytest --cov lindi --cov-report=xml --cov-report=term tests/
# - uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# fail_ci_if_error: true
# file: ./coverage.xml
# flags: unittests
22 changes: 22 additions & 0 deletions .github/workflows/linter_checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: linter-checks

on:
push:
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
name: Linter checks
steps:
- uses: actions/checkout@v1
- name: Install
run: pip install -e .
- name: Install packages needed for tests
# pyright 1.1.336 can produce annoying errors
run: pip install pyright==1.1.335 flake8
- name: Run flake8
run: cd lindi && flake8 --config ../.flake8
- name: Run pyright
run: cd lindi && pyright
1 change: 1 addition & 0 deletions .vscode/tasks/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
set -ex

# black --check .
flake8 .
pyright
pytest --cov=lindi --cov-report=xml --cov-report=term tests/
4 changes: 3 additions & 1 deletion devel/old_tests/test_lindi_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def test_lindi_client():
for k in acquisition.keys():
print(k)

x = client["acquisition/ElectricalSeriesAp"]["data"]
aa = client["acquisition/ElectricalSeriesAp"]
assert isinstance(aa, LindiGroup)
x = aa["data"]
assert isinstance(x, LindiDataset)

print(x.shape)
Expand Down
6 changes: 4 additions & 2 deletions examples/example1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
import h5py
import tempfile
import lindi
from lindi import LindiH5Store, LindiClient, LindiDataset
from _check_equal import _check_equal

Expand Down Expand Up @@ -76,8 +77,9 @@ def example1():
G1 = h5f["group"]
G2 = client["group"]
for k, v in G1.attrs.items():
assert k in G2.attrs
assert _check_equal(v, G2.attrs[k])
if not isinstance(G2, lindi.LindiReference):
assert k in G2.attrs
assert _check_equal(v, G2.attrs[k])

print("Comparing root group")
for k, v in h5f.attrs.items():
Expand Down
2 changes: 1 addition & 1 deletion examples/try_pynwb.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ def try_pynwb():


if __name__ == "__main__":
try_pynwb()
try_pynwb()
2 changes: 1 addition & 1 deletion lindi/LindiClient/LindiAttributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class LindiAttributes:
def __init__(self, *, _object: Union[zarr.Group, zarr.Array]):
self._object = _object

def get(self, key, default=None):
return self._object.attrs.get(key, default)

Expand Down
2 changes: 1 addition & 1 deletion lindi/LindiClient/LindiClient.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Union
import json
import tempfile
from altair import Literal
from typing import Literal
from fsspec import FSMap
import zarr
import urllib.request
Expand Down
1 change: 1 addition & 0 deletions lindi/LindiClient/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
from .LindiGroup import LindiGroup # noqa: F401
from .LindiDataset import LindiDataset # noqa: F401
from .LindiAttributes import LindiAttributes # noqa: F401
from .LindiGroup import LindiReference # noqa: F401
2 changes: 1 addition & 1 deletion lindi/LindiH5Store/LindiH5Store.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def _get_chunk_names_for_dataset(chunk_coords_shape: List[int]) -> List[str]:
return names


def _reformat_json(x: bytes):
def _reformat_json(x: Union[bytes, None]) -> Union[bytes, None]:
if x is None:
return None
return json.dumps(json.loads(x.decode("utf-8"))).encode("utf-8")
2 changes: 1 addition & 1 deletion lindi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .LindiClient import LindiClient, LindiGroup, LindiDataset, LindiAttributes # noqa: F401
from .LindiClient import LindiClient, LindiGroup, LindiDataset, LindiAttributes, LindiReference # noqa: F401
from .LindiH5Store import LindiH5Store, LindiH5StoreOpts # noqa: F401
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ numcodecs = "^0.12.1"
zarr = "^2.16.1"
h5py = "^3.10.0"
remfile = "^0.1.9"
fsspec = "^2023.12.2"

[tool.poetry.dev-dependencies]
pytest = "^7.4.4"
Expand Down

0 comments on commit e84ada0

Please sign in to comment.