unstructured-platform-plugins 0.0.44__tar.gz → 0.0.45__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/PKG-INFO +1 -1
- unstructured_platform_plugins-0.0.45/unstructured_platform_plugins/__version__.py +1 -0
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/unstructured_platform_plugins/etl_uvicorn/api_generator.py +39 -13
- unstructured_platform_plugins-0.0.44/unstructured_platform_plugins/__version__.py +0 -1
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/.gitignore +0 -0
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/LICENSE.md +0 -0
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/README.md +0 -0
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/pyproject.toml +0 -0
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/unstructured_platform_plugins/__init__.py +0 -0
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/unstructured_platform_plugins/etl_uvicorn/__init__.py +0 -0
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/unstructured_platform_plugins/etl_uvicorn/main.py +0 -0
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/unstructured_platform_plugins/etl_uvicorn/otel.py +0 -0
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/unstructured_platform_plugins/etl_uvicorn/utils.py +0 -0
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/unstructured_platform_plugins/schema/__init__.py +0 -0
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/unstructured_platform_plugins/schema/filedata_meta.py +0 -0
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/unstructured_platform_plugins/schema/json_schema.py +0 -0
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/unstructured_platform_plugins/schema/model.py +0 -0
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/unstructured_platform_plugins/schema/usage.py +0 -0
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/unstructured_platform_plugins/schema/utils.py +0 -0
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/unstructured_platform_plugins/type_hints.py +0 -0
- {unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/unstructured_platform_plugins/validate_api.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: unstructured_platform_plugins
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.45
|
|
4
4
|
Summary: Wrapper to convert arbitrary code into a uvicorn/fastapi implementation for Unstructured Platform
|
|
5
5
|
License-File: LICENSE.md
|
|
6
6
|
Classifier: Development Status :: 4 - Beta
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.45" # pragma: no cover
|
|
@@ -254,22 +254,48 @@ def _wrap_in_fastapi(
|
|
|
254
254
|
file_data=request_dict.get("file_data", None),
|
|
255
255
|
)
|
|
256
256
|
|
|
257
|
-
|
|
257
|
+
async def run_job_with_body(request: BaseModel) -> ResponseType:
|
|
258
|
+
log_func_and_body(func=func, body=request.json())
|
|
259
|
+
# Create dictionary from pydantic model while preserving underlying types
|
|
260
|
+
request_dict = {f: getattr(request, f) for f in request.model_fields}
|
|
261
|
+
# Make sure nested classes get instantiated correctly. `file_data` can legitimately be None
|
|
262
|
+
# -- a plugin may declare it optional, and then an absent or partial body leaves it unset --
|
|
263
|
+
# so convert only a real value. Calling `.model_dump()` on None would raise before `wrap_fn`
|
|
264
|
+
# runs, turning the optional-body contract into a 500.
|
|
265
|
+
file_data = request_dict.get("file_data")
|
|
266
|
+
if file_data is not None:
|
|
267
|
+
request_dict["file_data"] = file_data_from_dict(file_data.model_dump())
|
|
268
|
+
map_inputs(func=func, raw_inputs=request_dict)
|
|
269
|
+
if logger.level == LOG_LEVELS.get("trace", logging.NOTSET):
|
|
270
|
+
logger.log(level=logger.level, msg=f"passing inputs to function: {request_dict}")
|
|
271
|
+
return await wrap_fn(func=func, kwargs=request_dict)
|
|
272
|
+
|
|
273
|
+
# A pydantic body parameter with no default is mandatory even when every field inside the model
|
|
274
|
+
# is optional. So a plugin whose parameters are ALL optional would demand a body that no caller
|
|
275
|
+
# has a reason to populate -- and before it grew those parameters that same plugin accepted no
|
|
276
|
+
# body at all, so adding one flips the HTTP contract while looking backward-compatible. Default
|
|
277
|
+
# the body in that case: an absent body resolves each field to its own default, which is exactly
|
|
278
|
+
# what the function signature already promises.
|
|
279
|
+
#
|
|
280
|
+
# A plugin with at least one required field keeps a mandatory body, so an indexer that needs
|
|
281
|
+
# `file_data` still fails validation rather than silently receiving None.
|
|
282
|
+
body_is_optional = input_schema_model.model_fields and not any(
|
|
283
|
+
field.is_required() for field in input_schema_model.model_fields.values()
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
if body_is_optional:
|
|
287
|
+
|
|
288
|
+
@fastapi_app.post("/invoke", response_model=InvokeResponse)
|
|
289
|
+
async def run_job(request: Optional[input_schema_model] = None) -> ResponseType:
|
|
290
|
+
return await run_job_with_body(
|
|
291
|
+
request if request is not None else input_schema_model()
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
elif input_schema_model.model_fields:
|
|
258
295
|
|
|
259
296
|
@fastapi_app.post("/invoke", response_model=InvokeResponse)
|
|
260
297
|
async def run_job(request: input_schema_model) -> ResponseType:
|
|
261
|
-
|
|
262
|
-
# Create dictionary from pydantic model while preserving underlying types
|
|
263
|
-
request_dict = {f: getattr(request, f) for f in request.model_fields}
|
|
264
|
-
# Make sure nested classes get instantiated correctly
|
|
265
|
-
if "file_data" in request_dict:
|
|
266
|
-
request_dict["file_data"] = file_data_from_dict(
|
|
267
|
-
request_dict["file_data"].model_dump()
|
|
268
|
-
)
|
|
269
|
-
map_inputs(func=func, raw_inputs=request_dict)
|
|
270
|
-
if logger.level == LOG_LEVELS.get("trace", logging.NOTSET):
|
|
271
|
-
logger.log(level=logger.level, msg=f"passing inputs to function: {request_dict}")
|
|
272
|
-
return await wrap_fn(func=func, kwargs=request_dict)
|
|
298
|
+
return await run_job_with_body(request)
|
|
273
299
|
|
|
274
300
|
else:
|
|
275
301
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.0.44" # pragma: no cover
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unstructured_platform_plugins-0.0.44 → unstructured_platform_plugins-0.0.45}/pyproject.toml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|