Skip to content

Commit

Permalink
Fix missing to close file handle (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
erikogabrielsson committed Feb 22, 2024
1 parent 5886d11 commit 4cb8fce
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 77 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.13.1] - 2023-02-22

### Fixed

- Updated version of `WsiDicom` to 0.20.1 to fix missing to close file handle.

## [0.13.0] - 2023-02-15

### Added
Expand Down
146 changes: 85 additions & 61 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "wsidicomizer"
version = "0.13.0"
version = "0.13.1"
description = "Tool for reading WSI files from proprietary formats and optionally convert them to to DICOM"
authors = ["Erik O Gabrielsson <erik.o.gabrielsson@sectra.com>"]
license = "Apache-2.0"
Expand All @@ -18,8 +18,8 @@ classifiers = [

[tool.poetry.dependencies]
python = "^3.9"
wsidicom = "^0.18.2"
opentile = "^0.11.1"
wsidicom = "^0.20.1"
opentile = "^0.12.0"
numpy = "^1.22.0"
pydicom = ">=2.1.0"
czifile = ">=2019.7.2"
Expand Down
2 changes: 1 addition & 1 deletion wsidicomizer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@

from wsidicomizer.wsidicomizer import WsiDicomizer

__version__ = "0.13.0"
__version__ = "0.13.1"

__all__ = ["WsiDicomizer"]
15 changes: 4 additions & 11 deletions wsidicomizer/extras/openslide/openslide_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@

import math
from pathlib import Path
from typing import Any, Dict, List, Optional
from typing import List, Optional

from fsspec.core import url_to_fs
from fsspec.implementations.local import LocalFileSystem
from upath import UPath
from wsidicom.codec import Encoder
from wsidicom.metadata.wsi import WsiMetadata

Expand All @@ -38,18 +35,15 @@
class OpenSlideSource(DicomizerSource):
def __init__(
self,
filepath: UPath,
filepath: Path,
encoder: Encoder,
tile_size: int = 512,
metadata: Optional[WsiMetadata] = None,
default_metadata: Optional[WsiMetadata] = None,
include_confidential: bool = True,
file_options: Optional[Dict[str, Any]] = None,
) -> None:
fs, path = url_to_fs(str(filepath), **file_options or {})
if not isinstance(fs, LocalFileSystem):
raise ValueError("OpenSlideSource only supports local files.")
self._slide = OpenSlide(path)
self._slide = OpenSlide(filepath)

self._pyramid_levels = self._get_pyramid_levels(self._slide)
self._base_metadata = OpenSlideMetadata(self._slide)
super().__init__(
Expand All @@ -59,7 +53,6 @@ def __init__(
metadata,
default_metadata,
include_confidential,
file_options,
)

def close(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion wsidicomizer/wsidicomizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def open(
include_confidential,
**source_args,
)
return cls(source)
return cls(source, True)

@classmethod
def convert(
Expand Down

0 comments on commit 4cb8fce

Please sign in to comment.