Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions .github/workflows/speakeasy_sdk_generation.yml

This file was deleted.

1,581 changes: 0 additions & 1,581 deletions .speakeasy/gen.lock

This file was deleted.

4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing to This Repository

Thank you for your interest in contributing to this repository. Please note that this repository contains generated code. As such, we do not accept direct changes or pull requests. Instead, we encourage you to follow the guidelines below to report issues and suggest improvements.
Thank you for your interest in contributing to this repository. We do not currently accept direct changes or pull requests. Instead, we encourage you to follow the guidelines below to report issues and suggest improvements.

## How to Report Issues

Expand All @@ -15,7 +15,7 @@ If you encounter any bugs or have suggestions for improvements, please open an i

## Issue Triage and Upstream Fixes

We will review and triage issues as quickly as possible. Our goal is to address bugs and incorporate improvements in the upstream source code. Fixes will be included in the next generation of the generated code.
We will review and triage issues as quickly as possible. Our goal is to address bugs and incorporate improvements in the next release.

## Contact

Expand Down
47 changes: 1 addition & 46 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ install:
python scripts/prepare_readme.py
uv sync --locked

## 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 @@ -73,46 +68,6 @@ lint:
uv run pylint --rcfile=pylintrc src
uv run mypy src

#############
# Speakeasy #
#############

## download-openapi-specs: Download the openapi specs from the Serverless and Platform APIs
.PHONY: download-openapi-specs
download-openapi-specs:
wget -nv -q -O openapi_serverless.json https://api.unstructuredapp.io/general/openapi.json
wget -nv -q -O openapi_platform_api.json https://platform.unstructuredapp.io/openapi.json

## client-merge-serverless-platform: Merge the Serverless and Platform APIs specs into a single schema
.PHONY: client-merge-serverless-platform
client-merge-serverless-platform:
speakeasy merge -s ./openapi_platform_api.json -s ./openapi_serverless.json -o ./openapi_merged.yaml

## client-apply-overlay: Apply overlay on the merged schema
.PHONY: client-apply-overlay
client-apply-overlay:
speakeasy overlay validate -o ./overlay_client.yaml
speakeasy overlay apply -s ./openapi_merged.yaml -o ./overlay_client.yaml > ./openapi_platform_serverless_client.yaml

## client-generate-unified-sdk-local: Generate the SDK from the merged schema
.PHONY: client-generate-unified-sdk-local
client-generate-unified-sdk-local:
speakeasy generate sdk -s ./openapi_platform_serverless_client.yaml -o ./ -l python

## client-generate-sdk: Do all the steps to generate the SDK
.PHONY: client-generate-sdk
client-generate-sdk: download-openapi-specs client-merge-serverless-platform client-apply-overlay client-generate-unified-sdk-local


.PHONY: publish
publish:
./scripts/publish.sh

###########
# Jupyter #
###########

## run-jupyter: starts jupyter notebook
.PHONY: run-jupyter
run-jupyter:
PYTHONPATH=$(realpath .) JUPYTER_PATH=$(realpath .) jupyter-notebook --NotebookApp.token='' --NotebookApp.password=''
./scripts/publish.sh
52 changes: 1 addition & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@ This is a HTTP client for the [Unstructured Platform API](https://docs.unstructu

Please refer to the our documentation for a full guide on integrating the [Workflow Endpoint](https://docs.unstructured.io/platform-api/api/overview) and [Partition Endpoint](https://docs.unstructured.io/platform-api/partition-api/sdk-python) into your Python code.

<!-- Start Summary [summary] -->
## Summary


<!-- End Summary [summary] -->

<!-- Start Table of Contents [toc] -->
## Table of Contents
<!-- $toc-max-depth=2 -->
* [SDK Installation](#sdk-installation)
* [Retries](#retries)
* [Error Handling](#error-handling)
Expand All @@ -41,9 +35,6 @@ Please refer to the our documentation for a full guide on integrating the [Workf
* [Resource Management](#resource-management)
* [Debugging](#debugging)

<!-- End Table of Contents [toc] -->

<!-- Start SDK Installation [installation] -->
## SDK Installation

> [!NOTE]
Expand Down Expand Up @@ -107,10 +98,7 @@ sdk = UnstructuredClient(

Once that is saved to a file, you can run it with `uv run script.py` where
`script.py` can be replaced with the actual file name.
<!-- End SDK Installation [installation] -->


<!-- Start Retries [retries] -->
## Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
Expand Down Expand Up @@ -155,10 +143,7 @@ with UnstructuredClient(
print(res.dag_node_connection_check)

```
<!-- End Retries [retries] -->


<!-- Start Error Handling [errors] -->
## Error Handling

[`UnstructuredClientError`](./src/unstructured_client/models/errors/unstructuredclienterror.py) is the base class for all HTTP error responses. It has the following properties:
Expand Down Expand Up @@ -219,17 +204,14 @@ with UnstructuredClient() as uc_client:
* [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
* [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.


**Inherit from [`UnstructuredClientError`](./src/unstructured_client/models/errors/unstructuredclienterror.py)**:
* [`ServerError`](./src/unstructured_client/models/errors/servererror.py): Server Error. Status code `5XX`. Applicable to 1 of 30 methods.*
* [`ResponseValidationError`](./src/unstructured_client/models/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.

</details>

\* Check [the method documentation](#available-resources-and-operations) to see if the error is applicable.
<!-- End Error Handling [errors] -->

<!-- Start Custom HTTP Client [http-client] -->
## Custom HTTP Client

The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
Expand Down Expand Up @@ -308,20 +290,15 @@ class CustomClient(AsyncHttpClient):

s = UnstructuredClient(async_client=CustomClient(httpx.AsyncClient()))
```
<!-- End Custom HTTP Client [http-client] -->

<!-- Start IDE Support [idesupport] -->
## IDE Support

### PyCharm

Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.

- [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
<!-- End IDE Support [idesupport] -->


<!-- Start SDK Example Usage [usage] -->
## SDK Example Usage

### Example
Expand Down Expand Up @@ -366,11 +343,9 @@ async def main():

asyncio.run(main())
```
<!-- End SDK Example Usage [usage] -->

Refer to the [API parameters page](https://docs.unstructured.io/api-reference/api-services/api-parameters) for all available parameters.


## Configuration

### Splitting PDF by pages
Expand Down Expand Up @@ -458,7 +433,6 @@ finally:
Path(res.elements_file).unlink(missing_ok=True)
```

<!-- Start File uploads [file-upload] -->
## File uploads

Certain SDK methods accept file objects as part of a request body or multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
Expand Down Expand Up @@ -486,9 +460,7 @@ with UnstructuredClient() as uc_client:
print(res.job_information)

```
<!-- End File uploads [file-upload] -->

<!-- Start Resource Management [resource-management] -->
## Resource Management

The `UnstructuredClient` class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a [context manager][context-manager] and reuse it across the application.
Expand All @@ -509,9 +481,7 @@ async def amain():
async with UnstructuredClient() as uc_client:
# Rest of application here...
```
<!-- End Resource Management [resource-management] -->

<!-- Start Debugging [debug] -->
## Debugging

You can setup your SDK to emit debug logs for SDK requests and responses.
Expand All @@ -524,14 +494,6 @@ import logging
logging.basicConfig(level=logging.DEBUG)
s = UnstructuredClient(debug_logger=logging.getLogger("unstructured_client"))
```
<!-- End Debugging [debug] -->

<!-- No SDK Available Operations -->
<!-- No Pagination -->
<!-- No Server Selection -->
<!-- No Authentication -->

<!-- Placeholder for Future Speakeasy SDK Sections -->

### Maturity

Expand All @@ -558,18 +520,6 @@ The following instructions are intended to help you get up and running with `uns

### Contributions

While we value open-source contributions to this SDK, this library is generated programmatically by Speakeasy. In order to start working with this repo, you need to:
1. Install Speakeasy client locally https://github.com/speakeasy-api/speakeasy#installation
2. Run `speakeasy auth login`
3. Run `make client-generate`. This allows to iterate development with python client.

There are two important files used by `make client-generate`:
1. `openapi.json` which is actually not stored here, [but fetched from unstructured-api](https://api.unstructured.io/general/openapi.json), represents the API that is supported on backend.
2. `overlay_client.yaml` is a handcrafted diff that when applied over above, produces `openapi_client.json` which is used to generate SDK.

Once PR with changes is merged, Github CI will autogenerate the Speakeasy client in a new PR, using
the `openapi.json` and `overlay_client.yaml` You will have to manually bring back the human created lines in it.
While we value open-source contributions to this SDK, this library is not accepting direct changes at this time.

Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!

### SDK Created by [Speakeasy](https://www.speakeasyapi.dev/docs/sdk-design/python/methodology-python)
Loading