Skip to content

Commit a07d4e8

Browse files
authored
fixes issue with UPath 0.3.x (#1374)
1 parent 600af1a commit a07d4e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2299
-1688
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ jobs:
176176
timeout-minutes: 30
177177
env:
178178
PYTHON_VERSION: ${{ matrix.python-version }}
179-
COVERAGE_FILE: "~/.local/share/coverage/${{ matrix.group }}.coverage"
180179
run: ./test.sh --splits 3 --group ${{ matrix.group }} --splitting-algorithm least_duration --cov=webknossos --cov-report=
181180

182181
- name: Python tests
@@ -191,13 +190,13 @@ jobs:
191190
uses: actions/upload-artifact@v4
192191
with:
193192
name: coverage-report-${{ matrix.group }}
194-
path: "~/.local/share/coverage/${{ matrix.group }}.coverage"
193+
path: "webknossos/.coverage"
194+
include-hidden-files: true
195+
if-no-files-found: error
195196
retention-days: 1 # Automatically deletes after 1 day
196197

197198
- name: Check if git is dirty
198-
run: |
199-
git diff --no-ext-diff --exit-code
200-
[[ -z $(git status -s) ]]
199+
run: ../_tooling/check_clean.sh
201200

202201
webknossos_windows:
203202
needs: changes
@@ -262,7 +261,7 @@ jobs:
262261
env:
263262
COVERAGE_FILE: "~/coverage-files/result.coverage"
264263
run: |
265-
coverage combine ~/coverage-files/**/*.coverage
264+
coverage combine ~/coverage-files/**/.coverage
266265
coverage xml -i -o ~/coverage-files/result.xml
267266
268267
- name: Report coverage
@@ -301,8 +300,8 @@ jobs:
301300
cd docs
302301
./generate.sh --persist
303302
304-
- name: Push docs (for branch)
305-
if: github.ref_type == 'branch'
303+
- name: Push docs (for master)
304+
if: github.ref == 'refs/heads/master'
306305
env:
307306
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
308307
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

_tooling/check_clean.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/env bash
2+
set -eEuo pipefail
3+
4+
echo "🔍 Checking for uncommitted changes..."
5+
6+
# Include both committed and untracked changes
7+
if ! git diff --quiet HEAD || [ -n "$(git ls-files --others --exclude-standard)" ]; then
8+
echo "❌ Git working tree is dirty:"
9+
git status --short
10+
exit 1
11+
fi
12+
13+
echo "✅ Working tree clean."

cluster_tools/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ dask = ["distributed ~=2023.9.1"]
2121
kubernetes = ["kubernetes ~=27.2.0"]
2222
all=["cluster_tools[kubernetes]", "cluster_tools[dask]"]
2323

24-
[tool.uv]
25-
dev-dependencies = [
24+
[dependency-groups]
25+
dev = [
2626
"icecream ~=2.1.1",
2727
"mypy ~=1.15.0",
2828
"pytest ~=8.3.3",

webknossos/Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
2929
- Dataset.add_layer_as_ref() now accepts RemoteLayer objects as well as Layer objects. [#1371](https://github.com/scalableminds/webknossos-libs/pull/1371])
3030

3131
### Changed
32+
- Replaced `pathlib.Path` for `upath.UPath` internally. `pathlib.Path` is still supported for user-facing APIs. Adds support for `universal_pathlib` version 0.3.x. [#1374](https://github.com/scalableminds/webknossos-libs/pull/1374)
3233
- Only use fs-based copy for mags on local file systems and S3. Other protocols, e.g. memory and HTTP, have caveats that break fs-based copying. [#1365](https://github.com/scalableminds/webknossos-libs/pull/1365)
3334
- The `add_*` methods in `Attachments` now return the created attachment objects, similar to `add_layer` and `add_mag`. [#1365](https://github.com/scalableminds/webknossos-libs/pull/1365)
3435
- The returned dataset ID from dataset exploration is now used. [#1378](https://github.com/scalableminds/webknossos-libs/pull/1378)

webknossos/pyproject.toml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ dependencies = [
5151
"rich ~=13.8.0",
5252
"s3fs>=2024.6.1",
5353
"scipy >=1.13",
54-
"tensorstore~=0.1.74",
54+
"tensorstore ==0.1.76; sys_platform == 'win32'", # tensorstore crashes on windows with >0.1.76
55+
"tensorstore ~=0.1.78; sys_platform != 'win32'",
5556
"typer ~=0.12.5",
5657
"typing-extensions ~=4.0",
57-
"universal-pathlib ~=0.2",
58+
"universal-pathlib ~=0.3",
5859
"wkw ==1.1.24",
5960
"zipp ~=3.5.0",
6061
]
@@ -89,9 +90,8 @@ all = [
8990
"webknossos[examples]",
9091
]
9192

92-
[tool.uv]
93-
extra-index-url = ["https://pypi.scm.io/simple"]
94-
dev-dependencies = [
93+
[dependency-groups]
94+
dev = [
9595
"coverage>=7.8.0",
9696
"fsspec ~=2024.6.0",
9797
"hypothesis ~=6.35.0",
@@ -110,6 +110,9 @@ dev-dependencies = [
110110
"ruff ~=0.11.0",
111111
]
112112

113+
[tool.uv]
114+
extra-index-url = ["https://pypi.scm.io/simple"]
115+
113116
[tool.uv.sources]
114117
cluster-tools = { path = "../cluster_tools", editable = true }
115118

webknossos/script_collection/test_segmentation_heuristic.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
2-
from pathlib import Path
2+
3+
from upath import UPath
34

45
import webknossos as wk
56
from webknossos.dataset._utils.segmentation_recognition import (
@@ -9,11 +10,11 @@
910
)
1011

1112

12-
def looks_like_remote_dataset(path: Path) -> bool:
13+
def looks_like_remote_dataset(path: UPath) -> bool:
1314
return len([item for item in path.iterdir() if item.is_dir()]) == 0
1415

1516

16-
def main(path_to_datasets: Path) -> None:
17+
def main(path_to_datasets: UPath) -> None:
1718
wrongly_predicted: list[str] = []
1819
correctly_predicted: list[str] = []
1920
failures: list[str] = []
@@ -79,4 +80,4 @@ def main(path_to_datasets: Path) -> None:
7980

8081

8182
if __name__ == "__main__":
82-
main(Path("../webknossos/binaryData/sample_organization/"))
83+
main(UPath("../webknossos/binaryData/sample_organization/"))

webknossos/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bash
22
set -eEuo pipefail
3+
set -x
34

45
source local_wk_setup.sh
56

webknossos/tests/conftest.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
import os
33
import warnings
44
from collections.abc import Generator, Iterator
5-
from os import makedirs
65
from pathlib import Path
7-
from shutil import rmtree, unpack_archive
6+
from shutil import unpack_archive
87
from typing import Any
98

109
import fsspec.implementations.http as http
@@ -16,6 +15,7 @@
1615
import webknossos as wk
1716
from webknossos.client._upload_dataset import _cached_get_upload_datastore
1817
from webknossos.client.context import _clear_all_context_caches
18+
from webknossos.utils import rmtree
1919

2020
from .constants import TESTDATA_DIR, TESTOUTPUT_DIR
2121

@@ -98,7 +98,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
9898

9999
@pytest.fixture(autouse=True, scope="function")
100100
def clear_testoutput() -> Generator:
101-
makedirs(TESTOUTPUT_DIR, exist_ok=True)
101+
TESTOUTPUT_DIR.mkdir(parents=True, exist_ok=True)
102102
yield
103103
rmtree(TESTOUTPUT_DIR)
104104

@@ -145,12 +145,9 @@ def use_replay_proxay(request: Any) -> Generator:
145145

146146

147147
@pytest.fixture(scope="session")
148-
def WT1_path() -> Path:
148+
def WT1_upath() -> UPath:
149149
ds_path = TESTDATA_DIR / "WT1_wkw"
150150
if ds_path.exists():
151151
rmtree(ds_path)
152-
unpack_archive(
153-
TESTDATA_DIR / "WT1_wkw.tar.gz",
154-
ds_path,
155-
)
152+
unpack_archive(str(TESTDATA_DIR / "WT1_wkw.tar.gz"), str(ds_path))
156153
return ds_path

0 commit comments

Comments
 (0)