Skip to content

fix languages 500 error with empty string for ocr_languages#1968

Merged
awalker4 merged 9 commits into
mainfrom
jj/1870-languages-500-error
Nov 1, 2023
Merged

fix languages 500 error with empty string for ocr_languages#1968
awalker4 merged 9 commits into
mainfrom
jj/1870-languages-500-error

Conversation

@Coniferish
Copy link
Copy Markdown
Contributor

@Coniferish Coniferish commented Nov 1, 2023

Closes #1870
Defining both languages and ocr_languages raises a ValueError, but the api defaults to ocr_languages being an empty string, so if users define languages they are automatically hitting the ValueError.

This fix checks if ocr_languages is an empty string and converts it to None to avoid this.

Testing

On the main branch, the following will raise the ValueError, but it will correctly partition on this branch

from unstructured.partition.auto import partition
filename = "example-docs/category-level.docx"
elements = partition(filename,languages=['spa'],ocr_languages="")

elements[0].metadata.languages

@Coniferish Coniferish requested a review from awalker4 November 1, 2023 15:53
@Coniferish Coniferish temporarily deployed to ci November 1, 2023 15:56 — with GitHub Actions Inactive
@awalker4 awalker4 requested a review from shreyanid November 1, 2023 16:01
@Coniferish Coniferish temporarily deployed to ci November 1, 2023 16:08 — with GitHub Actions Inactive
@Coniferish Coniferish temporarily deployed to ci November 1, 2023 16:08 — with GitHub Actions Inactive
@Coniferish Coniferish temporarily deployed to ci November 1, 2023 16:08 — with GitHub Actions Inactive
@Coniferish Coniferish temporarily deployed to ci November 1, 2023 16:08 — with GitHub Actions Inactive
Copy link
Copy Markdown
Contributor

@awalker4 awalker4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Coniferish Coniferish temporarily deployed to ci November 1, 2023 18:10 — with GitHub Actions Inactive
@Coniferish Coniferish temporarily deployed to ci November 1, 2023 18:16 — with GitHub Actions Inactive
@Coniferish Coniferish temporarily deployed to ci November 1, 2023 18:16 — with GitHub Actions Inactive
@Coniferish Coniferish temporarily deployed to ci November 1, 2023 18:16 — with GitHub Actions Inactive
@Coniferish Coniferish temporarily deployed to ci November 1, 2023 18:16 — with GitHub Actions Inactive
@shreyanid shreyanid added this pull request to the merge queue Nov 1, 2023
@shreyanid
Copy link
Copy Markdown
Contributor

Seeing the version conflict with the previous PR in the merge queue. Confused on how to resolve it: setting it to dev5 like the previous wouldn't correctly increment the version for this change, but setting it to dev6 would still have a conflict. Perhaps that's why this was waiting to merge.

@shreyanid shreyanid removed this pull request from the merge queue due to a manual request Nov 1, 2023
@yuming-long yuming-long temporarily deployed to ci November 1, 2023 19:23 — with GitHub Actions Inactive
@yuming-long yuming-long enabled auto-merge November 1, 2023 19:24
@yuming-long yuming-long temporarily deployed to ci November 1, 2023 19:25 — with GitHub Actions Inactive
@yuming-long yuming-long temporarily deployed to ci November 1, 2023 19:25 — with GitHub Actions Inactive
@yuming-long yuming-long temporarily deployed to ci November 1, 2023 19:25 — with GitHub Actions Inactive
@yuming-long yuming-long temporarily deployed to ci November 1, 2023 19:25 — with GitHub Actions Inactive
@yuming-long yuming-long temporarily deployed to ci November 1, 2023 20:27 — with GitHub Actions Inactive
@yuming-long yuming-long temporarily deployed to ci November 1, 2023 20:28 — with GitHub Actions Inactive
@yuming-long yuming-long temporarily deployed to ci November 1, 2023 20:28 — with GitHub Actions Inactive
@yuming-long yuming-long temporarily deployed to ci November 1, 2023 20:28 — with GitHub Actions Inactive
@yuming-long yuming-long temporarily deployed to ci November 1, 2023 20:29 — with GitHub Actions Inactive
@yuming-long yuming-long temporarily deployed to ci November 1, 2023 20:29 — with GitHub Actions Inactive
@yuming-long yuming-long temporarily deployed to ci November 1, 2023 20:29 — with GitHub Actions Inactive
@yuming-long yuming-long temporarily deployed to ci November 1, 2023 20:29 — with GitHub Actions Inactive
@yuming-long yuming-long temporarily deployed to ci November 1, 2023 20:29 — with GitHub Actions Inactive
@yuming-long yuming-long added this pull request to the merge queue Nov 1, 2023
@yuming-long yuming-long removed this pull request from the merge queue due to a manual request Nov 1, 2023
@awalker4 awalker4 temporarily deployed to ci November 1, 2023 21:26 — with GitHub Actions Inactive
@awalker4 awalker4 enabled auto-merge November 1, 2023 21:26
@awalker4 awalker4 temporarily deployed to ci November 1, 2023 21:28 — with GitHub Actions Inactive
@awalker4 awalker4 temporarily deployed to ci November 1, 2023 21:28 — with GitHub Actions Inactive
@awalker4 awalker4 temporarily deployed to ci November 1, 2023 21:28 — with GitHub Actions Inactive
@awalker4 awalker4 temporarily deployed to ci November 1, 2023 21:28 — with GitHub Actions Inactive
@awalker4 awalker4 temporarily deployed to ci November 1, 2023 21:28 — with GitHub Actions Inactive
@awalker4 awalker4 temporarily deployed to ci November 1, 2023 21:28 — with GitHub Actions Inactive
@awalker4 awalker4 temporarily deployed to ci November 1, 2023 21:28 — with GitHub Actions Inactive
@awalker4 awalker4 temporarily deployed to ci November 1, 2023 21:28 — with GitHub Actions Inactive
@awalker4 awalker4 added this pull request to the merge queue Nov 1, 2023
Merged via the queue into main with commit b92cab7 Nov 1, 2023
@awalker4 awalker4 deleted the jj/1870-languages-500-error branch November 1, 2023 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug/Only one of languages and ocr_languages should be specified

4 participants