-
Notifications
You must be signed in to change notification settings - Fork 12
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
Fix parallel buffered slice writer bug #922
Merged
Merged
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
9204b09
Extend traceback to get exception of future.
markbader 2bb3883
Implement pad flag for webknossos cli convert subcommand.
markbader 54d3477
Implement hotfix solution for fitting bbox without pad flag.
markbader 3fe785e
Merge branch 'master' into Fix_parallel_BufferedSliceWriter_bug
markbader 7c6f46d
Update changelog.
markbader 44dd88c
Merge branch 'master' into Fix_parallel_BufferedSliceWriter_bug
markbader 52cc6b6
Add update_bbox argument and propagate it from from_images to actual …
markbader 5fe1387
Merge branch 'master' into Fix_parallel_BufferedSliceWriter_bug
markbader 1863194
Implement requested changes.
markbader 3bbcd06
Minor changes to default values.
markbader a6366c1
Run formatter.
markbader f230aed
Merge branch 'master' into Fix_parallel_BufferedSliceWriter_bug
markbader e3336f7
Add filelock dependency and start to change to SoftFileLock implement…
markbader 1f4f773
Implement filelock (upaths are not supported yet).
markbader 9122256
Adapted implementation of SoftFileLock. Still does not support filelo…
markbader cf643d1
Reverted changes with filelock and make some notes for further implem…
markbader b21b997
Add json_update_allowed bool.
markbader 54acf99
Merge branch 'master' into Fix_parallel_BufferedSliceWriter_bug
markbader ea7dc34
Add paragraph in docs and implement requested changes.
markbader 3256aa0
Merge branch 'master' into Fix_parallel_BufferedSliceWriter_bug
markbader File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
import numpy as np | ||
import psutil | ||
|
||
from webknossos.dataset.mag_view import MagView | ||
from webknossos.geometry import Vec3Int, Vec3IntLike | ||
|
||
if TYPE_CHECKING: | ||
|
@@ -34,6 +35,9 @@ def __init__( | |
self, | ||
view: "View", | ||
offset: Optional[Vec3IntLike] = None, | ||
# update_bbox enables the update of the bounding box and rewriting of the properties json. | ||
# It should be False when parallel access is intended. | ||
update_bbox: bool = True, | ||
# buffer_size specifies, how many slices should be aggregated until they are flushed. | ||
buffer_size: int = 32, | ||
dimension: int = 2, # z | ||
|
@@ -48,6 +52,7 @@ def __init__( | |
self.buffer_size = buffer_size | ||
self.dtype = self.view.get_dtype() | ||
self.use_logging = use_logging | ||
self.update_bbox = update_bbox | ||
if offset is None and relative_offset is None and absolute_offset is None: | ||
relative_offset = Vec3Int.zeros() | ||
if offset is not None: | ||
|
@@ -124,12 +129,22 @@ def _write_buffer(self) -> None: | |
buffer_start_list[self.dimension] = self.buffer_start_slice | ||
buffer_start = Vec3Int(buffer_start_list) | ||
buffer_start_mag1 = buffer_start * self.view.mag.to_vec3_int() | ||
self.view.write( | ||
data, | ||
offset=buffer_start.add_or_none(self.offset), | ||
relative_offset=buffer_start_mag1.add_or_none(self.relative_offset), | ||
absolute_offset=buffer_start_mag1.add_or_none(self.absolute_offset), | ||
) | ||
if isinstance(self.view, MagView): | ||
self.view.write( | ||
data, | ||
offset=buffer_start.add_or_none(self.offset), | ||
relative_offset=buffer_start_mag1.add_or_none(self.relative_offset), | ||
absolute_offset=buffer_start_mag1.add_or_none(self.absolute_offset), | ||
update_bbox=self.update_bbox, | ||
) | ||
else: | ||
self.view.write( | ||
data, | ||
offset=buffer_start.add_or_none(self.offset), | ||
relative_offset=buffer_start_mag1.add_or_none(self.relative_offset), | ||
absolute_offset=buffer_start_mag1.add_or_none(self.absolute_offset), | ||
allow_write_outside_bbox=not self.update_bbox, | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be DRYed with something like this, I think:
|
||
|
||
except Exception as exc: | ||
error( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this logic. If the bbox must not be updated, writing outside of the bbox is allowed? Shouldn't this be inverted?