Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Fixes

- **Update README.md**: readme-only changes; added a link to Unstructured Pipelines to the README. No library behavior changes.
- **`UNSTRUCTURED_INCLUDE_DEBUG_METADATA` now parses its env var value as a boolean**: previously `os.getenv("UNSTRUCTURED_INCLUDE_DEBUG_METADATA", False)` treated any explicitly-set string value (including `"false"` or `"0"`) as truthy, so setting the variable to explicitly disable debug metadata actually enabled it. Now parses the value the same way `ENVConfig._get_bool` already does elsewhere in the codebase (`"true"`/`"1"`/`"t"`, case-insensitive, is `True`; everything else, including unset, is `False`).

## 0.25.0

Expand Down
36 changes: 36 additions & 0 deletions test_unstructured/partition/utils/test_config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,46 @@
import importlib
import shutil
import tempfile
from pathlib import Path

import pytest


@pytest.mark.parametrize(
("env_value", "expected"),
[
("true", True),
("1", True),
("t", True),
("false", False),
("0", False),
("no", False),
],
)
def test_include_debug_metadata_parses_bool_string(monkeypatch, env_value, expected):
from unstructured.partition.utils import constants

monkeypatch.setenv("UNSTRUCTURED_INCLUDE_DEBUG_METADATA", env_value)
try:
importlib.reload(constants)
assert constants.UNSTRUCTURED_INCLUDE_DEBUG_METADATA is expected
finally:
monkeypatch.undo()
importlib.reload(constants)


def test_include_debug_metadata_defaults_to_false_when_unset(monkeypatch):
from unstructured.partition.utils import constants

monkeypatch.delenv("UNSTRUCTURED_INCLUDE_DEBUG_METADATA", raising=False)
try:
importlib.reload(constants)
assert constants.UNSTRUCTURED_INCLUDE_DEBUG_METADATA is False
finally:
monkeypatch.undo()
importlib.reload(constants)


def test_default_config():
from unstructured.partition.utils.config import env_config

Expand Down
8 changes: 7 additions & 1 deletion unstructured/partition/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ class PartitionStrategy:
"unstructured.partition.utils.speech_to_text.whisper_stt",
).split(",")

UNSTRUCTURED_INCLUDE_DEBUG_METADATA = os.getenv("UNSTRUCTURED_INCLUDE_DEBUG_METADATA", False)
UNSTRUCTURED_INCLUDE_DEBUG_METADATA = os.getenv(
"UNSTRUCTURED_INCLUDE_DEBUG_METADATA", ""
).lower() in (
"true",
"1",
"t",
)

# this field is defined by unstructured_pytesseract
TESSERACT_TEXT_HEIGHT = "height"
Expand Down