Skip to content

Commit d4deac7

Browse files
authored
Update to honor cpu count env var
1 parent 61fd99d commit d4deac7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/mdio/converters/segy.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ def segy_to_mdio( # noqa: PLR0913, PLR0915, PLR0912
354354
... grid_overrides={"HasDuplicates": True},
355355
... )
356356
"""
357+
from zarr.core.config import config as zarr_config
358+
import os
359+
num_cpus = int(os.getenv("MDIO__IMPORT__CPU_COUNT", 1))
360+
zarr_config.set({"threading.max_workers": num_cpus})
361+
357362
index_names = index_names or [f"dim_{i}" for i in range(len(index_bytes))]
358363
index_types = index_types or ["int32"] * len(index_bytes)
359364

@@ -521,6 +526,7 @@ def segy_to_mdio( # noqa: PLR0913, PLR0915, PLR0912
521526
write_attribute(name="text_header", zarr_group=meta_group, attribute=text_header.split("\n"))
522527
write_attribute(name="binary_header", zarr_group=meta_group, attribute=binary_header.to_dict())
523528

529+
zarr_config.set({"threading.max_workers": 1})
524530
# Write traces
525531
stats = blocked_io.to_zarr(
526532
segy_file=segy,

0 commit comments

Comments
 (0)