feat: add progress_callback support for real-time conversion tracking#1
Merged
Conversation
Add ConversionProgress dataclass and ProgressCallback Protocol to enable real-time progress reporting during document conversion. Converters emit progress events for each logical unit processed: - PdfConverter: per page - PptxConverter: per slide - EpubConverter: per chapter - XlsxConverter / XlsConverter: per sheet The callback is optional and passed via kwargs (progress_callback). Converters that do not support progress simply ignore it. Fully backward-compatible — no changes to existing API signatures. Signed-off-by: Eric Chavet <echavet@gmail.com>
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.
Résumé
Ajoute un mécanisme
progress_callbackà MarkItDown, permettant aux applications appelantes de recevoir des mises à jour de progression en temps réel pendant la conversion de documents.Problème résolu
Lors de la conversion de gros documents (ex: PDF de 213 pages),
convert()bloque pendant plusieurs minutes sans aucun moyen de reporter la progression à l'utilisateur. Les applications serveur, les workers, et les UIs ne peuvent pas afficher de feedback significatif.Conception
Deux nouveaux types publics dans
_base_converter.py:ConversionProgress— un@dataclassfrozen portantcurrent,total,unit(page/slide/chapter/sheet), etsource(nom de la classe converter).ProgressCallback— unProtocol@runtime_checkableque tout callable(ConversionProgress) -> Nonesatisfait (duck typing).Le callback est propagé via la chaîne
**kwargsexistante (convert()→_convert()→converter.convert()). Les convertisseurs qui ne supportent pas la progression ignorent simplement le kwarg.Convertisseurs mis à jour
PdfConverterpagePptxConverterslideEpubConverterchapterXlsxConvertersheetXlsConvertersheetCompatibilité
Lien upstream
PR soumise à Microsoft : microsoft/markitdown#1851