Skip to content

Commit

Permalink
BUG: and ENH:Fix and improve github actions for formatting (#26)
Browse files Browse the repository at this point in the history
Also updated files based on ruff results.
  • Loading branch information
aylward authored May 4, 2024
1 parent 1755c22 commit 24e1624
Show file tree
Hide file tree
Showing 24 changed files with 165 additions and 210 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/auto-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Auto-Format"

on: [push]

jobs:
ruff-check:
name: "Auto-Format"
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- uses: psf/black@stable
with:
use_pyproject: true
- uses: chartboost/ruff-action@v1
with:
args: "check --fix --config pyproject.toml"
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "STYLE:Fixes by auto-format"
21 changes: 0 additions & 21 deletions .github/workflows/lint.yml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/snorkell-auto-documentation.yml

This file was deleted.

5 changes: 2 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ repos:
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: trailing-whitespace
- id: double-quote-string-fixer
- repo: https://github.com/python/black.git
rev: 22.10.0
rev: 24.4.2
hooks:
- id: black
language_version: python3
Expand All @@ -30,4 +29,4 @@ repos:
hooks:
- id: prettier
stages: [commit]
exclude: ["src/ui_*", "*.md"]
exclude: "ui_.*|.*md|.*ui"
33 changes: 14 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
name = "minder3d"
description = "Using AI to foster innovation in the exploration of radiological images."
license = {text = "Apache 2.0"}
requires-python = ">=3.10"
requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3"
]
Expand All @@ -25,11 +25,11 @@ dependencies = [
minder3d = "minder3d.main:main"

[project.optional-dependencies]

develop = [
'black',
'black==24.4.2',
'pylint',
'flake8'
'flake8',
'pre-commit',
]

[tool.setuptools.packages.find]
Expand All @@ -41,22 +41,12 @@ readme = {file = ["README.md"]}

[tool.black]
line-length = 80
skip-string-normalization = 1
skip-string-normalization = true
target_version = ['py311']
exclude = '''
include = ["src"]
force-exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| build
| dist
)/
| .gitignore
ui_.*|.*\.ui|\.gitignore|.*\.yml|.*\.yaml|.*\.toml
)
'''

Expand All @@ -66,8 +56,13 @@ extend-ignore = ["E501"]

[tool.isort]
profile = "black"
skip_glob = "src/ui_*"
skip_glob = ["ui_*", "*.ui"]
line_length = 80

[tool.pylint]
max-line-length = 80

[tool.ruff]
include = ["*.py"]
exclude = ["*.ui", "ui_*", ".gitignore"]
line-length = 80
2 changes: 1 addition & 1 deletion src/minder3d/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.9.0"
__version__ = '0.9.0'
7 changes: 4 additions & 3 deletions src/minder3d/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ def parse_config() -> argparse.Namespace:
"""

parser = argparse.ArgumentParser(
description="Enabling innovative AI for medical imaging.")
description='Enabling innovative AI for medical imaging.'
)

parser.add_argument(
"--load-image", type=str, required=False, help="Path to image"
'--load-image', type=str, required=False, help='Path to image'
)
parser.add_argument(
"--load-scene", type=str, required=False, help="Path to scene"
'--load-scene', type=str, required=False, help='Path to scene'
)

args = parser.parse_args()
Expand Down
1 change: 0 additions & 1 deletion src/minder3d/lib/sovChatPanelWidget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QWidget

from .ui_sovChatPanelWidget import Ui_ChatPanelWidget
Expand Down
5 changes: 3 additions & 2 deletions src/minder3d/lib/sovImageTablePanelWidget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This module provides the ImageTablePanelWidget class."""

from PySide6.QtCore import QSize
from PySide6.QtGui import QIcon, QPixmap
from PySide6.QtWidgets import (
Expand Down Expand Up @@ -135,13 +136,13 @@ def fill_table(self):
self.imageTableWidget.setItem(
img_num, 2, QTableWidgetItem(file.filename)
)
if type(file.file_size) is type([]) and len(file.file_size) > 0:
if isinstance(file.file_size, []) and len(file.file_size) > 0:
size_str = [str(i) for i in file.file_size]
self.imageTableWidget.setItem(
img_num, 3, QTableWidgetItem('x'.join(size_str))
)
if (
type(file.file_spacing) is type([])
isinstance(file.file_spacing, [])
and len(file.file_spacing) > 0
):
spacing_str = [f'{i:.4f}' for i in file.file_spacing]
Expand Down
7 changes: 1 addition & 6 deletions src/minder3d/lib/sovInfoTablePanelWidget.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
from PySide6.QtWidgets import (
QHeaderView,
QTableWidget,
QTableWidgetItem,
QWidget,
)
from PySide6.QtWidgets import QTableWidget, QTableWidgetItem, QWidget

from .sovUtils import time_and_log
from .ui_sovInfoTablePanelWidget import Ui_InfoTablePanelWidget
Expand Down
1 change: 1 addition & 0 deletions src/minder3d/lib/sovLungCTALogic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import importlib.util as imp
import subprocess
import sys

import itk
Expand Down
2 changes: 0 additions & 2 deletions src/minder3d/lib/sovLungCTAPanelWidget.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import numpy as np
from PySide6.QtGui import QCloseEvent
from PySide6.QtWidgets import QMessageBox, QWidget

from .sovLungCTALogic import LungCTALogic
Expand Down
4 changes: 0 additions & 4 deletions src/minder3d/lib/sovOtsuPanelWidget.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import importlib.util as imp

import numpy as np
from PySide6.QtGui import QCloseEvent
from PySide6.QtWidgets import QWidget

from .sovOtsuLogic import OtsuLogic
Expand Down
1 change: 0 additions & 1 deletion src/minder3d/lib/sovScreenCapturePanelWidget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QWidget

from .ui_sovScreenCapturePanelWidget import Ui_ScreenCapturePanelWidget
Expand Down
1 change: 0 additions & 1 deletion src/minder3d/lib/sovTubesPanelWidget.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QWidget

from .ui_sovPreProcessPanelWidget import Ui_PreProcessPanelWidget
Expand Down
1 change: 0 additions & 1 deletion src/minder3d/lib/sovUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import os
import time
import uuid
from typing import Union

import itk
import numpy as np
Expand Down
36 changes: 16 additions & 20 deletions src/minder3d/lib/sovView2DPanelWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,13 @@ def create_new_image(self):

@time_and_log
def update_image(self):
imin = self.state.image_min[self.state.current_image_num]
imax = self.state.image_max[self.state.current_image_num]
irange = imax - imin

auto_range = np.quantile(self.state.image_array[-1], [0.1, 0.9])
self.state.view2D_intensity_window_min[
self.state.current_image_num
] = auto_range[0]
self.state.view2D_intensity_window_max[
self.state.current_image_num
] = auto_range[1]
self.state.view2D_intensity_window_min[self.state.current_image_num] = (
auto_range[0]
)
self.state.view2D_intensity_window_max[self.state.current_image_num] = (
auto_range[1]
)

self.update_gui = False

Expand Down Expand Up @@ -272,11 +268,11 @@ def update_overlay(self):
self.state.image[self.state.current_image_num],
self.state.overlay_array[self.state.current_image_num],
)
self.state.overlay[
self.state.current_image_num
] = itk.GetImageFromArray(
self.state.overlay_array[self.state.current_image_num],
ttype=self.state.overlay_type,
self.state.overlay[self.state.current_image_num] = (
itk.GetImageFromArray(
self.state.overlay_array[self.state.current_image_num],
ttype=self.state.overlay_type,
)
)
self.state.overlay[self.state.current_image_num].CopyInformation(
self.state.image[self.state.current_image_num]
Expand Down Expand Up @@ -366,11 +362,11 @@ def redraw_object(self, so):
self.state.image[self.state.current_image_num],
self.state.overlay_array[self.state.current_image_num],
)
self.state.overlay[
self.state.current_image_num
] = itk.GetImageFromArray(
self.state.overlay_array[self.state.current_image_num],
ttype=self.state.overlay_type,
self.state.overlay[self.state.current_image_num] = (
itk.GetImageFromArray(
self.state.overlay_array[self.state.current_image_num],
ttype=self.state.overlay_type,
)
)
self.state.overlay[self.state.current_image_num].CopyInformation(
self.state.image[self.state.current_image_num]
Expand Down
12 changes: 6 additions & 6 deletions src/minder3d/lib/sovView2DRenderWindowInteractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ def reset_camera(self):

@time_and_log
def update_image(self):
self.state.view2D_intensity_window_min[
self.state.current_image_num
] = self.state.image_min[self.state.current_image_num]
self.state.view2D_intensity_window_max[
self.state.current_image_num
] = self.state.image_max[self.state.current_image_num]
self.state.view2D_intensity_window_min[self.state.current_image_num] = (
self.state.image_min[self.state.current_image_num]
)
self.state.view2D_intensity_window_max[self.state.current_image_num] = (
self.state.image_max[self.state.current_image_num]
)
if self.view2D is None:
self.view2D = vtk.vtkImageViewer2()
self.view2D.SetupInteractor(self)
Expand Down
1 change: 0 additions & 1 deletion src/minder3d/lib/sovView3DRenderWindowInteractor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import itk
from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
from vtkmodules.vtkInteractionStyle import vtkInteractorStyleTrackballCamera
from vtkmodules.vtkRenderingCore import (
Expand Down
1 change: 0 additions & 1 deletion src/minder3d/lib/sovView3DUtils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import itk
import numpy as np
from vtkmodules.vtkCommonCore import vtkDoubleArray, vtkPoints
from vtkmodules.vtkCommonDataModel import vtkCellArray, vtkPolyData, vtkPolyLine
from vtkmodules.vtkFiltersCore import vtkSurfaceNets3D, vtkTubeFilter
Expand Down
5 changes: 3 additions & 2 deletions src/minder3d/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Launch the minder3D application
"""

import sys

from PySide6.QtCore import Qt
from PySide6.QtGui import QColor, QPalette
Expand All @@ -13,6 +12,7 @@
from .config import parse_config
from .minder3DWindow import Minder3DWindow


def main():
"""
Application entrypoint.
Expand Down Expand Up @@ -56,5 +56,6 @@ def main():

app.exec()

if __name__ == "__main__":

if __name__ == '__main__':
main()
1 change: 1 addition & 0 deletions src/minder3d/minder3DState.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The global state of the Minder3D application."""

import logging

import itk
Expand Down
Loading

0 comments on commit 24e1624

Please sign in to comment.