Skip to content

Commit

Permalink
Merge branch 'main' into yuming/RUDOLPH-288_python_sdk_readme_add_ser…
Browse files Browse the repository at this point in the history
…verless_api_signup
  • Loading branch information
yuming-long authored Sep 23, 2024
2 parents 4cccf22 + f345613 commit d73a160
Show file tree
Hide file tree
Showing 14 changed files with 108 additions and 1,955 deletions.
16 changes: 8 additions & 8 deletions .speakeasy/gen.lock
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
lockVersion: 2.0.0
id: 8b5fa338-9106-4734-abf0-e30d67044a90
management:
docChecksum: ad32e3faae264ab1eb7cf461e373dcfa
docChecksum: 50c3c5e39eb24b50e53fbe08f8156e76
docVersion: 1.0.48
speakeasyVersion: 1.396.6
generationVersion: 2.415.6
releaseVersion: 0.26.0-beta.1
configChecksum: 1af6154f17e397a8f89b4f6fd727be8d
speakeasyVersion: 1.401.2
generationVersion: 2.421.3
releaseVersion: 0.26.0-beta.2
configChecksum: 1c64b3f4febc852a778315853edd62ff
repoURL: https://github.com/Unstructured-IO/unstructured-python-client.git
repoSubDirectory: .
installationURL: https://github.com/Unstructured-IO/unstructured-python-client.git
published: true
features:
python:
additionalDependencies: 1.0.0
constsAndDefaults: 1.0.2
core: 5.5.3
constsAndDefaults: 1.0.3
core: 5.5.4
defaultEnabledRetries: 0.2.0
enumUnions: 0.1.0
envVarSecurityUsage: 0.3.1
Expand Down Expand Up @@ -105,6 +105,6 @@ examples:
"200":
application/json: [{"type": "Title", "element_id": "6aa0ff22f91bbe7e26e8e25ca8052acd", "text": "LayoutParser: A Unified Toolkit for Deep Learning Based Document Image Analysis", "metadata": {"languages": ["eng"], "page_number": 1, "filename": "layout-parser-paper.pdf", "filetype": "application/pdf"}}]
"422":
application/json: {"detail": "<value>"}
application/json: {"detail": []}
5XX:
application/json: {"detail": "An error occurred"}
11 changes: 5 additions & 6 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
speakeasyVersion: 1.361.1
speakeasyVersion: 1.401.2
sources:
my-source:
sourceNamespace: my-source
sourceRevisionDigest: sha256:403efaa5f402ccbd48b83c579e1d8c14197267223ba67e17ddf9f8b824c78a8e
sourceBlobDigest: sha256:f89c6ba5c02602f9cf8c75d96a69a7fef23f7057cd82e78236557ba51f504e98
sourceRevisionDigest: sha256:8e6306f9d3aef76cdd2d517057e363229b0c83337f56f7ef6ee5e497067ed02e
sourceBlobDigest: sha256:e56a9e82f06b4aecdc8653a8b04256104f5ef4c8000dd8fd30fb2cb66a857567
tags:
- latest
- main
targets:
unstructured-python:
source: my-source
sourceNamespace: my-source
sourceRevisionDigest: sha256:403efaa5f402ccbd48b83c579e1d8c14197267223ba67e17ddf9f8b824c78a8e
sourceBlobDigest: sha256:f89c6ba5c02602f9cf8c75d96a69a7fef23f7057cd82e78236557ba51f504e98
outLocation: /github/workspace/repo
sourceRevisionDigest: sha256:8e6306f9d3aef76cdd2d517057e363229b0c83337f56f7ef6ee5e497067ed02e
sourceBlobDigest: sha256:e56a9e82f06b4aecdc8653a8b04256104f5ef4c8000dd8fd30fb2cb66a857567
workflow:
workflowVersion: 1.0.0
speakeasyVersion: latest
Expand Down
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ install:
python scripts/prepare-readme.py
poetry install

## install-speakeasy-cli: download the speakeasy cli tool
.PHONY: install-speakeasy-cli
install-speakeasy-cli:
curl -fsSL https://raw.githubusercontent.com/speakeasy-api/speakeasy/main/install.sh | sh

#################
# Test and Lint #
#################
Expand Down Expand Up @@ -48,24 +53,21 @@ lint:
# Speakeasy #
#############

## client-generate: Pull the openapi spec from the free hosted API and generate the SDK
.PHONY: client-generate
client-generate:
wget -nv -q -O openapi.json https://api.unstructured.io/general/openapi.json
speakeasy overlay validate -o ./overlay_client.yaml
speakeasy overlay apply -s ./openapi.json -o ./overlay_client.yaml > ./openapi_client.json
speakeasy generate sdk -s ./openapi_client.json -o ./ -l python

## client-generate-local: Generate the SDK using a local copy of openapi.json
.PHONY: client-generate-local
client-generate-local:
wget -nv -q -O openapi.json http://localhost:5000/general/openapi.json
speakeasy overlay validate -o ./overlay_client.yaml
speakeasy overlay apply -s ./openapi.json -o ./overlay_client.yaml > ./openapi_client.json
speakeasy generate sdk -s ./openapi_client.json -o ./ -l python

.PHONY: patch-custom-code
patch-custom-code:
git apply _custom_code.patch

.PHONY: publish
publish:
./scripts/publish.sh
Expand Down
12 changes: 11 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -654,4 +654,14 @@ Based on:
### Generated
- [python v0.26.0-beta.1] .
### Releases
- [PyPI v0.26.0-beta.1] https://pypi.org/project/unstructured-client/0.26.0-beta.1 - .
- [PyPI v0.26.0-beta.1] https://pypi.org/project/unstructured-client/0.26.0-beta.1 - .

## 2024-09-21 00:08:49
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.401.2 (2.421.3) https://github.com/speakeasy-api/speakeasy
### Generated
- [python v0.26.0-beta.2] .
### Releases
- [PyPI v0.26.0-beta.2] https://pypi.org/project/unstructured-client/0.26.0-beta.2 - .
29 changes: 0 additions & 29 deletions _custom_code.patch

This file was deleted.

2 changes: 1 addition & 1 deletion _test_unstructured_client/integration/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ async def mock_send(_, request: httpx.Request, **kwargs):
)

req = operations.PartitionRequest(
shared.PartitionParameters(
partition_parameters=shared.PartitionParameters(
files=files,
split_pdf_page=True,
split_pdf_allow_failed=False,
Expand Down
4 changes: 2 additions & 2 deletions _test_unstructured_client/unit/test_custom_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ def mock_post(request):
files = shared.Files(content=f.read(), file_name=filename)

req = operations.PartitionRequest(
shared.PartitionParameters(files=files)
partition_parameters=shared.PartitionParameters(files=files)
)

with pytest.raises(Exception, match=f"Status {status_code}"):
session.general.partition(req, retries=retries)
session.general.partition(request=req, retries=retries)

if expect_retry:
assert number_of_requests[0] > 1
Expand Down
32 changes: 4 additions & 28 deletions codeSamples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,7 @@ info:
actions:
- target: $["paths"]["/general/v0/general"]["post"]
update:
x-codeSamples:
- lang: python
label: partition
source: |-
import unstructured_client
from unstructured_client.models import operations, shared
s = unstructured_client.UnstructuredClient()
res = s.general.partition(request=operations.PartitionRequest(
partition_parameters=shared.PartitionParameters(
files=shared.Files(
file_name='your_file_here',
content='0x2cC94b2FEF'.encode(),
),
strategy=shared.Strategy.AUTO,
chunking_strategy=shared.ChunkingStrategy.BASIC,
split_pdf_page_range=[
1,
10,
],
),
))
if res.elements is not None:
# handle response
pass
"x-codeSamples":
- "lang": "python"
"label": "partition"
"source": "from unstructured_client import UnstructuredClient\nfrom unstructured_client.models import shared\n\ns = UnstructuredClient()\n\nres = s.general.partition(request={\n \"partition_parameters\": {\n \"files\": {\n \"file_name\": \"example.file\",\n \"content\": open(\"example.file\", \"rb\"),\n },\n \"strategy\": shared.Strategy.AUTO,\n \"chunking_strategy\": shared.ChunkingStrategy.BASIC,\n \"split_pdf_page_range\": [\n 1,\n 10,\n ],\n },\n})\n\nif res.elements is not None:\n # handle response\n pass"
2 changes: 1 addition & 1 deletion gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ generation:
auth:
oAuth2ClientCredentialsEnabled: false
python:
version: 0.26.0-beta.1
version: 0.26.0-beta.2
additionalDependencies:
dev:
deepdiff: '>=6.0'
Expand Down
Loading

0 comments on commit d73a160

Please sign in to comment.