Skip to main content

Unstructured Platform Plugins

CI

Deprecation notice: wrap_in_fastapi (and the etl-uvicorn CLI it backs) is deprecated. New plugins should build a FastAPI app directly with explicit handlers for the plugin contract routes (/invoke, /schema, /id, etc.).

Information about how to build custom plugins to integrate with Unstructured Platform.

Plugin Development

Any plugin must be published in a dedicated docker image with all required dependencies that when run, exposes an api on port 8000 with the required endpoints to interact with the Unstructured Platform product:

  • /invoke: A POST endpoint which gets all data to run the underlying logic in the request body and expects a json serializable response.
  • /schema: A GET endpoint which publishes a json schema formatted response with the schema of the input and output expected by the plugin.
  • /id: A GET endpoint which publishes a string unique identifier for this instance of the plugin. Will default to a hash of the schema response if one is not set explicitly.

Utility CLI

When installing this repo, it also installs the cli etl-uvicorn. This takes a pointer to any generic python function and wraps it in a FastApi application to conform to the patterns that are expected by the api hosting the plugin logic. This cli extends the existing uvicorn cli which takes in a pointer to a fastapi instance or factory but instead takes in a pointer to a python function/class which gets wrapped with a FastApi application.

Example usage

For all following commands, make sure you have the local repo in your PYTHONPATH:

export PYTHONPATH=.

Wrapping a basic function with a typed dict response

etl-uvicorn test.assets.typed_dict_response:sample_function

Wrapping a basic async function with a typed dict response

etl-uvicorn test.assets.async_typed_dict_response:async_sample_function

Wrapping a class. For this to work, the class must be self instantiating. When passing a class in, a method needs to be passed in as well, otherwise __call__ is used. The following example returns a pydantic BaseModel

etl-uvicorn test.assets.pydantic_response_class_method:SampleClass --method-name sample_method

Wrapping an instance of a class.

etl-uvicorn test.assets.pydantic_response_class_method:sample_class --method-name sample_method

The CLI does some validation on the wrapped function, which must have explicit inputs and outputs, meaning *args and **kwargs are not supported. These will cause the cli to fail fast.

etl-uvicorn test.assets.improper_function:sample_improper_function

/id requirements

All the the above examples caused the CLI to autogenerate the /id endpoint with a hash of the generated schema. However, you can also provide it a reference to use for the id value. This can be a reference to a concrete value (i.e. plugin_id="my_plugin_id") or a function in the same way that one was passed in to be wrapped above.

Will populate the response of /id with the static value of hash_value:

etl-uvicorn test.assets.typed_dict_response:sample_function --plugin-id test.assets.simple_hash_value:hash_value

Can populate it using a lambda:

etl-uvicorn test.assets.typed_dict_response:sample_function --plugin-id test.assets.simple_hash_lambda:hash_lambda_fn

Similar to the function being wrapped, can also use a class:

etl-uvicorn test.assets.typed_dict_response:sample_function --plugin-id test.assets.simple_hash_class:GetHash --plugin-id-method my_hash

Or the instantiated class:

etl-uvicorn test.assets.typed_dict_response:sample_function --plugin-id test.assets.simple_hash_class:get_hash_class_instance --plugin-id-method my_hash

Metadata

Release files for unstructured-platform-plugins 0.0.46

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unstructured-platform-plugins 0.0.46
File Size Uploaded
unstructured_platform_plugins-0.0.46.tar.gz 21.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for unstructured-platform-plugins 0.0.46
File Interpreter ABI Platform
unstructured_platform_plugins-0.0.46-py3-none-any.whl Python 3 none any Details

Total release size: 48.1 kB

Release files / unstructured_platform_plugins-0.0.46.tar.gz

Download URL unstructured_platform_plugins-0.0.46.tar.gz
Size 21.9 kB
Tags Source
SHA-256 checksum
How to use checksums
66bad2439c1c42ce68f4963ae5f6804e01329dc1cf6441f52f27def93c1fb9f2
BLAKE2b-256 checksum
How to use checksums
d2131e817a1151765c1bca80956d310fd6125d35ca2734908901796530d0bc85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / unstructured_platform_plugins-0.0.46-py3-none-any.whl

Download URL unstructured_platform_plugins-0.0.46-py3-none-any.whl
Size 26.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f33701ae3cfc17785021a9e5a98bacbebdb296e0d901b7063417b29d582b43f7
BLAKE2b-256 checksum
How to use checksums
38736622287a739272659f5a452a30ea80cf8cfab6a16c7b5cde5b1452d84772
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.1.0

2 release files

This release

0.0.46 This release

2 release files

0.0.45

2 release files

0.0.44

2 release files

0.0.40

2 release files

0.0.39

2 release files

0.0.38

2 release files

0.0.37

2 release files

0.0.35

2 release files

0.0.34

2 release files

0.0.33

2 release files

0.0.32

2 release files

0.0.31

2 release files

0.0.30

2 release files

0.0.28

2 release files

0.0.27

2 release files

0.0.26

2 release files

0.0.25

2 release files

0.0.24

2 release files

0.0.23

2 release files

0.0.22

2 release files

0.0.21

2 release files

0.0.20

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page