Repository navigation
fix: fix multiple values for infer_table_structure - #3870
Merged
Merged
Conversation
🔍 Existing Issues For ReviewYour pull request is modifying functions with the following pre-existing issues: 📄 File: unstructured/partition/auto.py
Did you find this useful? React with a 👍 or 👎 |
badGarnet
requested review from
christinestraub,
plucinskik and
scanny
and removed request for
christinestraub,
plucinskik and
scanny
January 17, 2025 02:42
plucinskik
reviewed
Jan 17, 2025
| # into a partition function, e.g., partition_email is reused to partition sub-elements, e.g., | ||
| # partition an image attachment buy calling partition with the kwargs. In that case here kwargs | ||
| # would have a infer_table_structure already | ||
| infer_table_structure = kwargs.pop( |
Contributor
There was a problem hiding this comment.
Looking at the failing test I think we introduced a regression, and I believe this is because the below behaviour
>>> x={'a': None, 'b': 2}
>>> x
{'a': None, 'b': 2}
>>> a=x.pop('a', 5)
>>> b=x.pop('b', 5)
>>> a
>>> b
2general_partition methods configure all parameters regardless of whether they are passed or not, so I assume it passed some Nones.
I modified that and added test
Contributor
There was a problem hiding this comment.
It didn't change the ingest test, although maybe it is safer this way
Collaborator
Author
There was a problem hiding this comment.
thanks for the catch
…tures update (#3874) This pull request includes updated ingest test fixtures. Please review and merge if appropriate. Co-authored-by: christinestraub <[email protected]>
temp-adelyn
pushed a commit
to temp-adelyn/unstructured
that referenced
this pull request
Mar 3, 2025
) This PR fixes a bug when using `partition` to partition an email with image attachments with hi_res and allow table structure inference -> the partitioning of the image would encounter a value error: `got multiple values for keyword argument 'infer_table_structure'`. This is because pass `kwargs` into partition "other" types of files in this [block](https://github.com/Unstructured-IO/unstructured/blob/aa5f4015bf15cf5b79ac3e210b098148b75d9a5f/unstructured/partition/auto.py#L270-L280) `infer_table_structure` is packaged into `partitioning_kwargs`. Then for email at least when there are attachments that can be partitioned with `hi_res` we pass that dict of `kwargs` right back into `partition` entry -> so when we get [here](https://github.com/Unstructured-IO/unstructured/blob/aa5f4015bf15cf5b79ac3e210b098148b75d9a5f/unstructured/partition/auto.py#L222-L235) we are both specifying explicitly `infer_table_structure` and have it in `kwargs` variable The fix is to detect first if `kwargs` already contains `infer_table_structure` and if yes use that and pop it from `kwargs`. --------- Co-authored-by: Kamil Plucinski <[email protected]> Co-authored-by: christinestraub <[email protected]> Co-authored-by: ryannikolaidis <[email protected]> Co-authored-by: christinestraub <[email protected]>
cragwolfe
pushed a commit
that referenced
this pull request
Oct 23, 2026
) **Summary** `partition_tsv()` silently ignores `infer_table_structure=False`, so callers still receive `Table.metadata.text_as_html`. The flag is passed through by `partition()` but absorbed by `**kwargs` in the TSV partitioner. The fix adds the explicit parameter with the same default (`True`) as the other table partitioners, and sets HTML metadata only when enabled. Tests cover both flag values through `partition_tsv()` and `partition()`. Disabling HTML sends the whole flattened table through the shared text splitter, which exposed latent progress and work-bound defects in that path. The branch therefore also carries the bounded-split fixes already discussed on this PR: a prefix wholly covered by overlap advances, the token window and fallback scans are bounded, the vocabulary bound is shared across HTML cells, the unread suffix is not re-encoded on every split, and a fitting input is not rejected because an earlier prefix overflowed. **This revision (`f256ed23`)** Both findings from the latest review: - **Preferred-separator search:** candidates inside one whitespace run all trim to the same fragment and lstrip to the same remainder. The run is now evaluated once and the remaining matches inside it are skipped, so `"a" + " " * 100_000 + "print(1)"` measures one candidate instead of 100,000. Covered for spaces, newlines, mixed whitespace and a configured tab separator. - **Fallback overlap:** `split_pos > len(fragment)` records that the cut trimmed a trailing whitespace run. That is now combined with `is_whitespace_split`, so the overlap tail gets a separating space when either side of the cut had whitespace. The corrupted `"aprint(1)"` expectation is replaced by `"a print(1)"`; an unbroken-word test still forbids an artificial space when the cut had no whitespace. **Test** - `pytest test_unstructured/chunking test_unstructured/partition/test_tsv.py -q` → `719 passed, 2 skipped in 12.76s` - `ruff check` and `ruff format --check` on the two changed files → clean - `git diff --check` → clean Not run: the full partitioner/extras suites and cross-platform tests. CI is now running on this head; no green check is claimed yet. **Type of change:** bug fix; no new dependency. Related #4373 changes numeric HTML generation, and #3870 fixed a duplicate auto-dispatch kwarg; neither addresses this ignored TSV flag.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR fixes a bug when using
partitionto partition an email with image attachments with hi_res and allow table structure inference -> the partitioning of the image would encounter a value error:got multiple values for keyword argument 'infer_table_structure'.This is because pass
kwargsinto partition "other" types of files in this blockinfer_table_structureis packaged intopartitioning_kwargs. Then for email at least when there are attachments that can be partitioned withhi_reswe pass that dict ofkwargsright back intopartitionentry -> so when we get here we are both specifying explicitlyinfer_table_structureand have it inkwargsvariableThe fix is to detect first if
kwargsalready containsinfer_table_structureand if yes use that and pop it fromkwargs.