Skip to content

Commit d5f19d8

Browse files
authored
test.py instead of test.sh (#1379)
* test.py * lint * npx * shell * rm proxay from ci * print * ci * ci * pre-install proxay * comments * win! * changelog * pr feedback * better handle sigint * pr feedback
1 parent 65874f1 commit d5f19d8

File tree

7 files changed

+324
-201
lines changed

7 files changed

+324
-201
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ jobs:
149149
cache-dependency-glob: "webknossos/uv.lock"
150150

151151
- name: Install proxay
152-
run: npm install -g proxay
152+
run: npm install -g proxay@1.9.0
153153

154154
- name: Set up Python ${{ matrix.python-version }}
155155
run: uv python install ${{ matrix.python-version }}
@@ -176,14 +176,14 @@ jobs:
176176
timeout-minutes: 30
177177
env:
178178
PYTHON_VERSION: ${{ matrix.python-version }}
179-
run: ./test.sh --splits 3 --group ${{ matrix.group }} --splitting-algorithm least_duration --cov=webknossos --cov-report=
179+
run: uv run test.py --splits 3 --group ${{ matrix.group }} --splitting-algorithm least_duration --cov=webknossos --cov-report=
180180

181181
- name: Python tests
182182
if: ${{ matrix.python-version != '3.11' }}
183183
timeout-minutes: 30
184184
env:
185185
PYTHON_VERSION: ${{ matrix.python-version }}
186-
run: ./test.sh --splits 3 --group ${{ matrix.group }} --splitting-algorithm least_duration
186+
run: uv run test.py --splits 3 --group ${{ matrix.group }} --splitting-algorithm least_duration
187187

188188
- name: Persist coverage reports
189189
if: ${{ matrix.python-version == '3.11' }}
@@ -222,22 +222,21 @@ jobs:
222222
enable-cache: true
223223
cache-dependency-glob: "webknossos/uv.lock"
224224

225-
- name: Install proxay
226-
run: npm install -g proxay
227-
228225
- name: Install minio
229226
run: Invoke-WebRequest -Uri "https://dl.min.io/server/minio/release/windows-amd64/minio.exe" -OutFile "minio.exe"
230227

228+
- name: Install proxay
229+
run: npm install -g [email protected]
230+
231231
- name: Set up Python ${{ matrix.python-version }}
232232
run: uv python install ${{ matrix.python-version }}
233233

234234
- name: Python tests
235235
timeout-minutes: 30
236-
shell: bash
237236
env:
238237
PYTHON_VERSION: ${{ matrix.python-version }}
239238
MULTIPROCESSING_DEFAULT_START_METHOD: spawn
240-
run: ./test.sh --splits 3 --group ${{ matrix.group }} --splitting-algorithm least_duration
239+
run: uv run test.py --splits 3 --group ${{ matrix.group }} --splitting-algorithm least_duration
241240

242241
coverage_report:
243242
needs: [webknossos_linux]

.github/workflows/nightly.yml

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: nightly
22

33
on:
44
schedule:
5-
- cron: '00 06 * * *'
5+
- cron: "00 06 * * *"
66
workflow_dispatch: ~
77

88
jobs:
@@ -19,46 +19,46 @@ jobs:
1919
working-directory: webknossos
2020

2121
steps:
22-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v3
2323

24-
- name: Install uv
25-
uses: astral-sh/setup-uv@v3
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v3
2626

27-
- name: Install proxay
28-
run: npm install -g proxay
27+
- name: Install proxay
28+
run: npm install -g proxay
2929

30-
- name: Set up Python ${{ matrix.python-version }}
31-
run: uv python install ${{ matrix.python-version }}
30+
- name: Set up Python ${{ matrix.python-version }}
31+
run: uv python install ${{ matrix.python-version }}
3232

33-
- name: Check if git is dirty
34-
run: |
35-
git diff --no-ext-diff --quiet --exit-code
36-
[[ -z $(git status -s) ]]
33+
- name: Check if git is dirty
34+
run: |
35+
git diff --no-ext-diff --quiet --exit-code
36+
[[ -z $(git status -s) ]]
3737
38-
- name: Python tests, refreshing the network snapshots
39-
env:
40-
WK_TOKEN: ${{ secrets.WK_TOKEN }}
41-
run: ./test.sh --refresh-snapshots --splits 3 --group ${{ matrix.group }}
38+
- name: Python tests, refreshing the network snapshots
39+
env:
40+
WK_TOKEN: ${{ secrets.WK_TOKEN }}
41+
run: uv run test.py --refresh-snapshots --splits 3 --group ${{ matrix.group }}
4242

43-
- name: Python tests, using the new snapshots
44-
env:
45-
WK_TOKEN: ${{ secrets.WK_TOKEN }}
46-
run: ./test.sh --refresh-snapshots --splits 3 --group ${{ matrix.group }}
43+
- name: Python tests, using the new snapshots
44+
env:
45+
WK_TOKEN: ${{ secrets.WK_TOKEN }}
46+
run: uv run test.py --refresh-snapshots --splits 3 --group ${{ matrix.group }}
4747

48-
- uses: slackapi/[email protected]
49-
if: failure() || cancelled()
50-
with:
51-
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
52-
webhook-type: incoming-webhook
53-
payload: |
54-
attachments:
55-
- color: "#f00"
56-
blocks:
57-
- type: "section"
58-
text:
59-
type: "mrkdwn"
60-
text: ':fire: Job <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|${{github.job}}> of workflow "${{github.workflow}}" failed'
61-
- type: "context"
62-
elements:
63-
- type: mrkdwn
64-
text: '<${{github.repositoryUrl}}|${{github.repository}}>'
48+
- uses: slackapi/[email protected]
49+
if: failure() || cancelled()
50+
with:
51+
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
52+
webhook-type: incoming-webhook
53+
payload: |
54+
attachments:
55+
- color: "#f00"
56+
blocks:
57+
- type: "section"
58+
text:
59+
type: "mrkdwn"
60+
text: ':fire: Job <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|${{github.job}}> of workflow "${{github.workflow}}" failed'
61+
- type: "context"
62+
elements:
63+
- type: mrkdwn
64+
text: '<${{github.repositoryUrl}}|${{github.repository}}>'

CONTRIBUTING.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ See below for specifics of the different packages. Let's have a look at the comm
114114
* `./format.sh`: ruff
115115
* `./lint.sh`: ruff
116116
* `./typecheck.sh`: mypy
117-
* `./test.sh`: pytest and custom scripts
117+
* `./test.py`: pytest and custom scripts
118118

119119
Those are also accessible via make commands from the top-level directory, running the respective scripts for each sub-project
120120
, e.g. `make format`, `make lint`, …
@@ -133,26 +133,26 @@ Internal workflows for scalable minds:
133133

134134
The `webknossos` folder contains examples, which are not part of the package, but are tested via `tests/test_examples.py` and added to the documentation (see `docs/src/webknossos-py/examples`).
135135

136-
To run the `./test.sh` script it is necessary to install `proxay`. This is either done with [NPM](https://www.npmjs.com) or [yarn](https://yarnpkg.com/getting-started/install):
136+
To run the `uv run test.py` script it is necessary to install `proxay`. This is either done with [NPM](https://www.npmjs.com) or [yarn](https://yarnpkg.com/getting-started/install):
137137
```bash
138138
npm install --global proxay
139139

140140
# or if you're using yarn
141141
yarn global add proxay
142142
```
143-
When running the `./test.sh` script on MacOS, it is also necessary to install `minio` using the following command:
143+
When running the `uv run test.py` script on MacOS, it is also necessary to install `minio` using the following command:
144144

145145
```bash
146146
brew install minio
147147
```
148148

149149
The tests also contain functionality for the WEBKNOSSOS client. There a two modes to run the tests:
150150

151-
1. `./test.sh --refresh-snapshots`, sending network requests to a WEBKNOSSOS instance:
152-
This expects a local WEBKNOSSOS setup with specific test data, which is shipped with WEBKNOSSOS. If you're starting and running WEBKNOSSOS manually, please use port 9000 (the default) and run the `tools/postgres/dbtool.js prepare-test-db` script in the WEBKNOSSOS repository (⚠️ this overwrites your local WEBKNOSSOS database). Alternatively, a `docker compose` setup is started automatically for the tests, see `./test.sh` and `tests/docker-compose.yml` for details. The network requests & response are recorded as "cassettes" by [proxay](https://github.com/airtasker/proxay), see next point:
153-
2. `./test.sh` replays responses from previous network snapshots using [proxay](https://github.com/airtasker/proxay).
151+
1. `uv run test.py --refresh-snapshots`, sending network requests to a WEBKNOSSOS instance:
152+
This expects a local WEBKNOSSOS setup with specific test data, which is shipped with WEBKNOSSOS. If you're starting and running WEBKNOSSOS manually, please use port 9000 (the default) and run the `tools/postgres/dbtool.js prepare-test-db` script in the WEBKNOSSOS repository (⚠️ this overwrites your local WEBKNOSSOS database). Alternatively, a `docker compose` setup is started automatically for the tests, see `uv run test.py` and `tests/docker-compose.yml` for details. The network requests & response are recorded as "cassettes" by [proxay](https://github.com/airtasker/proxay), see next point:
153+
2. `uv run test.py` replays responses from previous network snapshots using [proxay](https://github.com/airtasker/proxay).
154154

155-
`./test.sh --store-durations` updates the durations for
155+
`uv run test.py --store-durations` updates the durations for
156156
[`pytest-split`](https://jerry-git.github.io/pytest-split),
157157
which is used in the CI to split the tests for different runners.
158158

webknossos/Changelog.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
1515
### Breaking Changes
1616
- The `endpoint_url` in `UPath` objects is now stored directly in the `storage_options` dict, instead of being stored in the `storage_options["client_kwargs"]` dict. [#1365](https://github.com/scalableminds/webknossos-libs/pull/1365)
1717
- Removed Docker image `scalableminds/webknossos-cli` build. It will not be released further. [#1376](https://github.com/scalableminds/webknossos-libs/pull/1376)
18+
19+
### Added
20+
- Dataset.add_layer_as_ref() now accepts RemoteLayer objects as well as Layer objects. [#1371](https://github.com/scalableminds/webknossos-libs/pull/1371])
21+
- RemoteDataset.annotation_id is now exposed, when available. [#1380](https://github.com/scalableminds/webknossos-libs/pull/1380)
22+
- RemoteDataset.open() now accepts an annotation url as well. [#1380](https://github.com/scalableminds/webknossos-libs/pull/1380)
23+
### Changed
24+
- Ported `test.sh` to `test.py`, run with `uv run test.py`. [#1379](https://github.com/scalableminds/webknossos-libs/pull/1379)
1825
- `Dataset.add_layer_as_ref(remote_layer.path)` does not work anymore. Please use `Dataset.add_layer_as_ref(remote_layer)` instead. [#1371](https://github.com/scalableminds/webknossos-libs/pull/1371])
1926
- Due to the refactoring, the imports of various classes have changed. Please update your code accordingly. [#1371](https://github.com/scalableminds/webknossos-libs/pull/1371])
2027
- Deprecated a number of methods [#1371](https://github.com/scalableminds/webknossos-libs/pull/1371]):
@@ -24,13 +31,6 @@ For upgrade instructions, please check the respective _Breaking Changes_ section
2431
- `Dataset.download()`, use `RemoteDataset.download()` instead.
2532
- `mag_view.is_foreign`, use `layer.is_mag_view_foreign(mag_view)` instead.
2633
- `Dataset.trigger_reload_in_datastore()`, use `RemoteDataset.trigger_reload_in_datastore()` instead.
27-
28-
### Added
29-
- Dataset.add_layer_as_ref() now accepts RemoteLayer objects as well as Layer objects. [#1371](https://github.com/scalableminds/webknossos-libs/pull/1371])
30-
- RemoteDataset.annotation_id is now exposed, when available. [#1380](https://github.com/scalableminds/webknossos-libs/pull/1380)
31-
- RemoteDataset.open() now accepts an annotation url as well. [#1380](https://github.com/scalableminds/webknossos-libs/pull/1380)
32-
33-
### Changed
3434
- 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)
3535
- 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)
3636
- 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)

webknossos/local_wk_setup.sh

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)