ivcap-lambda 0.8.2__tar.gz → 0.8.4__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.
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/PKG-INFO +1 -1
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/ivcap_lambda/builder.py +1 -1
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/ivcap_lambda/server.py +56 -7
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/ivcap_lambda/service_definition.py +10 -1
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/pyproject.toml +1 -1
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/AUTHORS.md +0 -0
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/LICENSE +0 -0
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/README.md +0 -0
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/ivcap_lambda/__init__.py +0 -0
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/ivcap_lambda/decorators.py +0 -0
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/ivcap_lambda/executor.py +0 -0
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/ivcap_lambda/health_handler.py +0 -0
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/ivcap_lambda/logger.py +0 -0
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/ivcap_lambda/logging.json +0 -0
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/ivcap_lambda/mcp.py +0 -0
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/ivcap_lambda/py.typed +0 -0
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/ivcap_lambda/secret.py +0 -0
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/ivcap_lambda/utils.py +0 -0
- {ivcap_lambda-0.8.2 → ivcap_lambda-0.8.4}/ivcap_lambda/version.py +0 -0
|
@@ -286,7 +286,7 @@ def _return_job_result(el, job_id):
|
|
|
286
286
|
headers=h,
|
|
287
287
|
)
|
|
288
288
|
elif isinstance(el, ExecutionError):
|
|
289
|
-
if el.type
|
|
289
|
+
if el.type == ValueError.__name__:
|
|
290
290
|
m = ErrorModel(message=el.error, code=400)
|
|
291
291
|
status_code = status.HTTP_400_BAD_REQUEST
|
|
292
292
|
else:
|
|
@@ -17,6 +17,7 @@ from ivcap_service import (
|
|
|
17
17
|
Service,
|
|
18
18
|
SidecarReporter,
|
|
19
19
|
getLogger,
|
|
20
|
+
init_openobserve_from_env,
|
|
20
21
|
otel_instrument,
|
|
21
22
|
print_tool_definition,
|
|
22
23
|
service_log_config,
|
|
@@ -66,7 +67,8 @@ def start_lambda_server(
|
|
|
66
67
|
logger (Logger): optional logger instance; defaults to getLogger("app")
|
|
67
68
|
custom_args (Optional[Callable[[argparse.ArgumentParser], argparse.Namespace]], optional): callback to add extra CLI arguments. Defaults to None.
|
|
68
69
|
run_opts (Optional[Dict[str, Any]], optional): extra options forwarded to uvicorn.Config. Defaults to None.
|
|
69
|
-
with_telemetry: (Optional[bool]):
|
|
70
|
+
with_telemetry: (Optional[bool]): Tri-state control of OpenTelemetry
|
|
71
|
+
instrumentation. CLI flags take precedence over this parameter.
|
|
70
72
|
"""
|
|
71
73
|
if len(tools) == 0:
|
|
72
74
|
raise ValueError(
|
|
@@ -94,8 +96,16 @@ def start_lambda_server(
|
|
|
94
96
|
parser.add_argument(
|
|
95
97
|
"--port", type=int, default=os.environ.get("PORT", "8090"), help="Port number"
|
|
96
98
|
)
|
|
97
|
-
parser.
|
|
98
|
-
|
|
99
|
+
telemetry_group = parser.add_mutually_exclusive_group()
|
|
100
|
+
telemetry_group.add_argument(
|
|
101
|
+
"--with-telemetry",
|
|
102
|
+
action="store_true",
|
|
103
|
+
help="Force-enable OpenTelemetry instrumentation",
|
|
104
|
+
)
|
|
105
|
+
telemetry_group.add_argument(
|
|
106
|
+
"--without-telemetry",
|
|
107
|
+
action="store_true",
|
|
108
|
+
help="Force-disable OpenTelemetry instrumentation",
|
|
99
109
|
)
|
|
100
110
|
parser.add_argument("--with-mcp", action="store_true", help="Add an MCP endpoint")
|
|
101
111
|
parser.add_argument(
|
|
@@ -107,6 +117,11 @@ def start_lambda_server(
|
|
|
107
117
|
"e.g. Claude Desktop, Cline). Requires the 'mcp' extra."
|
|
108
118
|
),
|
|
109
119
|
)
|
|
120
|
+
parser.add_argument(
|
|
121
|
+
"--list-services",
|
|
122
|
+
action="store_true",
|
|
123
|
+
help="List the names of all registered services/tools and exit",
|
|
124
|
+
)
|
|
110
125
|
parser.add_argument(
|
|
111
126
|
"--print-service-description",
|
|
112
127
|
type=str,
|
|
@@ -116,6 +131,15 @@ def start_lambda_server(
|
|
|
116
131
|
default=None,
|
|
117
132
|
help=f"Print service description to stdout [{','.join(tool_names)}]",
|
|
118
133
|
)
|
|
134
|
+
parser.add_argument(
|
|
135
|
+
"--service-name",
|
|
136
|
+
type=str,
|
|
137
|
+
default=None,
|
|
138
|
+
help=(
|
|
139
|
+
"Override the service name used in --print-service-description "
|
|
140
|
+
"(defaults to the tool name, with '_' replaced by '-')"
|
|
141
|
+
),
|
|
142
|
+
)
|
|
119
143
|
parser.add_argument(
|
|
120
144
|
"--print-tool-description",
|
|
121
145
|
type=str,
|
|
@@ -134,6 +158,11 @@ def start_lambda_server(
|
|
|
134
158
|
if args.with_mcp_stdio and args.with_mcp:
|
|
135
159
|
parser.error("--with-mcp-stdio and --with-mcp are mutually exclusive")
|
|
136
160
|
|
|
161
|
+
if args.list_services:
|
|
162
|
+
for name in tool_names:
|
|
163
|
+
print(name)
|
|
164
|
+
sys.exit(0)
|
|
165
|
+
|
|
137
166
|
if args.print_tool_description:
|
|
138
167
|
tool = next((t for t in tools if t.name == args.print_tool_description), None)
|
|
139
168
|
if tool is None:
|
|
@@ -157,14 +186,32 @@ def start_lambda_server(
|
|
|
157
186
|
file=sys.stderr,
|
|
158
187
|
)
|
|
159
188
|
sys.exit(1)
|
|
160
|
-
|
|
189
|
+
tool_slug = tool.name.replace("_", "-")
|
|
190
|
+
name = args.service_name or f"{service.name}-{tool_slug}"
|
|
191
|
+
print_rest_service_definition(
|
|
192
|
+
service, tool.worker_fn, name=name, path=tool.path_prefix
|
|
193
|
+
)
|
|
161
194
|
sys.exit(0)
|
|
162
195
|
|
|
163
196
|
logger.info(
|
|
164
197
|
f"{title} - {os.getenv('VERSION')} - v{get_version()}|v{get_service_version()}"
|
|
165
198
|
)
|
|
166
199
|
|
|
167
|
-
|
|
200
|
+
try:
|
|
201
|
+
init_openobserve_from_env(
|
|
202
|
+
logger=logger,
|
|
203
|
+
service_name=service.name,
|
|
204
|
+
service_version=service.version,
|
|
205
|
+
)
|
|
206
|
+
except Exception as exc:
|
|
207
|
+
logger.warning("OpenTelemetry initialization failed: %s", exc)
|
|
208
|
+
|
|
209
|
+
effective_with_telemetry = with_telemetry
|
|
210
|
+
if getattr(args, "without_telemetry", False):
|
|
211
|
+
effective_with_telemetry = False
|
|
212
|
+
elif getattr(args, "with_telemetry", False):
|
|
213
|
+
effective_with_telemetry = True
|
|
214
|
+
|
|
168
215
|
set_event_reporter_factory(SidecarReporter) # type: ignore[arg-type]
|
|
169
216
|
|
|
170
217
|
def get_context():
|
|
@@ -183,7 +230,7 @@ def start_lambda_server(
|
|
|
183
230
|
# instrumented the same way as for the HTTP server.
|
|
184
231
|
from .mcp import run_mcp_stdio
|
|
185
232
|
|
|
186
|
-
otel_instrument(
|
|
233
|
+
otel_instrument(effective_with_telemetry, None, logger)
|
|
187
234
|
run_mcp_stdio(service.name, app.version)
|
|
188
235
|
return
|
|
189
236
|
|
|
@@ -201,7 +248,9 @@ def start_lambda_server(
|
|
|
201
248
|
register_mcp(app, "/mcp")
|
|
202
249
|
|
|
203
250
|
otel_instrument(
|
|
204
|
-
|
|
251
|
+
effective_with_telemetry,
|
|
252
|
+
lambda _: FastAPIInstrumentor.instrument_app(app),
|
|
253
|
+
logger,
|
|
205
254
|
)
|
|
206
255
|
|
|
207
256
|
async def _add_version(request: Request, call_next) -> Response:
|
|
@@ -22,6 +22,7 @@ REST_CONTROLLER_SCHEMA = "urn:ivcap:schema.service.rest.1"
|
|
|
22
22
|
|
|
23
23
|
class RestController(BaseModel):
|
|
24
24
|
jschema: str = Field(default=REST_CONTROLLER_SCHEMA, alias="$schema")
|
|
25
|
+
path: str | None = Field(default=None, description="internal path of this tool's endpoint")
|
|
25
26
|
image: str
|
|
26
27
|
command: list[str] | str
|
|
27
28
|
resources: Resources = Field(default_factory=Resources)
|
|
@@ -30,11 +31,15 @@ def print_rest_service_definition(
|
|
|
30
31
|
service_description: Service,
|
|
31
32
|
fn: Callable[..., Any],
|
|
32
33
|
service_id: str | None = None,
|
|
34
|
+
name: str | None = None,
|
|
35
|
+
path: str | None = None,
|
|
33
36
|
):
|
|
34
37
|
sd = create_rest_service_definition(
|
|
35
38
|
service_description,
|
|
36
39
|
fn,
|
|
37
40
|
service_id=service_id,
|
|
41
|
+
name=name,
|
|
42
|
+
path=path,
|
|
38
43
|
)
|
|
39
44
|
print(sd.model_dump_json(indent=2, by_alias=True, exclude_none=True))
|
|
40
45
|
|
|
@@ -42,11 +47,15 @@ def create_rest_service_definition(
|
|
|
42
47
|
service_description: Service,
|
|
43
48
|
fn: Callable[..., Any],
|
|
44
49
|
service_id: str | None = None,
|
|
50
|
+
name: str | None = None,
|
|
51
|
+
path: str | None = None,
|
|
45
52
|
) -> ServiceDefinition:
|
|
46
53
|
# controller
|
|
47
54
|
image = os.getenv("DOCKER_IMG", IMAGE_PLACEHOLDER)
|
|
48
55
|
|
|
49
56
|
command = find_command()
|
|
50
57
|
resources = find_resources_file()
|
|
51
|
-
controller = RestController(image=image, command=command, resources=resources)
|
|
58
|
+
controller = RestController(path=path, image=image, command=command, resources=resources)
|
|
59
|
+
if name is not None:
|
|
60
|
+
service_description = service_description.model_copy(update={"name": name})
|
|
52
61
|
return create_service_definition(service_description, fn, REST_CONTROLLER_SCHEMA, controller, service_id)
|
|
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
|