aignostics 0.2.22__tar.gz → 0.2.23__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {aignostics-0.2.22 → aignostics-0.2.23}/PKG-INFO +1 -1
- {aignostics-0.2.22 → aignostics-0.2.23}/examples/notebook.py +1 -1
- {aignostics-0.2.22 → aignostics-0.2.23}/pyproject.toml +2 -2
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/wsi/_gui.py +14 -19
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/wsi/_openslide_handler.py +16 -1
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/wsi/_service.py +46 -63
- aignostics-0.2.23/src/aignostics/wsi/assets/fallback.png +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/.gitignore +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/LICENSE +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/README.md +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/.openapi-generator/FILES +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/.openapi-generator/VERSION +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/api/public_api.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/api_client.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/api_response.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/configuration.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/exceptions.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/__init__.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/application_read_response.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/application_run_status.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/application_version_read_response.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/http_validation_error.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/input_artifact_creation_request.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/input_artifact_read_response.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/item_creation_request.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/item_result_read_response.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/item_status.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/output_artifact_read_response.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/output_artifact_result_read_response.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/output_artifact_scope.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/payload_input_artifact.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/payload_item.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/payload_output_artifact.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/run_creation_request.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/run_creation_response.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/run_read_response.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/transfer_urls.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/user_payload.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/validation_error.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/validation_error_loc_inner.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/rest.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/docs/PublicApi.md +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/examples/__init__.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/examples/e2e.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/examples/notebook.ipynb +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/examples/script.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/__init__.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/__init__.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_cli.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/_frame.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/_page_application_describe.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/_page_application_run_describe.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/_page_builder.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/_page_index.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/_utils.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/canceled.lottie +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/done.lottie +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/empty.lottie +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/error.lottie +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/error_alt.lottie +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/home-card-1.png +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/home-card-2.png +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/home-card-3.png +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/home-card-4.png +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/home-card-5.png +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/image-not-found.png +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/pending.lottie +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/pending_alt.lottie +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/ruo.png +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/ruo.svg +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_service.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_settings.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_utils.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/bucket/__init__.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/bucket/_cli.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/bucket/_gui.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/bucket/_service.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/bucket/_settings.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/bucket/assets/Google-Cloud-logo.png +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/bucket/assets/Google-Cloud-logo.svg +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/cli.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/constants.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/dataset/__init__.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/dataset/_cli.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/dataset/_gui.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/dataset/_idc_index.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/dataset/_service.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/dataset/assets/NIH-IDC-logo.svg +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/gui/__init__.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/gui/_frame.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/gui/_theme.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/gui/assets/cabin-v27-latin-regular.woff2 +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/gui/assets/logo.png +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/notebook/__init__.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/notebook/_gui.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/notebook/_notebook.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/notebook/_service.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/notebook/assets/python.lottie +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/platform/__init__.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/platform/_authentication.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/platform/_client.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/platform/_constants.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/platform/_messages.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/platform/_service.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/platform/_settings.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/platform/_utils.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/platform/resources/__init__.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/platform/resources/applications.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/platform/resources/runs.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/platform/resources/utils.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/qupath/__init__.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/qupath/_cli.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/qupath/_gui.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/qupath/_service.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/qupath/_settings.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/qupath/assets/download.lottie +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/qupath/assets/microscope.lottie +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/system/__init__.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/system/_cli.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/system/_exceptions.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/system/_gui.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/system/_service.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/system/_settings.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/utils/.vendored/bottle.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/utils/__init__.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/utils/_cli.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/utils/_console.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/utils/_constants.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/utils/_di.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/utils/_gui.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/utils/_health.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/utils/_log.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/utils/_logfire.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/utils/_notebook.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/utils/_process.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/utils/_sentry.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/utils/_service.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/utils/_settings.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/utils/boot.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/wsi/__init__.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/wsi/_cli.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/wsi/_pydicom_handler.py +0 -0
- {aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/wsi/_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: aignostics
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.23
|
|
4
4
|
Summary: 🔬 Python SDK providing access to the Aignostics Platform. Includes Aignostics Launchpad (Desktop Application), Aignostics CLI (Command-Line Interface), example notebooks, and Aignostics Client Library.
|
|
5
5
|
Project-URL: Homepage, https://aignostics.readthedocs.io/en/latest/
|
|
6
6
|
Project-URL: Documentation, https://aignostics.readthedocs.io/en/latest/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "aignostics"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.23"
|
|
4
4
|
description = "🔬 Python SDK providing access to the Aignostics Platform. Includes Aignostics Launchpad (Desktop Application), Aignostics CLI (Command-Line Interface), example notebooks, and Aignostics Client Library."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -355,7 +355,7 @@ source = ["src/"]
|
|
|
355
355
|
|
|
356
356
|
|
|
357
357
|
[tool.bumpversion]
|
|
358
|
-
current_version = "0.2.
|
|
358
|
+
current_version = "0.2.23"
|
|
359
359
|
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
|
360
360
|
serialize = ["{major}.{minor}.{patch}"]
|
|
361
361
|
search = "{current_version}"
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
5
|
-
from fastapi import
|
|
5
|
+
from fastapi import Response
|
|
6
|
+
from fastapi.responses import RedirectResponse
|
|
6
7
|
|
|
7
8
|
from aignostics.utils import BasePageBuilder, get_logger
|
|
8
9
|
|
|
@@ -16,6 +17,8 @@ class PageBuilder(BasePageBuilder):
|
|
|
16
17
|
def register_pages() -> None:
|
|
17
18
|
from nicegui import app # noqa: PLC0415
|
|
18
19
|
|
|
20
|
+
app.add_static_files("/wsi_assets", Path(__file__).parent / "assets")
|
|
21
|
+
|
|
19
22
|
@app.get("/thumbnail")
|
|
20
23
|
def thumbnail(source: str) -> Response:
|
|
21
24
|
"""Serve a thumbnail for a given source reference.
|
|
@@ -24,21 +27,16 @@ class PageBuilder(BasePageBuilder):
|
|
|
24
27
|
source (str): The source of the slide pointing to a file on the filesystem.
|
|
25
28
|
|
|
26
29
|
Returns:
|
|
27
|
-
fastapi.Response: HTTP response containing the thumbnail image.
|
|
28
|
-
|
|
29
|
-
Raises:
|
|
30
|
-
HTTPException: If the file does not exist or if thumbnail generation fails.
|
|
30
|
+
fastapi.Response: HTTP response containing the thumbnail or fallback image.
|
|
31
31
|
"""
|
|
32
32
|
try:
|
|
33
33
|
return Response(content=Service().get_thumbnail_bytes(Path(source)), media_type="image/png")
|
|
34
|
-
except ValueError
|
|
34
|
+
except ValueError:
|
|
35
35
|
logger.warning("Error generating thumbnail on bad request or invalid image input")
|
|
36
|
-
|
|
37
|
-
except RuntimeError
|
|
36
|
+
return RedirectResponse("/wsi_assets/fallback.png")
|
|
37
|
+
except RuntimeError:
|
|
38
38
|
logger.exception("Internal server error when generating thumbnail")
|
|
39
|
-
|
|
40
|
-
status_code=500, detail=f"Internal server error when generating thumbnail: {e!s}"
|
|
41
|
-
) from e
|
|
39
|
+
return RedirectResponse("/wsi_assets/fallback.png")
|
|
42
40
|
|
|
43
41
|
@app.get("/tiff")
|
|
44
42
|
def tiff(url: str) -> Response:
|
|
@@ -48,16 +46,13 @@ class PageBuilder(BasePageBuilder):
|
|
|
48
46
|
url (str): The URL of the tiff.
|
|
49
47
|
|
|
50
48
|
Returns:
|
|
51
|
-
fastapi.Response: HTTP response containing the
|
|
52
|
-
|
|
53
|
-
Raises:
|
|
54
|
-
HTTPException: If the file does not exist or if thumbnail generation fails.
|
|
49
|
+
fastapi.Response: HTTP response containing the converted tiff or fallback image
|
|
55
50
|
"""
|
|
56
51
|
try:
|
|
57
52
|
return Response(content=Service().get_tiff_as_jpg(url), media_type="image/jpeg")
|
|
58
|
-
except ValueError
|
|
53
|
+
except ValueError:
|
|
59
54
|
logger.warning("Error generating jpeg on bad request or invalid tiff input")
|
|
60
|
-
|
|
61
|
-
except RuntimeError
|
|
55
|
+
return RedirectResponse("/wsi_assets/fallback.png")
|
|
56
|
+
except RuntimeError:
|
|
62
57
|
logger.exception("Internal server error when generating jpeg")
|
|
63
|
-
|
|
58
|
+
return RedirectResponse("/wsi_assets/fallback.png")
|
|
@@ -5,6 +5,7 @@ from pathlib import Path
|
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
7
|
import openslide
|
|
8
|
+
from openslide import ImageSlide, OpenSlide, open_slide
|
|
8
9
|
from PIL.Image import Image
|
|
9
10
|
|
|
10
11
|
TIFF_IMAGE_DESCRIPTION = "tiff.ImageDescription"
|
|
@@ -15,10 +16,21 @@ class OpenSlideHandler:
|
|
|
15
16
|
|
|
16
17
|
def __init__(self, path: str) -> None:
|
|
17
18
|
self.path = Path(path)
|
|
18
|
-
self.slide =
|
|
19
|
+
self.slide: OpenSlide | ImageSlide = open_slide(str(path))
|
|
19
20
|
|
|
20
21
|
@classmethod
|
|
21
22
|
def from_file(cls, path: str | Path) -> "OpenSlideHandler":
|
|
23
|
+
"""Create an OpenSlideHandler from a file path.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
path (str | Path): The path to the WSI file.
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
OpenSlideHandler: An instance of OpenSlideHandler initialized with the given path.
|
|
30
|
+
|
|
31
|
+
Raises:
|
|
32
|
+
OpenSlideError: If the file cannot be opened as a WSI.
|
|
33
|
+
"""
|
|
22
34
|
return cls(str(path))
|
|
23
35
|
|
|
24
36
|
def _detect_format(self) -> str | None:
|
|
@@ -55,6 +67,9 @@ class OpenSlideHandler:
|
|
|
55
67
|
|
|
56
68
|
Returns:
|
|
57
69
|
Image: Thumbnail image of the slide.
|
|
70
|
+
|
|
71
|
+
Raises:
|
|
72
|
+
OpenSlideError: If the slide cannot be opened or if thumbnail generation fails.
|
|
58
73
|
"""
|
|
59
74
|
return self.slide.get_thumbnail((256, 256))
|
|
60
75
|
|
|
@@ -12,6 +12,8 @@ logger = get_logger(__name__)
|
|
|
12
12
|
|
|
13
13
|
TIMEOUT = 60 # 1 minutes
|
|
14
14
|
|
|
15
|
+
FILE_TYPES_SUPPORTED = {".dcm", ".tiff", ".tif", ".svs"}
|
|
16
|
+
|
|
15
17
|
|
|
16
18
|
class Service(BaseService):
|
|
17
19
|
"""Service of the application module."""
|
|
@@ -34,58 +36,8 @@ class Service(BaseService):
|
|
|
34
36
|
status=Health.Code.UP,
|
|
35
37
|
)
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
Args:
|
|
41
|
-
path (Path): Path to the wsi file.
|
|
42
|
-
|
|
43
|
-
Returns:
|
|
44
|
-
dict[str, Any]: Metadata of the wsi file.
|
|
45
|
-
"""
|
|
46
|
-
from ._openslide_handler import OpenSlideHandler # noqa: PLC0415
|
|
47
|
-
|
|
48
|
-
handler = OpenSlideHandler.from_file(path)
|
|
49
|
-
return handler.get_metadata()
|
|
50
|
-
|
|
51
|
-
def _get_openslide_thumbnail(self, path: Path) -> "PIL.Image.Image": # type: ignore # noqa: F821, PLR6301
|
|
52
|
-
"""Get thumbnail of a wsi file via OpenSlide.
|
|
53
|
-
|
|
54
|
-
Args:
|
|
55
|
-
path (Path): Path to the wsi file.
|
|
56
|
-
|
|
57
|
-
Returns:
|
|
58
|
-
PIL.Image.Image: Thumbnail of the wsi file.
|
|
59
|
-
|
|
60
|
-
Raises:
|
|
61
|
-
OpenSlideError: If there is an error processing the wsi file with OpenSlide.
|
|
62
|
-
"""
|
|
63
|
-
from openslide import OpenSlideError, OpenSlideUnsupportedFormatError # noqa: PLC0415
|
|
64
|
-
from PIL import Image as PILImage # noqa: PLC0415
|
|
65
|
-
|
|
66
|
-
from ._openslide_handler import OpenSlideHandler # noqa: PLC0415
|
|
67
|
-
|
|
68
|
-
try:
|
|
69
|
-
handler = OpenSlideHandler.from_file(path)
|
|
70
|
-
return handler.get_thumbnail()
|
|
71
|
-
except OpenSlideUnsupportedFormatError:
|
|
72
|
-
# If OpenSlide fails, try using PIL directly
|
|
73
|
-
img_file = PILImage.open(path)
|
|
74
|
-
# Create a thumbnail with max size 256x256 while maintaining aspect ratio
|
|
75
|
-
img_file.thumbnail((256, 256))
|
|
76
|
-
# Convert to RGB mode if needed (for PNG compatibility)
|
|
77
|
-
return img_file.convert("RGB") if img_file.mode not in {"RGB", "RGBA"} else img_file.copy()
|
|
78
|
-
except OpenSlideError as e:
|
|
79
|
-
if str(e) == "No pyramid levels found":
|
|
80
|
-
# If regular OpenSlide fails, try using PIL directly
|
|
81
|
-
img_file = PILImage.open(path)
|
|
82
|
-
# Create a thumbnail with max size 256x256 while maintaining aspect ratio
|
|
83
|
-
img_file.thumbnail((256, 256))
|
|
84
|
-
# Convert to RGB mode if needed (for PNG compatibility)
|
|
85
|
-
return img_file.convert("RGB") if img_file.mode not in {"RGB", "RGBA"} else img_file.copy()
|
|
86
|
-
raise
|
|
87
|
-
|
|
88
|
-
def get_thumbnail(self, path: Path) -> "PIL.Image.Image": # type: ignore # noqa: F821
|
|
39
|
+
@staticmethod
|
|
40
|
+
def get_thumbnail(path: Path) -> "PIL.Image.Image": # type: ignore # noqa: F821
|
|
89
41
|
"""Get thumbnail as PIL image.
|
|
90
42
|
|
|
91
43
|
Args:
|
|
@@ -96,18 +48,27 @@ class Service(BaseService):
|
|
|
96
48
|
|
|
97
49
|
Raises:
|
|
98
50
|
ValueError: If the file type is not supported (.dcm, .tiff, or .tif).
|
|
51
|
+
RuntimeError: If there is an error generating the thumbnail.
|
|
99
52
|
"""
|
|
53
|
+
from ._openslide_handler import OpenSlideHandler # noqa: PLC0415
|
|
54
|
+
|
|
100
55
|
if path.exists() is False:
|
|
101
56
|
message = f"File does not exist: {path}"
|
|
102
57
|
logger.warning(message)
|
|
103
58
|
raise ValueError(message)
|
|
104
|
-
if path.suffix.lower() in
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
59
|
+
if path.suffix.lower() not in FILE_TYPES_SUPPORTED:
|
|
60
|
+
message = f"Unsupported file type: {path.suffix}. Supported types are .dcm, .tiff, and .tif."
|
|
61
|
+
logger.warning(message)
|
|
62
|
+
raise ValueError(message)
|
|
63
|
+
try:
|
|
64
|
+
return OpenSlideHandler.from_file(path).get_thumbnail()
|
|
65
|
+
except Exception as e:
|
|
66
|
+
message = f"Error processing file {path}: {e!s}"
|
|
67
|
+
logger.exception(message)
|
|
68
|
+
raise RuntimeError(message) from e
|
|
109
69
|
|
|
110
|
-
|
|
70
|
+
@staticmethod
|
|
71
|
+
def get_thumbnail_bytes(path: Path) -> bytes:
|
|
111
72
|
"""Get thumbnail of a image as bytes.
|
|
112
73
|
|
|
113
74
|
Args:
|
|
@@ -117,14 +78,16 @@ class Service(BaseService):
|
|
|
117
78
|
bytes: Thumbnail of the image.
|
|
118
79
|
|
|
119
80
|
Raises:
|
|
120
|
-
ValueError: If the file type is not supported
|
|
81
|
+
ValueError: If the file type is not supported.
|
|
82
|
+
RuntimeError: If there is an error processing the file.
|
|
121
83
|
"""
|
|
122
|
-
thumbnail_image =
|
|
84
|
+
thumbnail_image = Service.get_thumbnail(path)
|
|
123
85
|
buffer = io.BytesIO()
|
|
124
86
|
thumbnail_image.save(buffer, format="PNG")
|
|
125
87
|
return buffer.getvalue()
|
|
126
88
|
|
|
127
|
-
|
|
89
|
+
@staticmethod
|
|
90
|
+
def get_metadata(path: Path) -> dict[str, Any]:
|
|
128
91
|
"""Get metadata from a TIFF file.
|
|
129
92
|
|
|
130
93
|
Args:
|
|
@@ -132,10 +95,30 @@ class Service(BaseService):
|
|
|
132
95
|
|
|
133
96
|
Returns:
|
|
134
97
|
dict[str, Any]: Metadata of the TIFF file.
|
|
98
|
+
|
|
99
|
+
Raises:
|
|
100
|
+
ValueError: If the file type is not supported.
|
|
101
|
+
RuntimeError: If there is an error processing the file.
|
|
135
102
|
"""
|
|
136
|
-
|
|
103
|
+
from ._openslide_handler import OpenSlideHandler # noqa: PLC0415
|
|
104
|
+
|
|
105
|
+
if path.exists() is False:
|
|
106
|
+
message = f"File does not exist: {path}"
|
|
107
|
+
logger.warning(message)
|
|
108
|
+
raise ValueError(message)
|
|
109
|
+
if path.suffix.lower() not in FILE_TYPES_SUPPORTED:
|
|
110
|
+
message = f"Unsupported file type: {path.suffix}. Supported types are .dcm, .tiff, and .tif."
|
|
111
|
+
logger.warning(message)
|
|
112
|
+
raise ValueError(message)
|
|
113
|
+
try:
|
|
114
|
+
return OpenSlideHandler.from_file(path).get_metadata()
|
|
115
|
+
except Exception as e:
|
|
116
|
+
error_msg = f"Error processing file {path}: {e!s}"
|
|
117
|
+
logger.exception(error_msg)
|
|
118
|
+
raise RuntimeError(error_msg) from e
|
|
137
119
|
|
|
138
|
-
|
|
120
|
+
@staticmethod
|
|
121
|
+
def get_tiff_as_jpg(url: str) -> bytes:
|
|
139
122
|
"""Get a TIFF image from a URL and convert it to JPG format.
|
|
140
123
|
|
|
141
124
|
Args:
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/application_run_status.py
RENAMED
|
File without changes
|
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/http_validation_error.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/item_creation_request.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/output_artifact_scope.py
RENAMED
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/payload_input_artifact.py
RENAMED
|
File without changes
|
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/payload_output_artifact.py
RENAMED
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/run_creation_request.py
RENAMED
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/run_creation_response.py
RENAMED
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/run_read_response.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/codegen/out/aignx/codegen/models/validation_error.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/canceled.lottie
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/error_alt.lottie
RENAMED
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/home-card-1.png
RENAMED
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/home-card-2.png
RENAMED
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/home-card-3.png
RENAMED
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/home-card-4.png
RENAMED
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/home-card-5.png
RENAMED
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/image-not-found.png
RENAMED
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/pending.lottie
RENAMED
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/application/_gui/assets/pending_alt.lottie
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{aignostics-0.2.22 → aignostics-0.2.23}/src/aignostics/gui/assets/cabin-v27-latin-regular.woff2
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|