-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: improve handling of disallowed formats #429
Conversation
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding convert()
:
I see no need to touch the return type, we can just run next()
in a try catch and in case of StopIteration
raise a more user-friendly error instead (ideally some DoclingError we can define).
Regarding convert_all()
:
I would leave this untouched.
I also think we should not touch the return type, since the function have an explicit argument But it is still unclear to me what could/should be the return value when |
Yes and we can introduce a new |
Signed-off-by: Christoph Auer <[email protected]>
Signed-off-by: Christoph Auer <[email protected]>
Signed-off-by: Christoph Auer <[email protected]>
- Introduced new explicit exception types instead of `RuntimeError` - Introduced new `ConversionStatus` value for unsupported formats - Tidied up converter member typing & removed asserts Signed-off-by: Panos Vagenas <[email protected]>
495503f
to
0bb1e20
Compare
Signed-off-by: Panos Vagenas <[email protected]>
docling/datamodel/base_models.py
Outdated
@@ -22,6 +22,7 @@ class ConversionStatus(str, Enum): | |||
FAILURE = auto() | |||
SUCCESS = auto() | |||
PARTIAL_SUCCESS = auto() | |||
UNSUPPORTED = auto() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this UNSUPPORTED_FORMAT
to be a bit more explicit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make UNSUPPORTED into UNSUPPORTED_FORMAT to be a bit more explicit. All the rest is good!
We must agree on the naming, instead of
and add a reason that explains properly what went wrong as an |
Signed-off-by: Panos Vagenas <[email protected]>
* fix: Fixes and tests for StopIteration on .convert() Signed-off-by: Christoph Auer <[email protected]> * fix: Remove unnecessary case handling Signed-off-by: Christoph Auer <[email protected]> * fix: Other test fixes Signed-off-by: Christoph Auer <[email protected]> * improve handling of unsupported types - Introduced new explicit exception types instead of `RuntimeError` - Introduced new `ConversionStatus` value for unsupported formats - Tidied up converter member typing & removed asserts Signed-off-by: Panos Vagenas <[email protected]> * robustify & simplify format option resolution Signed-off-by: Panos Vagenas <[email protected]> * rename new status, populate ConversionResult errors Signed-off-by: Panos Vagenas <[email protected]> --------- Signed-off-by: Christoph Auer <[email protected]> Signed-off-by: Panos Vagenas <[email protected]> Co-authored-by: Panos Vagenas <[email protected]>
* fix: Fixes and tests for StopIteration on .convert() Signed-off-by: Christoph Auer <[email protected]> * fix: Remove unnecessary case handling Signed-off-by: Christoph Auer <[email protected]> * fix: Other test fixes Signed-off-by: Christoph Auer <[email protected]> * improve handling of unsupported types - Introduced new explicit exception types instead of `RuntimeError` - Introduced new `ConversionStatus` value for unsupported formats - Tidied up converter member typing & removed asserts Signed-off-by: Panos Vagenas <[email protected]> * robustify & simplify format option resolution Signed-off-by: Panos Vagenas <[email protected]> * rename new status, populate ConversionResult errors Signed-off-by: Panos Vagenas <[email protected]> --------- Signed-off-by: Christoph Auer <[email protected]> Signed-off-by: Panos Vagenas <[email protected]> Co-authored-by: Panos Vagenas <[email protected]>
* fix: Fixes and tests for StopIteration on .convert() Signed-off-by: Christoph Auer <[email protected]> * fix: Remove unnecessary case handling Signed-off-by: Christoph Auer <[email protected]> * fix: Other test fixes Signed-off-by: Christoph Auer <[email protected]> * improve handling of unsupported types - Introduced new explicit exception types instead of `RuntimeError` - Introduced new `ConversionStatus` value for unsupported formats - Tidied up converter member typing & removed asserts Signed-off-by: Panos Vagenas <[email protected]> * robustify & simplify format option resolution Signed-off-by: Panos Vagenas <[email protected]> * rename new status, populate ConversionResult errors Signed-off-by: Panos Vagenas <[email protected]> --------- Signed-off-by: Christoph Auer <[email protected]> Signed-off-by: Panos Vagenas <[email protected]> Co-authored-by: Panos Vagenas <[email protected]> Signed-off-by: Christoph Auer <[email protected]>
Checklist: