unstructured-platform-plugins 0.0.2__tar.gz → 0.0.3__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.2/unstructured_platform_plugins.egg-info → unstructured-platform-plugins-0.0.3}/PKG-INFO +1 -1
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/test/test_schema.py +8 -0
- unstructured-platform-plugins-0.0.3/unstructured_platform_plugins/__version__.py +1 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/unstructured_platform_plugins/etl_uvicorn/api_generator.py +6 -0
- unstructured-platform-plugins-0.0.3/unstructured_platform_plugins/etl_uvicorn/otel.py +107 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3/unstructured_platform_plugins.egg-info}/PKG-INFO +1 -1
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/unstructured_platform_plugins.egg-info/SOURCES.txt +1 -0
- unstructured-platform-plugins-0.0.3/unstructured_platform_plugins.egg-info/requires.txt +8 -0
- unstructured-platform-plugins-0.0.2/unstructured_platform_plugins/__version__.py +0 -1
- unstructured-platform-plugins-0.0.2/unstructured_platform_plugins.egg-info/requires.txt +0 -6
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/LICENSE +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/LICENSE.md +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/README.md +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/pyproject.toml +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/setup.cfg +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/setup.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/test/__init__.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/test/assets/__init__.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/test/assets/async_typed_dict_response.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/test/assets/dataclass_response.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/test/assets/empty_input_and_response.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/test/assets/hash_function.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/test/assets/improper_function.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/test/assets/pydantic_response_class_method.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/test/assets/simple_hash_class.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/test/assets/simple_hash_lambda.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/test/assets/simple_hash_value.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/test/assets/typed_dict_response.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/test/test_utils.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/unstructured_platform_plugins/__init__.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/unstructured_platform_plugins/etl_uvicorn/__init__.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/unstructured_platform_plugins/etl_uvicorn/main.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/unstructured_platform_plugins/etl_uvicorn/utils.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/unstructured_platform_plugins/schema/__init__.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/unstructured_platform_plugins/schema/json_schema.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/unstructured_platform_plugins/schema/model.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/unstructured_platform_plugins/schema/usage.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/unstructured_platform_plugins/schema/utils.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/unstructured_platform_plugins/type_hints.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/unstructured_platform_plugins/validate_api.py +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/unstructured_platform_plugins.egg-info/dependency_links.txt +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/unstructured_platform_plugins.egg-info/entry_points.txt +0 -0
- {unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/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.3
|
|
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.2 → unstructured-platform-plugins-0.0.3}/test/test_schema.py
RENAMED
|
@@ -554,6 +554,10 @@ def test_file_data():
|
|
|
554
554
|
],
|
|
555
555
|
"default": None,
|
|
556
556
|
},
|
|
557
|
+
"filesize_bytes": {
|
|
558
|
+
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
|
559
|
+
"default": None,
|
|
560
|
+
},
|
|
557
561
|
},
|
|
558
562
|
"required": [],
|
|
559
563
|
},
|
|
@@ -643,6 +647,10 @@ def test_file_data():
|
|
|
643
647
|
],
|
|
644
648
|
"default": None,
|
|
645
649
|
},
|
|
650
|
+
"filesize_bytes": {
|
|
651
|
+
"anyOf": [{"type": "integer"}, {"type": "null"}],
|
|
652
|
+
"default": None,
|
|
653
|
+
},
|
|
646
654
|
},
|
|
647
655
|
"required": [],
|
|
648
656
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.3" # pragma: no cover
|
|
@@ -6,10 +6,12 @@ import logging
|
|
|
6
6
|
from typing import Any, Callable, Optional
|
|
7
7
|
|
|
8
8
|
from fastapi import FastAPI, status
|
|
9
|
+
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
|
|
9
10
|
from pydantic import BaseModel
|
|
10
11
|
from starlette.responses import RedirectResponse
|
|
11
12
|
from uvicorn.importer import import_from_string
|
|
12
13
|
|
|
14
|
+
from unstructured_platform_plugins.etl_uvicorn.otel import get_metric_provider, get_trace_provider
|
|
13
15
|
from unstructured_platform_plugins.etl_uvicorn.utils import (
|
|
14
16
|
get_func,
|
|
15
17
|
get_input_schema,
|
|
@@ -170,4 +172,8 @@ def generate_fast_api(
|
|
|
170
172
|
except TypeError as e:
|
|
171
173
|
raise TypeError(f"failed to validate function schema: {e}") from e
|
|
172
174
|
|
|
175
|
+
FastAPIInstrumentor.instrument_app(
|
|
176
|
+
fastapi_app, tracer_provider=get_trace_provider(), meter_provider=get_metric_provider()
|
|
177
|
+
)
|
|
178
|
+
|
|
173
179
|
return fastapi_app
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from typing import Literal, TypedDict
|
|
3
|
+
|
|
4
|
+
from opentelemetry.environment_variables import OTEL_METRICS_EXPORTER, OTEL_TRACES_EXPORTER
|
|
5
|
+
from opentelemetry.sdk.environment_variables import OTEL_SERVICE_NAME
|
|
6
|
+
from opentelemetry.sdk.metrics import MeterProvider
|
|
7
|
+
from opentelemetry.sdk.metrics.export import (
|
|
8
|
+
ConsoleMetricExporter,
|
|
9
|
+
MetricReader,
|
|
10
|
+
PeriodicExportingMetricReader,
|
|
11
|
+
)
|
|
12
|
+
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
|
|
13
|
+
from opentelemetry.sdk.trace import TracerProvider
|
|
14
|
+
from opentelemetry.sdk.trace.export import (
|
|
15
|
+
ConsoleSpanExporter,
|
|
16
|
+
SimpleSpanProcessor,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
TraceExporterType = Literal["otlp", "jaeger", "zipkin", "console"]
|
|
20
|
+
MetricExporterType = Literal["otlp", "prometheus", "none"]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class OtelSettings(TypedDict):
|
|
24
|
+
service_name: str
|
|
25
|
+
trace_exporters: list[TraceExporterType]
|
|
26
|
+
metric_exporters: list[MetricExporterType]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_settings() -> OtelSettings:
|
|
30
|
+
service_name = os.environ.get(OTEL_SERVICE_NAME, "unknown_service")
|
|
31
|
+
trace_exporters = os.environ.get(OTEL_TRACES_EXPORTER)
|
|
32
|
+
trace_exporters = trace_exporters.split(",") if trace_exporters else []
|
|
33
|
+
|
|
34
|
+
metric_exporters = os.environ.get(OTEL_METRICS_EXPORTER)
|
|
35
|
+
metric_exporters = metric_exporters.split(",") if metric_exporters else []
|
|
36
|
+
return OtelSettings(
|
|
37
|
+
service_name=service_name,
|
|
38
|
+
trace_exporters=trace_exporters,
|
|
39
|
+
metric_exporters=metric_exporters,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def get_trace_provider() -> TracerProvider:
|
|
44
|
+
settings = get_settings()
|
|
45
|
+
print(settings)
|
|
46
|
+
provider = TracerProvider(resource=Resource({SERVICE_NAME: settings["service_name"]}))
|
|
47
|
+
|
|
48
|
+
for trace_exporter_type in settings["trace_exporters"]:
|
|
49
|
+
_add_trace_exporter(exporter_type=trace_exporter_type, provider=provider)
|
|
50
|
+
|
|
51
|
+
return provider
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def get_metric_provider() -> MeterProvider:
|
|
55
|
+
settings = get_settings()
|
|
56
|
+
readers = []
|
|
57
|
+
for metric_exporter_type in settings["metric_exporters"]:
|
|
58
|
+
readers.append(_get_metrics_reader(exporter_type=metric_exporter_type))
|
|
59
|
+
return MeterProvider(
|
|
60
|
+
resource=Resource({SERVICE_NAME: settings["service_name"]}), metric_readers=readers
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def _add_trace_exporter(exporter_type: TraceExporterType, provider: TracerProvider):
|
|
65
|
+
if exporter_type == "otlp":
|
|
66
|
+
_add_traces_otlp_exporter(
|
|
67
|
+
provider,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
elif exporter_type == "console":
|
|
71
|
+
_add_traces_console_exporter(provider)
|
|
72
|
+
else:
|
|
73
|
+
raise NotImplementedError(f"{exporter_type} implementation not supported yet")
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def _get_metrics_reader(exporter_type: MetricExporterType) -> MetricReader:
|
|
77
|
+
if exporter_type == "otlp":
|
|
78
|
+
return _get_metric_otlp_reader()
|
|
79
|
+
if exporter_type == "console":
|
|
80
|
+
return _get_metric_console_reader()
|
|
81
|
+
raise NotImplementedError(f"{exporter_type} implementation not supported yet")
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def _add_traces_console_exporter(provider: TracerProvider) -> None:
|
|
85
|
+
exporter = ConsoleSpanExporter()
|
|
86
|
+
processor = SimpleSpanProcessor(exporter)
|
|
87
|
+
provider.add_span_processor(processor)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def _add_traces_otlp_exporter(provider: TracerProvider) -> None:
|
|
91
|
+
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
|
|
92
|
+
|
|
93
|
+
exporter = OTLPSpanExporter()
|
|
94
|
+
processor = SimpleSpanProcessor(exporter)
|
|
95
|
+
provider.add_span_processor(processor)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _get_metric_otlp_reader() -> MetricReader:
|
|
99
|
+
from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter
|
|
100
|
+
|
|
101
|
+
exporter = OTLPMetricExporter()
|
|
102
|
+
return PeriodicExportingMetricReader(exporter)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _get_metric_console_reader() -> MetricReader:
|
|
106
|
+
exporter = ConsoleMetricExporter()
|
|
107
|
+
return PeriodicExportingMetricReader(exporter)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: unstructured-platform-plugins
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
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
|
|
@@ -31,6 +31,7 @@ unstructured_platform_plugins.egg-info/top_level.txt
|
|
|
31
31
|
unstructured_platform_plugins/etl_uvicorn/__init__.py
|
|
32
32
|
unstructured_platform_plugins/etl_uvicorn/api_generator.py
|
|
33
33
|
unstructured_platform_plugins/etl_uvicorn/main.py
|
|
34
|
+
unstructured_platform_plugins/etl_uvicorn/otel.py
|
|
34
35
|
unstructured_platform_plugins/etl_uvicorn/utils.py
|
|
35
36
|
unstructured_platform_plugins/schema/__init__.py
|
|
36
37
|
unstructured_platform_plugins/schema/json_schema.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.0.2" # 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.2 → unstructured-platform-plugins-0.0.3}/test/__init__.py
RENAMED
|
File without changes
|
{unstructured-platform-plugins-0.0.2 → unstructured-platform-plugins-0.0.3}/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.2 → unstructured-platform-plugins-0.0.3}/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
|