Skip to content

Commit 20dbfeb

Browse files
committed
pre-commit and cleanup warnings
1 parent 8486672 commit 20dbfeb

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/mdio/segy/_workers.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import TYPE_CHECKING
77

88
import numpy as np
9+
from segy import SegyFile
910
from segy.arrays import HeaderArray
1011

1112
from mdio.core.config import MDIOSettings
@@ -15,10 +16,9 @@
1516

1617
if TYPE_CHECKING:
1718
from zarr import Array as zarr_Array
18-
from zarr import Group as zarr_Group
19-
from segy import SegyFile
2019

2120
from zarr.core.config import config as zarr_config
21+
2222
from mdio.builder.schemas.v1.stats import CenteredBinHistogram
2323
from mdio.builder.schemas.v1.stats import SummaryStatistics
2424
from mdio.constants import fill_value_map
@@ -31,16 +31,18 @@
3131

3232
def _init_worker(segy_file_kwargs: SegyFileArguments) -> None:
3333
"""Initialize worker process with persistent segy file handle.
34-
34+
3535
This function is called once per worker process to open the segy file,
3636
which is then reused across all tasks in that worker.
37-
37+
3838
Args:
3939
segy_file_kwargs: Arguments to open SegyFile instance.
4040
"""
41-
global _worker_segy_file
42-
43-
from segy import SegyFile
41+
global _worker_segy_file # noqa: PLW0603
42+
# TODO(BrianMichell): Diagnose and fix handles not being cleaned up on cloud2cloud ingesions.
43+
# https://github.com/TGSAI/mdio-python/pull/712
44+
# https://github.com/TGSAI/mdio-python/pull/701
45+
# The reason for having a global variable is to reduce the number of GET requests for opening the file.
4446

4547
# Open the SEG-Y file once per worker
4648
_worker_segy_file = SegyFile(**segy_file_kwargs)
@@ -96,7 +98,7 @@ def trace_worker( # noqa: PLR0913
9698
grid_map: zarr_Array,
9799
) -> SummaryStatistics | None:
98100
"""Writes a subset of traces from a region of the dataset of Zarr file.
99-
101+
100102
Uses pre-opened segy file from _init_worker and receives zarr arrays directly.
101103
102104
Args:
@@ -109,8 +111,8 @@ def trace_worker( # noqa: PLR0913
109111
Returns:
110112
SummaryStatistics object containing statistics about the written traces.
111113
"""
112-
global _worker_segy_file
113-
114+
global _worker_segy_file # noqa: PLW0602
115+
114116
# Use the pre-opened segy file from worker initialization
115117
segy_file = _worker_segy_file
116118

src/mdio/segy/blocked_io.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ def to_zarr( # noqa: PLR0913, PLR0915
9090
mode="r+",
9191
storage_options=storage_options,
9292
use_consolidated=zarr_format == ZarrFormat.V2,
93-
zarr_version=zarr_format,
94-
zarr_format=zarr_format,
9593
)
9694

9795
# Get array handles from the opened group

0 commit comments

Comments
 (0)