bug: partition_email() raises io.UnsupportedOperation on a file-like object that cannot seek
メンテナーはふだん 6 日以内に返信
評価
調査の方向性
unstructured/partition/email.py、特にEmailPartitioningContext._validate()とmsgプロパティを読み、#4643と#4649で説明されているように、partition_json()とpartition_ndjson()がシークできないストリームをどのように扱うかを比較してください。読み取り可能なパイプ、またはシークできない別のファイル風オブジェクトで再現し、その出力を同じメールバイト列を含むio.BytesIOの出力と比較してください。両方の入力でpartition_email(file=...)が同じ要素を返せば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
partition_email(file=...) raises io.UnsupportedOperation: File or stream is not seekable. when the file-like object is readable but cannot seek back, such as the read end of a pipe. An unbuffered handle (open(fd, "rb", buffering=0)) fails the same way with OSError: [Errno 29] Illegal seek.
EmailPartitioningContext._validate() rewinds file unconditionally with self._file.seek(0) (unstructured/partition/email.py), before the message is parsed. The partitioner reads the message once after that (self._file.read() in the msg property), so the rewind is the only thing such a stream cannot provide.
The sibling partitioners accept the same kind of stream when called directly: partition_text(), partition_html() and partition_xml() read it as it stands, partition_json() / partition_ndjson() skip the rewind for a stream that reports seekable() as False (#4643, fixed by #4649), and partition_tsv() copies it once to a temporary file.
To Reproduce
import io
import os
from unstructured.partition.email import partition_email
with open("example-docs/eml/fake-email.eml", "rb") as f:
eml_bytes = f.read()
reader_fd, writer_fd = os.pipe()
with os.fdopen(writer_fd, "wb") as writer:
writer.write(eml_bytes)
with os.fdopen(reader_fd, "rb") as reader:
print(partition_email(file=reader))
# io.UnsupportedOperation: File or stream is not seekable.
print(partition_email(file=io.BytesIO(eml_bytes))) # the same bytes, seekable: works
Expected behavior
partition_email(file=...) partitions a stream that cannot seek the way the sibling partitioners do, returning the same elements as the same bytes read from a seekable object.
Environment Info
- unstructured 0.27.38 (
mainat 2653935) - Python 3.12, macOS arm64
Additional context
This report is about calling partition_email(file=...) directly. #4677 describes the same error on the generic partition(file=...) entry point, where it comes from file-type detection; #4678 addresses that path.
- 主要言語
- HTML
- スター
- 15.8k
- フォーク
- 1.4k
- 平均マージ
- 8日 4時間
- マージ済み PR(30日)
- 40
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Unstructured-IO/unstructured のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Unstructured-IO/unstructured#4876 ·
メンテナーはふだん 6 日以内に返信
-
fix(nlp): match single-letter bullets in the enumerated bullet pattern対応中かも @Eapp1e が 33 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Unstructured-IO/unstructured#4635 ·
メンテナーはふだん 6 日以内に返信
-
bug(cleaners): translate_text passes text instead of chunk in attention window loop対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
Unstructured-IO/unstructured#4558 · コメント 1 件 ·
メンテナーはふだん 6 日以内に返信
-
extract_text_before/extract_text_after raise UnboundLocalError when the pattern is absent対応中かも @ayam04 が 103 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Unstructured-IO/unstructured#4427 · コメント 3 件 ·
メンテナーはふだん 6 日以内に返信
-
Large HTML documents cannot be partitioned using the partition_html function.対応中かも @CrepuscularIRIS が 229 日前に担当しました。 オープンbug
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
Unstructured-IO/unstructured#4289 · コメント 1 件 ·
メンテナーはふだん 6 日以内に返信
Unstructured-IO/unstructured の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
TigreGotico/orthography2ipa#2950 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
🐛 bug 👩💻 équipe CE
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
betagouv/conseillers-entreprises#4835 ·
メンテナーはふだん 1 日以内に返信
-
area: integrations documentation priority: P2 size: XS
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
eddiejaoude/StackDash#798 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ThinkR-open/mordew#88 ·