Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add python 3.12 testing #1087

Merged
merged 11 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python_version: ["3.8", "3.9", "3.10", "3.11"]
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (llm): Adding Python 3.12 to the testing matrix is a great move for forward compatibility. However, it's important to ensure that all dependencies of the project are compatible with Python 3.12. Have we verified that all dependencies support Python 3.12, or are there any known issues?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (llm): Expanding the testing matrix to include Python 3.12 across different operating systems is commendable for ensuring cross-platform compatibility. However, have we considered the potential impact on CI build times and resource usage? It might be beneficial to monitor these aspects to ensure efficient CI operations.

os: ["ubuntu-20.04"]
qt_backend: ["PyQt5"]
tox_args: [ "" ]
Expand Down Expand Up @@ -78,7 +78,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python_version: ["3.8", "3.9", "3.10"]
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: ["ubuntu-20.04", "macos-11", "windows-2019"]
qt_backend: ["PySide2", "PyQt5"]
include:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upgrade-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
pip install -U uv
flags=(--extra pyqt5 --extra pyqt6 --extra pyside2 --extra pyside6 --extra test --extra pyinstaller)

for pyv in 3.8 3.9 3.10 3.11; do
for pyv in 3.8 3.9 3.10 3.11 3.12; do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (llm): Including Python 3.12 in the upgrade-dependencies workflow is crucial for maintaining up-to-date dependencies. However, it's equally important to ensure that the upgrade process accounts for any Python 3.12 specific dependencies or version constraints. Are there any additional steps or considerations needed for Python 3.12 in the upgrade process?

uv pip compile --python-version ${pyv} --upgrade --output-file requirements/constraints_py${pyv}.txt pyproject.toml requirements/version_denylist.txt "${flags[@]}"
uv pip compile --python-version ${pyv} --upgrade --output-file requirements/constraints_py${pyv}_pydantic_1.txt pyproject.toml requirements/version_denylist.txt "${flags[@]}" --constraint requirements/pydantic_1.txt
done
Expand Down
7 changes: 1 addition & 6 deletions package/PartSeg/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import contextlib
import importlib
import itertools
import os
import pkgutil
import sys
import typing
from importlib.metadata import entry_points

import PartSegCore.plugins

Expand All @@ -30,10 +28,7 @@ def get_plugins():
else:
sys.path.append(os.path.dirname(__file__))
packages = list(pkgutil.iter_modules(__path__))
packages2 = itertools.chain(
entry_points().get("PartSeg.plugins", []),
entry_points().get("partseg.plugins", []),
)
packages2 = PartSegCore.plugins.iter_entrypoints("PartSeg.plugins")
return [importlib.import_module(el.name) for el in packages] + [el.load() for el in packages2]


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,11 @@ def get_results(self) -> BatchResultDescription:
responses: list[tuple[uuid.UUID, WrappedResult]] = self.batch_manager.get_result()
new_errors: list[tuple[str, ErrorInfo]] = []
for uuid_id, (ind, result_list) in responses:
if uuid_id == "-1": # pragma: no cover
self.errors_list.append((f"Unknown file {ind}", result_list))
new_errors.append((f"Unknown file {ind}", result_list))
continue

self.calculation_done += 1
self.counter_dict[uuid_id] += 1
calculation = self.calculation_dict[uuid_id]
Expand Down
17 changes: 10 additions & 7 deletions package/PartSegCore/analysis/batch_processing/parallel_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,13 @@ def spawn_worker(task_queue: Queue, order_queue: Queue, result_queue: Queue, cal
:param result_queue: Queue for calculation result
:param calculation_dict: dict with global parameters
"""
register_if_need()
with suppress(ImportError):
from PartSeg.plugins import register_if_need as register

register()
worker = BatchWorker(task_queue, order_queue, result_queue, calculation_dict)
worker.run()
try:
register_if_need()
with suppress(ImportError):
from PartSeg.plugins import register_if_need as register

register()
worker = BatchWorker(task_queue, order_queue, result_queue, calculation_dict)
worker.run()
except Exception as e: # pragma: no cover # pylint: disable=broad-except
result_queue.put(("-1", (-1, [(e, traceback.extract_tb(e.__traceback__))])))
19 changes: 15 additions & 4 deletions package/PartSegCore/plugins/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
import importlib
import itertools
import pkgutil
import sys
import typing
from importlib.metadata import entry_points


def iter_entrypoints(group: str):
if sys.version_info < (3, 10):
return itertools.chain(
entry_points().get(group, []),
entry_points().get(group.lower(), []),
)

return itertools.chain(
entry_points().select(group=group),
entry_points().select(group=group.lower()),
)


def get_plugins():
packages = pkgutil.iter_modules(__path__, f"{__name__}.")
packages2 = itertools.chain(
entry_points().get("PartSegCore.plugins", []),
entry_points().get("partsegcore.plugins", []),
)
packages2 = iter_entrypoints("PartSegCore.plugins")
return [importlib.import_module(el.name) for el in packages] + [el.load() for el in packages2]


Expand Down
4 changes: 3 additions & 1 deletion package/tests/test_PartSegCore/test_analysis_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,9 @@ def mask_operation_plan(request, simple_measurement_list):

def wait_for_calculation(manager):
for _ in range(int(120 / 0.1)):
manager.get_results()
res = manager.get_results()
if res.errors and res.errors[0][0].startswith("Unknown file"):
pytest.fail(str(res.errors)) # pragma: no cover
if manager.has_work:
time.sleep(0.1)
else:
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Topic :: Scientific/Engineering :: Image Processing",
Expand Down