Skip to content

Commit 76eba1d

Browse files
Jo-Byrjourdain
authored andcommitted
chore: update pre-commit
Update pre-commit configuration to align with latest trame standards
1 parent 2502cc5 commit 76eba1d

56 files changed

Lines changed: 996 additions & 877 deletions

Some content is hidden

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

.codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ comment: false
22
coverage:
33
status:
44
project: off
5-
patch: off
5+
patch: off

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[run]
2-
omit = *docs*, *tests*, setup.py
2+
omit = *docs*, *tests*, setup.py

.github/workflows/test_and_release.yml

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Test and Release
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88

99
jobs:
1010
pre-commit:
@@ -30,10 +30,7 @@ jobs:
3030
matrix:
3131
python-version: ["3.12"]
3232
config:
33-
- {
34-
name: "Linux",
35-
os: ubuntu-latest
36-
}
33+
- { name: "Linux", os: ubuntu-latest }
3734
# - {
3835
# name: "MacOSX",
3936
# os: macos-latest
@@ -48,45 +45,45 @@ jobs:
4845
shell: bash
4946

5047
steps:
51-
- name: Checkout
52-
uses: actions/checkout@v6
53-
54-
- name: Set up Python ${{ matrix.python-version }}
55-
uses: actions/setup-python@v6
56-
with:
57-
python-version: ${{ matrix.python-version }}
58-
59-
- name: Set Up Node
60-
uses: actions/setup-node@v6
61-
with:
62-
node-version: 24
63-
64-
- name: Build Vue2 App
65-
run: |
66-
cd vue2-app
67-
npm ci
68-
npm run build
69-
70-
- name: Build Vue3 App
71-
run: |
72-
cd vue3-app
73-
npm ci
74-
npm run build
75-
76-
- name: Install and Run Tests
77-
run: |
78-
pip install .
79-
pip install -r tests/requirements.txt
80-
# Install requirements for playwright
81-
playwright install
82-
# Run the tests with coverage so we get a coverage report too
83-
pip install coverage
84-
coverage run --source . -m pytest -s .
85-
# Print the coverage report
86-
coverage report -m
87-
88-
- name: Upload Coverage to Codecov
89-
uses: codecov/codecov-action@v3
48+
- name: Checkout
49+
uses: actions/checkout@v6
50+
51+
- name: Set up Python ${{ matrix.python-version }}
52+
uses: actions/setup-python@v6
53+
with:
54+
python-version: ${{ matrix.python-version }}
55+
56+
- name: Set Up Node
57+
uses: actions/setup-node@v6
58+
with:
59+
node-version: 24
60+
61+
- name: Build Vue2 App
62+
run: |
63+
cd vue2-app
64+
npm ci
65+
npm run build
66+
67+
- name: Build Vue3 App
68+
run: |
69+
cd vue3-app
70+
npm ci
71+
npm run build
72+
73+
- name: Install and Run Tests
74+
run: |
75+
pip install .
76+
pip install -r tests/requirements.txt
77+
# Install requirements for playwright
78+
playwright install
79+
# Run the tests with coverage so we get a coverage report too
80+
pip install coverage
81+
coverage run --source . -m pytest -s .
82+
# Print the coverage report
83+
coverage report -m
84+
85+
- name: Upload Coverage to Codecov
86+
uses: codecov/codecov-action@v3
9087

9188
test-npm-build:
9289
runs-on: ubuntu-latest
@@ -99,7 +96,7 @@ jobs:
9996
uses: actions/setup-node@v6
10097
with:
10198
node-version: 24
102-
99+
103100
- name: Build js-lib
104101
run: |
105102
cd js-lib

.pre-commit-config.yaml

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,69 @@
1+
ci:
2+
autoupdate_commit_msg: "chore: update pre-commit hooks"
3+
autofix_commit_msg: "style: pre-commit fixes"
4+
5+
exclude: ^.*\.md|.*\.min\.js|.*\.global\.js$
6+
17
repos:
2-
- repo: https://github.com/codespell-project/codespell
3-
rev: v2.1.0
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: "v6.0.0"
410
hooks:
5-
- id: codespell
11+
- id: check-added-large-files
12+
- id: check-case-conflict
13+
- id: check-merge-conflict
14+
- id: check-symlinks
15+
- id: check-yaml
16+
- id: debug-statements
17+
- id: end-of-file-fixer
18+
exclude: ^trame_client/LICENSE$
19+
- id: mixed-line-ending
20+
- id: name-tests-test
21+
args: ["--pytest-test-first"]
22+
- id: requirements-txt-fixer
23+
- id: trailing-whitespace
24+
25+
- repo: https://github.com/pre-commit/pygrep-hooks
26+
rev: "v1.10.0"
27+
hooks:
28+
- id: rst-backticks
29+
- id: rst-directive-colons
30+
- id: rst-inline-touching-normal
31+
32+
- repo: https://github.com/rbubley/mirrors-prettier
33+
rev: "v3.8.3"
34+
hooks:
35+
- id: prettier
36+
types_or: [yaml, markdown, html, css, scss, javascript, json]
37+
args: [--prose-wrap=always]
638

739
- repo: https://github.com/astral-sh/ruff-pre-commit
8-
rev: v0.8.4
40+
rev: "v0.15.11"
941
hooks:
1042
- id: ruff
11-
- id: ruff-format
43+
args: ["--fix", "--show-fixes"]
44+
- id: ruff-format
45+
46+
- repo: https://github.com/codespell-project/codespell
47+
rev: "v2.4.2"
48+
hooks:
49+
- id: codespell
50+
51+
- repo: https://github.com/shellcheck-py/shellcheck-py
52+
rev: "v0.11.0.1"
53+
hooks:
54+
- id: shellcheck
55+
56+
- repo: https://github.com/abravalheri/validate-pyproject
57+
rev: "v0.25"
58+
hooks:
59+
- id: validate-pyproject
60+
additional_dependencies:
61+
- validate-pyproject[all]
62+
- validate-pyproject-schema-store
63+
64+
- repo: https://github.com/python-jsonschema/check-jsonschema
65+
rev: "0.37.1"
66+
hooks:
67+
- id: check-dependabot
68+
- id: check-github-workflows
69+
- id: check-readthedocs

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
21+
THE SOFTWARE.

examples/handler/dicom_utils.js

Lines changed: 73 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,90 @@
1-
import { readDicomTags, readImageDicomFileSeries } from "https://cdn.jsdelivr.net/npm/@itk-wasm/dicom@7.6.4/dist/bundle/index-worker-embedded.min.js";
2-
import { writeImage } from "https://cdn.jsdelivr.net/npm/@itk-wasm/image-io@1.6.1/dist/bundle/index-worker-embedded.min.js";;
3-
1+
import {
2+
readDicomTags,
3+
readImageDicomFileSeries,
4+
} from "https://cdn.jsdelivr.net/npm/@itk-wasm/dicom@7.6.4/dist/bundle/index-worker-embedded.min.js";
5+
import { writeImage } from "https://cdn.jsdelivr.net/npm/@itk-wasm/image-io@1.6.1/dist/bundle/index-worker-embedded.min.js";
46

57
const PATIENT_NAME_TAG = "0010|0010";
68
const SERIE_DESCRIPTION_TAG = "0008|103e";
79

8-
const EXIT_SUCCESS = true
9-
const EXIT_FAILURE = false
10+
const EXIT_SUCCESS = true;
11+
const EXIT_FAILURE = false;
1012

1113
// Notice the patient_name destructuring which match the inputs param to the widget on the python side
12-
export async function validateDicomFilePatientName(dicom_file, { patient_name }) {
13-
console.log({dicom_file});
14-
const options = {
15-
tagsToRead: { tags: [SERIE_DESCRIPTION_TAG, PATIENT_NAME_TAG] }
16-
}
14+
export async function validateDicomFilePatientName(
15+
dicom_file,
16+
{ patient_name },
17+
) {
18+
console.log({ dicom_file });
19+
const options = {
20+
tagsToRead: { tags: [SERIE_DESCRIPTION_TAG, PATIENT_NAME_TAG] },
21+
};
1722

18-
const { tags } = await readDicomTags(dicom_file, options);
19-
console.log({ tags })
23+
const { tags } = await readDicomTags(dicom_file, options);
24+
console.log({ tags });
2025

21-
for (const [tag_code, tag_value] of tags) {
22-
if (tag_code === PATIENT_NAME_TAG) {
23-
if (tag_value.trim() !== patient_name.trim() && tag_value !== "Anonymized") {
24-
const output = {
25-
expected: patient_name,
26-
got: tag_value
27-
};
28-
return {
29-
status: EXIT_FAILURE,
30-
outputs: [output]
31-
};
32-
}
33-
}
26+
for (const [tag_code, tag_value] of tags) {
27+
if (tag_code === PATIENT_NAME_TAG) {
28+
if (
29+
tag_value.trim() !== patient_name.trim() &&
30+
tag_value !== "Anonymized"
31+
) {
32+
const output = {
33+
expected: patient_name,
34+
got: tag_value,
35+
};
36+
return {
37+
status: EXIT_FAILURE,
38+
outputs: [output],
39+
};
40+
}
3441
}
42+
}
3543

36-
return {
37-
status: EXIT_SUCCESS,
38-
outputs: [
39-
dicom_file
40-
]
41-
}
44+
return {
45+
status: EXIT_SUCCESS,
46+
outputs: [dicom_file],
47+
};
4248
}
4349

50+
export async function generateNIFTIFromDicomFileSet(
51+
dicom_fileset,
52+
{ output_file_name },
53+
) {
54+
console.log(dicom_fileset);
55+
const inputs = await Promise.all(
56+
dicom_fileset.map(async (file) => {
57+
const buffer = await file.arrayBuffer();
58+
return {
59+
path: file.name,
60+
data: new Uint8Array(buffer),
61+
};
62+
}),
63+
);
4464

45-
export async function generateNIFTIFromDicomFileSet(dicom_fileset, { output_file_name }) {
46-
console.log(dicom_fileset);
47-
const inputs = await Promise.all(
48-
dicom_fileset.map(async (file) => {
49-
const buffer = await file.arrayBuffer();
50-
return {
51-
path: file.name,
52-
data: new Uint8Array(buffer),
53-
};
54-
})
55-
);
56-
57-
let image_result;
58-
try {
59-
image_result = await readImageDicomFileSeries({ inputImages: inputs, singleSortedSeries: true });
60-
} catch (e) {
61-
return {
62-
status: false,
63-
outputs: "Error while reading DICOM file series"
64-
}
65-
}
65+
let image_result;
66+
try {
67+
image_result = await readImageDicomFileSeries({
68+
inputImages: inputs,
69+
singleSortedSeries: true,
70+
});
71+
} catch (e) {
72+
return {
73+
status: false,
74+
outputs: "Error while reading DICOM file series",
75+
};
76+
}
6677

67-
const nifti_image_result = await writeImage(
68-
image_result.outputImage,
69-
output_file_name,
70-
{ mimeType: "image/nii" }
71-
);
78+
const nifti_image_result = await writeImage(
79+
image_result.outputImage,
80+
output_file_name,
81+
{ mimeType: "image/nii" },
82+
);
7283

73-
const blob = new Blob([nifti_image_result.serializedImage.data.buffer]);
84+
const blob = new Blob([nifti_image_result.serializedImage.data.buffer]);
7485

75-
return {
76-
status: true,
77-
outputs: [new File([blob], output_file_name)],
78-
}
86+
return {
87+
status: true,
88+
outputs: [new File([blob], output_file_name)],
89+
};
7990
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
node_modules
22
dist
3-
package-lock.json
3+
package-lock.json

0 commit comments

Comments
 (0)