-
Notifications
You must be signed in to change notification settings - Fork 17
chore: Python v2 migration #135
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
Merged
Merged
Conversation
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
0f96076
to
7f75744
Compare
This was referenced Jul 31, 2024
awalker4
added a commit
that referenced
this pull request
Aug 5, 2024
PDF page splitting uses asyncio but the SDK is not async. Therefore, we had to manage our own event loop, which can lead to issues in other event loop contexts. Uvloop is one context that does not allow us to use nested event loops. When we find ourselves in a uvloop.Loop, we have to fallback to non splitting mode. #135 will make the whole SDK async so we don't have to hack this. Closes #133
c4602c4
to
37f3628
Compare
37f3628
to
ea55097
Compare
* Update legacy partition calls that don't use PartitionRequest * Update error response mock to use httpx
* Change legacy calls without PartitionRequest
* Update calls that don't use PartitionRequest * Instances of shared.Files need to use keyword args * Update request mocks to use httpx
4d8271a
to
d7836d2
Compare
d7836d2
to
9e9fa0a
Compare
We need to allow positional args for consistency.
awalker4
approved these changes
Aug 18, 2024
awalker4
added a commit
that referenced
this pull request
Aug 21, 2024
Fix all mypy errors due to incorrect typing after the SDK v2 merge (#135). Logic changes should be minimal, this is mostly to change type hints where a `httpx.Response` is used instead of a `requests.Response`, etc. I removed some `form_utils.py` functions where we no longer need to convert a httpx request back to Requests. There's more we can cleanup in here, but let's get the V2 migration settled first. Add mypy to `make lint` so that we can cath these errors before merging. The publish job runs a full linter suite, and these changes made it to main but broke the publish job. Also, remove the Patch Custom Code step that I added to the generate. This broke the job. There are some minor changes to the Speakeasy code on the main branch. In the short term, this means we'll have to run `make patch-custom-code` whenever we regenerate. # To verify Make sure you can lint and run the tests locally. `make lint` and `make test`. You can also verify that the pdf split behavior has not changed with a call to your local server: ``` from unstructured_client import UnstructuredClient from unstructured_client.models import shared, operations import json filename = "_sample_docs/layout-parser-paper.pdf" s = UnstructuredClient( server_url="http://localhost:8000", ) with open(filename, "rb") as f: files=shared.Files( content=f, file_name=filename, ) req = operations.PartitionRequest( shared.PartitionParameters( files=files, strategy="fast", split_pdf_page_range=[4,8], ), ) resp = s.general.partition(req) print(json.dumps(resp.elements, indent=4)) ```
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.
After merging these changes there are steps if you're using custom hooks.
Please see:
https://www.speakeasy.com/docs/python-migration#4-adjust-imports-for-python-v2