Skip to content

Commit 8af1c58

Browse files
committed
rename env var for raw headers
1 parent dd2fbb6 commit 8af1c58

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/mdio/converters/segy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,11 @@ def segy_to_mdio( # noqa PLR0913
435435
_, non_dim_coords = _get_coordinates(grid, segy_headers, mdio_template)
436436
header_dtype = to_structured_type(segy_spec.trace.header.dtype)
437437

438-
if os.getenv("MDIO__DO_RAW_HEADERS") == "1":
438+
if os.getenv("MDIO__IMPORT__RAW_HEADERS") in ("1", "true", "yes", "on"):
439439
if zarr.config.get("default_zarr_format") == ZarrFormat.V2:
440440
logger.warning("Raw headers are only supported for Zarr v3. Skipping raw headers.")
441441
else:
442-
logger.warning("MDIO__DO_RAW_HEADERS is experimental and expected to change or be removed.")
442+
logger.warning("MDIO__IMPORT__RAW_HEADERS is experimental and expected to change or be removed.")
443443
mdio_template = _add_raw_headers_to_template(mdio_template)
444444

445445
horizontal_unit = _get_horizontal_coordinate_unit(segy_dimensions)

tests/integration/test_segy_import_export_masked.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def export_masked_path(tmp_path_factory: pytest.TempPathFactory, raw_headers_env
286286
"""Fixture that generates temp directory for export tests."""
287287
# Create path suffix based on current raw headers environment variable
288288
# raw_headers_env dependency ensures the environment variable is set before this runs
289-
raw_headers_enabled = os.getenv("MDIO__DO_RAW_HEADERS") == "1"
289+
raw_headers_enabled = os.getenv("MDIO__IMPORT__RAW_HEADERS") in ("1", "true", "yes", "on")
290290
path_suffix = "with_raw_headers" if raw_headers_enabled else "without_raw_headers"
291291

292292
if DEBUG_MODE:
@@ -296,17 +296,17 @@ def export_masked_path(tmp_path_factory: pytest.TempPathFactory, raw_headers_env
296296

297297
@pytest.fixture
298298
def raw_headers_env(request: pytest.FixtureRequest) -> None:
299-
"""Fixture to set/unset MDIO__DO_RAW_HEADERS environment variable."""
299+
"""Fixture to set/unset MDIO__IMPORT__RAW_HEADERS environment variable."""
300300
env_value = request.param
301301
if env_value is not None:
302-
os.environ["MDIO__DO_RAW_HEADERS"] = env_value
302+
os.environ["MDIO__IMPORT__RAW_HEADERS"] = env_value
303303
else:
304-
os.environ.pop("MDIO__DO_RAW_HEADERS", None)
304+
os.environ.pop("MDIO__IMPORT__RAW_HEADERS", None)
305305

306306
yield
307307

308308
# Cleanup after test - both environment variable and template state
309-
os.environ.pop("MDIO__DO_RAW_HEADERS", None)
309+
os.environ.pop("MDIO__IMPORT__RAW_HEADERS", None)
310310

311311
# Clean up any template modifications to ensure test isolation
312312
registry = TemplateRegistry.get_instance()
@@ -513,7 +513,7 @@ def test_raw_headers_byte_preservation(
513513
export_masked_path: Path,
514514
raw_headers_env: None, # noqa: ARG002
515515
) -> None:
516-
"""Test that raw headers are preserved byte-for-byte when MDIO__DO_RAW_HEADERS=1."""
516+
"""Test that raw headers are preserved byte-for-byte when MDIO__IMPORT__RAW_HEADERS=1."""
517517
grid_conf, segy_factory_conf, _, _ = test_conf
518518
segy_path = export_masked_path / f"{grid_conf.name}.sgy"
519519
mdio_path = export_masked_path / f"{grid_conf.name}.mdio"
@@ -523,10 +523,12 @@ def test_raw_headers_byte_preservation(
523523

524524
# Check if raw_headers should exist based on environment variable
525525
has_raw_headers = "raw_headers" in ds.data_vars
526-
if os.getenv("MDIO__DO_RAW_HEADERS") == "1":
527-
assert has_raw_headers, "raw_headers should be present when MDIO__DO_RAW_HEADERS=1"
526+
if os.getenv("MDIO__IMPORT__RAW_HEADERS") in ("1", "true", "yes", "on"):
527+
assert has_raw_headers, "raw_headers should be present when MDIO__IMPORT__RAW_HEADERS=1"
528528
else:
529-
assert not has_raw_headers, f"raw_headers should not be present when MDIO__DO_RAW_HEADERS is not set\n {ds}"
529+
assert not has_raw_headers, (
530+
f"raw_headers should not be present when MDIO__IMPORT__RAW_HEADERS is not set\n {ds}"
531+
)
530532
return # Exit early if raw_headers are not expected
531533

532534
# Get data (only if raw_headers exist)

0 commit comments

Comments
 (0)