unstructured-platform-plugins 0.0.41__tar.gz → 0.0.44__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.41 → unstructured_platform_plugins-0.0.44}/PKG-INFO +5 -1
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/README.md +4 -0
- unstructured_platform_plugins-0.0.44/unstructured_platform_plugins/__version__.py +1 -0
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/unstructured_platform_plugins/etl_uvicorn/api_generator.py +5 -0
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/unstructured_platform_plugins/etl_uvicorn/main.py +21 -0
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/unstructured_platform_plugins/etl_uvicorn/otel.py +10 -2
- unstructured_platform_plugins-0.0.41/unstructured_platform_plugins/__version__.py +0 -1
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/.gitignore +0 -0
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/LICENSE.md +0 -0
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/pyproject.toml +0 -0
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/unstructured_platform_plugins/__init__.py +0 -0
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/unstructured_platform_plugins/etl_uvicorn/__init__.py +0 -0
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/unstructured_platform_plugins/etl_uvicorn/utils.py +0 -0
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/unstructured_platform_plugins/schema/__init__.py +0 -0
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/unstructured_platform_plugins/schema/filedata_meta.py +0 -0
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/unstructured_platform_plugins/schema/json_schema.py +0 -0
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/unstructured_platform_plugins/schema/model.py +0 -0
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/unstructured_platform_plugins/schema/usage.py +0 -0
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/unstructured_platform_plugins/schema/utils.py +0 -0
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/unstructured_platform_plugins/type_hints.py +0 -0
- {unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/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.44
|
|
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
|
|
@@ -29,6 +29,10 @@ Description-Content-Type: text/markdown
|
|
|
29
29
|
# Unstructured Platform Plugins
|
|
30
30
|

|
|
31
31
|
|
|
32
|
+
> **Deprecation notice:** `wrap_in_fastapi` (and the `etl-uvicorn` CLI it backs)
|
|
33
|
+
> is deprecated. New plugins should build a FastAPI app directly with explicit
|
|
34
|
+
> handlers for the plugin contract routes (`/invoke`, `/schema`, `/id`, etc.).
|
|
35
|
+
|
|
32
36
|
Information about how to build custom plugins to integrate with Unstructured Platform.
|
|
33
37
|
|
|
34
38
|
## Plugin Development
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# Unstructured Platform Plugins
|
|
2
2
|

|
|
3
3
|
|
|
4
|
+
> **Deprecation notice:** `wrap_in_fastapi` (and the `etl-uvicorn` CLI it backs)
|
|
5
|
+
> is deprecated. New plugins should build a FastAPI app directly with explicit
|
|
6
|
+
> handlers for the plugin contract routes (`/invoke`, `/schema`, `/id`, etc.).
|
|
7
|
+
|
|
4
8
|
Information about how to build custom plugins to integrate with Unstructured Platform.
|
|
5
9
|
|
|
6
10
|
## Plugin Development
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.44" # pragma: no cover
|
|
@@ -11,6 +11,7 @@ from fastapi.responses import StreamingResponse
|
|
|
11
11
|
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
|
|
12
12
|
from pydantic import BaseModel, Field, create_model
|
|
13
13
|
from starlette.responses import RedirectResponse
|
|
14
|
+
from typing_extensions import deprecated
|
|
14
15
|
from unstructured_ingest.data_types.file_data import BatchFileData, FileData, file_data_from_dict
|
|
15
16
|
from unstructured_ingest.error import UnstructuredIngestError
|
|
16
17
|
from uvicorn.config import LOG_LEVELS
|
|
@@ -108,6 +109,10 @@ def update_filedata_model(new_type) -> BaseModel:
|
|
|
108
109
|
return new_filedata_model
|
|
109
110
|
|
|
110
111
|
|
|
112
|
+
@deprecated(
|
|
113
|
+
"wrap_in_fastapi is deprecated; build a FastAPI app directly with "
|
|
114
|
+
"explicit handlers for the plugin contract routes."
|
|
115
|
+
)
|
|
111
116
|
def wrap_in_fastapi(
|
|
112
117
|
func: Callable,
|
|
113
118
|
plugin_id: str,
|
|
@@ -1,13 +1,34 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import signal
|
|
3
|
+
import threading
|
|
1
4
|
from dataclasses import dataclass, field
|
|
2
5
|
from typing import IO, Any, Optional
|
|
3
6
|
|
|
4
7
|
import click
|
|
8
|
+
import uvicorn
|
|
5
9
|
from uvicorn.config import LOGGING_CONFIG, Config, RawConfigParser
|
|
6
10
|
from uvicorn.main import main, run
|
|
7
11
|
|
|
8
12
|
from unstructured_platform_plugins.etl_uvicorn.api_generator import generate_fast_api
|
|
9
13
|
|
|
10
14
|
|
|
15
|
+
def _install_signal_handlers_ignoring_sigterm(self: uvicorn.Server) -> None:
|
|
16
|
+
# uvicorn's default load-sheds 504 on SIGTERM, which races with controllers
|
|
17
|
+
# trying to drain in-flight work during pod shutdown. Plugin webservers are
|
|
18
|
+
# expected to outlive their controller container so SIGKILL — not SIGTERM —
|
|
19
|
+
# ends the process. SIGINT is preserved so local Ctrl-C still works.
|
|
20
|
+
if threading.current_thread() is not threading.main_thread():
|
|
21
|
+
return
|
|
22
|
+
try:
|
|
23
|
+
loop = asyncio.get_event_loop()
|
|
24
|
+
loop.add_signal_handler(signal.SIGINT, self.handle_exit, signal.SIGINT, None)
|
|
25
|
+
except NotImplementedError:
|
|
26
|
+
signal.signal(signal.SIGINT, self.handle_exit)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
uvicorn.Server.install_signal_handlers = _install_signal_handlers_ignoring_sigterm
|
|
30
|
+
|
|
31
|
+
|
|
11
32
|
@dataclass
|
|
12
33
|
class CustomConfig:
|
|
13
34
|
log_config: dict[str, Any] | str | RawConfigParser | IO[Any] | None = field(
|
|
@@ -30,9 +30,11 @@ def get_settings() -> OtelSettings:
|
|
|
30
30
|
service_name = os.environ.get(OTEL_SERVICE_NAME, "unknown_service")
|
|
31
31
|
trace_exporters = os.environ.get(OTEL_TRACES_EXPORTER)
|
|
32
32
|
trace_exporters = trace_exporters.split(",") if trace_exporters else []
|
|
33
|
+
trace_exporters = [e for e in trace_exporters if e != "none"]
|
|
33
34
|
|
|
34
35
|
metric_exporters = os.environ.get(OTEL_METRICS_EXPORTER)
|
|
35
36
|
metric_exporters = metric_exporters.split(",") if metric_exporters else []
|
|
37
|
+
metric_exporters = [e for e in metric_exporters if e != "none"]
|
|
36
38
|
return OtelSettings(
|
|
37
39
|
service_name=service_name,
|
|
38
40
|
trace_exporters=trace_exporters,
|
|
@@ -40,8 +42,11 @@ def get_settings() -> OtelSettings:
|
|
|
40
42
|
)
|
|
41
43
|
|
|
42
44
|
|
|
43
|
-
def get_trace_provider() -> TracerProvider:
|
|
45
|
+
def get_trace_provider() -> TracerProvider | None:
|
|
44
46
|
settings = get_settings()
|
|
47
|
+
if not settings["trace_exporters"]:
|
|
48
|
+
return None
|
|
49
|
+
|
|
45
50
|
provider = TracerProvider(resource=Resource({SERVICE_NAME: settings["service_name"]}))
|
|
46
51
|
|
|
47
52
|
for trace_exporter_type in settings["trace_exporters"]:
|
|
@@ -50,8 +55,11 @@ def get_trace_provider() -> TracerProvider:
|
|
|
50
55
|
return provider
|
|
51
56
|
|
|
52
57
|
|
|
53
|
-
def get_metric_provider() -> MeterProvider:
|
|
58
|
+
def get_metric_provider() -> MeterProvider | None:
|
|
54
59
|
settings = get_settings()
|
|
60
|
+
if not settings["metric_exporters"]:
|
|
61
|
+
return None
|
|
62
|
+
|
|
55
63
|
readers = []
|
|
56
64
|
for metric_exporter_type in settings["metric_exporters"]:
|
|
57
65
|
readers.append(_get_metrics_reader(exporter_type=metric_exporter_type))
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.0.41" # pragma: no cover
|
|
File without changes
|
|
File without changes
|
{unstructured_platform_plugins-0.0.41 → unstructured_platform_plugins-0.0.44}/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
|