ivcap-lambda 0.8.2__py3-none-any.whl → 0.8.3__py3-none-any.whl

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/builder.py CHANGED
@@ -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 is ValueError:
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:
ivcap_lambda/server.py CHANGED
@@ -107,6 +107,11 @@ def start_lambda_server(
107
107
  "e.g. Claude Desktop, Cline). Requires the 'mcp' extra."
108
108
  ),
109
109
  )
110
+ parser.add_argument(
111
+ "--list-services",
112
+ action="store_true",
113
+ help="List the names of all registered services/tools and exit",
114
+ )
110
115
  parser.add_argument(
111
116
  "--print-service-description",
112
117
  type=str,
@@ -116,6 +121,15 @@ def start_lambda_server(
116
121
  default=None,
117
122
  help=f"Print service description to stdout [{','.join(tool_names)}]",
118
123
  )
124
+ parser.add_argument(
125
+ "--service-name",
126
+ type=str,
127
+ default=None,
128
+ help=(
129
+ "Override the service name used in --print-service-description "
130
+ "(defaults to the tool name, with '_' replaced by '-')"
131
+ ),
132
+ )
119
133
  parser.add_argument(
120
134
  "--print-tool-description",
121
135
  type=str,
@@ -134,6 +148,11 @@ def start_lambda_server(
134
148
  if args.with_mcp_stdio and args.with_mcp:
135
149
  parser.error("--with-mcp-stdio and --with-mcp are mutually exclusive")
136
150
 
151
+ if args.list_services:
152
+ for name in tool_names:
153
+ print(name)
154
+ sys.exit(0)
155
+
137
156
  if args.print_tool_description:
138
157
  tool = next((t for t in tools if t.name == args.print_tool_description), None)
139
158
  if tool is None:
@@ -157,7 +176,11 @@ def start_lambda_server(
157
176
  file=sys.stderr,
158
177
  )
159
178
  sys.exit(1)
160
- print_rest_service_definition(service, tool.worker_fn)
179
+ tool_slug = tool.name.replace("_", "-")
180
+ name = args.service_name or f"{service.name}-{tool_slug}"
181
+ print_rest_service_definition(
182
+ service, tool.worker_fn, name=name, path=tool.path_prefix
183
+ )
161
184
  sys.exit(0)
162
185
 
163
186
  logger.info(
@@ -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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ivcap-lambda
3
- Version: 0.8.2
3
+ Version: 0.8.3
4
4
  Summary: Helper functions for building lambda-style services on the IVCAP platform
5
5
  License-File: AUTHORS.md
6
6
  License-File: LICENSE
@@ -1,5 +1,5 @@
1
1
  ivcap_lambda/__init__.py,sha256=F7U051SfuhLLE88kHD7FvGWJSgIBeqQ1Kel6tWCPbeQ,1478
2
- ivcap_lambda/builder.py,sha256=vxArbC_v4xz0zQfoNpaBR5mHxO2ZElLMF4aBrNhLiV0,11634
2
+ ivcap_lambda/builder.py,sha256=mKxs9EkE_cYbAo-m-Va4MP06HaJNo-7u44dgxpf1hx8,11643
3
3
  ivcap_lambda/decorators.py,sha256=dHaw15aqn_42DsHE_GIEecceg9LBIPXw2B1W3spV2vQ,2779
4
4
  ivcap_lambda/executor.py,sha256=cJMk10dFwKi-P6eElbyvdS6vCxTgHF7HkGuK4wEfOhw,11802
5
5
  ivcap_lambda/health_handler.py,sha256=YyN9Qy_VFJ14LoV9hoK6851AS9jE8u-uI4akZvfmBQw,1385
@@ -8,12 +8,12 @@ ivcap_lambda/logging.json,sha256=EBreTGZe9l1OU_MylU4uigwA8Zs_RBPCr_UDWHCVAps,164
8
8
  ivcap_lambda/mcp.py,sha256=IhHp3ETZ7QugdqrFx6PeHyENHvqFNUFI3ddldQqJYX0,12028
9
9
  ivcap_lambda/py.typed,sha256=8ZJUsxZiuOy1oJeVhsTWQhTG_6pTVHVXk5hJL79ebTk,25
10
10
  ivcap_lambda/secret.py,sha256=iLXhuA0rfXLIlahVp7htk9_MF5mpfccLa6gqCp-OAEs,1300
11
- ivcap_lambda/server.py,sha256=kGsOt0X1MXoRfkNSCTXAoP-oyo4n_XCKcYYiOsukcvY,8190
12
- ivcap_lambda/service_definition.py,sha256=cMG8giYMUotUXeR_EIIeTIP9pk9f_e8_4Uj-FIWe_Lg,1645
11
+ ivcap_lambda/server.py,sha256=ppoRB4_4Ql0u2qG585SlMMT0qgyr7XKoCDRgBC8T7gg,8892
12
+ ivcap_lambda/service_definition.py,sha256=wISQAzzhiSJeNaImPTWJQ0nt4-mkyDXwDfqczIhhd9s,2015
13
13
  ivcap_lambda/utils.py,sha256=PIb-f8Jua0hwt-77kfWX2h7hfVmN2C_FaUTyjoCQVvI,3084
14
14
  ivcap_lambda/version.py,sha256=doCn_9Qf-MMhIb5a7LaVxn3YDfU0SVH2QebEUTYe8zg,610
15
- ivcap_lambda-0.8.2.dist-info/METADATA,sha256=XHnNUL7MGJtkhGbcojmpyr3rbBUspKtQ5jFyru1VlYo,7358
16
- ivcap_lambda-0.8.2.dist-info/WHEEL,sha256=EGEvSphFYqXKs23-kQBeyNoJP1nrT8ZJKQoi5p5DYL8,88
17
- ivcap_lambda-0.8.2.dist-info/licenses/AUTHORS.md,sha256=s9xR4_HAHQgbNlj505LViebt5AtACQmhPf92aJvNYgg,88
18
- ivcap_lambda-0.8.2.dist-info/licenses/LICENSE,sha256=dsQrDPPwW7iJs9pxahgJKDW8RNPf5FyXG70MFUlxcuk,1587
19
- ivcap_lambda-0.8.2.dist-info/RECORD,,
15
+ ivcap_lambda-0.8.3.dist-info/METADATA,sha256=zmYAlHkJQp_4VkOF3HQF4XjycW6dxofIOKd0zEk3UeI,7358
16
+ ivcap_lambda-0.8.3.dist-info/WHEEL,sha256=EGEvSphFYqXKs23-kQBeyNoJP1nrT8ZJKQoi5p5DYL8,88
17
+ ivcap_lambda-0.8.3.dist-info/licenses/AUTHORS.md,sha256=s9xR4_HAHQgbNlj505LViebt5AtACQmhPf92aJvNYgg,88
18
+ ivcap_lambda-0.8.3.dist-info/licenses/LICENSE,sha256=dsQrDPPwW7iJs9pxahgJKDW8RNPf5FyXG70MFUlxcuk,1587
19
+ ivcap_lambda-0.8.3.dist-info/RECORD,,