unstructured-platform-plugins 0.0.3__tar.gz → 0.0.5__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.3/unstructured_platform_plugins.egg-info → unstructured-platform-plugins-0.0.5}/PKG-INFO +1 -1
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/test_schema.py +8 -0
- unstructured-platform-plugins-0.0.5/unstructured_platform_plugins/__version__.py +1 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins/etl_uvicorn/api_generator.py +23 -4
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5/unstructured_platform_plugins.egg-info}/PKG-INFO +1 -1
- unstructured-platform-plugins-0.0.3/unstructured_platform_plugins/__version__.py +0 -1
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/LICENSE +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/LICENSE.md +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/README.md +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/pyproject.toml +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/setup.cfg +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/setup.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/__init__.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/assets/__init__.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/assets/async_typed_dict_response.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/assets/dataclass_response.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/assets/empty_input_and_response.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/assets/hash_function.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/assets/improper_function.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/assets/pydantic_response_class_method.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/assets/simple_hash_class.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/assets/simple_hash_lambda.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/assets/simple_hash_value.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/assets/typed_dict_response.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/test_utils.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins/__init__.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins/etl_uvicorn/__init__.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins/etl_uvicorn/main.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins/etl_uvicorn/otel.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins/etl_uvicorn/utils.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins/schema/__init__.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins/schema/json_schema.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins/schema/model.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins/schema/usage.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins/schema/utils.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins/type_hints.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins/validate_api.py +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins.egg-info/SOURCES.txt +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins.egg-info/dependency_links.txt +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins.egg-info/entry_points.txt +0 -0
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins.egg-info/requires.txt +2 -2
- {unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/unstructured_platform_plugins.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: unstructured-platform-plugins
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
4
4
|
Summary: A utility library that provides tools around unstructured plugin development
|
|
5
5
|
Home-page: https://github.com/Unstructured-IO/unstructured-platform-plugins
|
|
6
6
|
License: Apache-2.0
|
{unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/test_schema.py
RENAMED
|
@@ -566,6 +566,10 @@ def test_file_data():
|
|
|
566
566
|
"items": {"key": {"type": "string"}, "value": {}},
|
|
567
567
|
},
|
|
568
568
|
"reprocess": {"type": "boolean", "default": False},
|
|
569
|
+
"local_download_path": {
|
|
570
|
+
"anyOf": [{"type": "string"}, {"type": "null"}],
|
|
571
|
+
"default": None,
|
|
572
|
+
},
|
|
569
573
|
},
|
|
570
574
|
"required": ["identifier", "connector_type", "metadata", "additional_metadata"],
|
|
571
575
|
}
|
|
@@ -659,6 +663,10 @@ def test_file_data():
|
|
|
659
663
|
"items": {"key": {"type": "string"}, "value": {}},
|
|
660
664
|
},
|
|
661
665
|
"reprocess": {"type": "boolean", "default": False},
|
|
666
|
+
"local_download_path": {
|
|
667
|
+
"anyOf": [{"type": "string"}, {"type": "null"}],
|
|
668
|
+
"default": None,
|
|
669
|
+
},
|
|
662
670
|
},
|
|
663
671
|
"required": ["identifier", "connector_type", "metadata", "additional_metadata"],
|
|
664
672
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.5" # pragma: no cover
|
|
@@ -3,12 +3,14 @@ import hashlib
|
|
|
3
3
|
import inspect
|
|
4
4
|
import json
|
|
5
5
|
import logging
|
|
6
|
+
from functools import partial
|
|
6
7
|
from typing import Any, Callable, Optional
|
|
7
8
|
|
|
8
9
|
from fastapi import FastAPI, status
|
|
9
10
|
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
|
|
10
11
|
from pydantic import BaseModel
|
|
11
12
|
from starlette.responses import RedirectResponse
|
|
13
|
+
from uvicorn.config import LOG_LEVELS
|
|
12
14
|
from uvicorn.importer import import_from_string
|
|
13
15
|
|
|
14
16
|
from unstructured_platform_plugins.etl_uvicorn.otel import get_metric_provider, get_trace_provider
|
|
@@ -28,12 +30,28 @@ from unstructured_platform_plugins.schema.usage import UsageData
|
|
|
28
30
|
logger = logging.getLogger("uvicorn.error")
|
|
29
31
|
|
|
30
32
|
|
|
33
|
+
def log_func_and_body(func: Callable, body: Optional[str] = None) -> None:
|
|
34
|
+
msg = None
|
|
35
|
+
if logger.level == LOG_LEVELS.get("debug", logging.NOTSET):
|
|
36
|
+
if not body:
|
|
37
|
+
msg = f"invoking function without inputs: {func.__name__}"
|
|
38
|
+
else:
|
|
39
|
+
msg = f"invoking function {func.__name__} with body"
|
|
40
|
+
elif logger.level == LOG_LEVELS.get("trace", logging.NOTSET):
|
|
41
|
+
if not body:
|
|
42
|
+
msg = f"invoking function without inputs: {func}"
|
|
43
|
+
else:
|
|
44
|
+
msg = f"invoking function {func} with body: {body}"
|
|
45
|
+
if msg:
|
|
46
|
+
logger.log(level=logger.level, msg=msg)
|
|
47
|
+
|
|
48
|
+
|
|
31
49
|
async def invoke_func(func: Callable, kwargs: Optional[dict[str, Any]] = None) -> Any:
|
|
32
50
|
kwargs = kwargs or {}
|
|
33
51
|
if inspect.iscoroutinefunction(func):
|
|
34
52
|
return await func(**kwargs)
|
|
35
53
|
else:
|
|
36
|
-
return func
|
|
54
|
+
return await asyncio.get_event_loop().run_in_executor(None, partial(func, **kwargs))
|
|
37
55
|
|
|
38
56
|
|
|
39
57
|
def check_precheck_func(precheck_func: Callable):
|
|
@@ -115,18 +133,19 @@ def generate_fast_api(
|
|
|
115
133
|
|
|
116
134
|
@fastapi_app.post("/invoke", response_model=InvokeResponse)
|
|
117
135
|
async def run_job(request: input_schema_model) -> InvokeResponse:
|
|
118
|
-
|
|
136
|
+
log_func_and_body(func=func, body=request.json())
|
|
119
137
|
# Create dictionary from pydantic model while preserving underlying types
|
|
120
138
|
request_dict = {f: getattr(request, f) for f in request.model_fields}
|
|
121
139
|
map_inputs(func=func, raw_inputs=request_dict)
|
|
122
|
-
logger.
|
|
140
|
+
if logger.level == LOG_LEVELS.get("trace", logging.NOTSET):
|
|
141
|
+
logger.log(level=logger.level, msg=f"passing inputs to function: {request_dict}")
|
|
123
142
|
return await wrap_fn(func=func, kwargs=request_dict)
|
|
124
143
|
|
|
125
144
|
else:
|
|
126
145
|
|
|
127
146
|
@fastapi_app.post("/invoke", response_model=InvokeResponse)
|
|
128
147
|
async def run_job() -> InvokeResponse:
|
|
129
|
-
|
|
148
|
+
log_func_and_body(func=func)
|
|
130
149
|
return await wrap_fn(
|
|
131
150
|
func=func,
|
|
132
151
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: unstructured-platform-plugins
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.5
|
|
4
4
|
Summary: A utility library that provides tools around unstructured plugin development
|
|
5
5
|
Home-page: https://github.com/Unstructured-IO/unstructured-platform-plugins
|
|
6
6
|
License: Apache-2.0
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.0.3" # pragma: no cover
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/__init__.py
RENAMED
|
File without changes
|
{unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/assets/__init__.py
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
|
{unstructured-platform-plugins-0.0.3 → unstructured-platform-plugins-0.0.5}/test/test_utils.py
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|