ivcap-lambda 0.8.9__tar.gz → 0.8.10__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ivcap-lambda
3
- Version: 0.8.9
3
+ Version: 0.8.10
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
@@ -65,6 +65,10 @@ class ToolOptions(BaseModel):
65
65
  service_id: str | None = Field(
66
66
  None, description="overriding the default service id"
67
67
  )
68
+ service_timeout: int | None = Field(
69
+ None,
70
+ description="service timeout in seconds, included in the REST service description",
71
+ )
68
72
  is_ready: Callable[[], bool | dict[str, Any] | BaseModel] | None = Field(
69
73
  None,
70
74
  description=(
@@ -88,6 +92,7 @@ class ToolDescription:
88
92
  worker_fn: WorkerFn
89
93
  input: tuple[type[BaseModel] | None, dict[str, Any]]
90
94
  executor: Executor
95
+ service_timeout: int | None = None
91
96
 
92
97
 
93
98
  tools: list[ToolDescription] = []
@@ -155,6 +160,7 @@ def add_tool_api_route(
155
160
  worker_fn=worker_fn,
156
161
  input=get_input_type(worker_fn),
157
162
  executor=executor,
163
+ service_timeout=opts.service_timeout,
158
164
  )
159
165
  )
160
166
 
@@ -191,7 +191,11 @@ def start_lambda_server(
191
191
  tool_slug = tool.name.replace("_", "-")
192
192
  name = args.service_name or f"{service.name}-{tool_slug}"
193
193
  print_rest_service_definition(
194
- service, tool.worker_fn, name=name, path=tool.path_prefix
194
+ service,
195
+ tool.worker_fn,
196
+ name=name,
197
+ path=tool.path_prefix,
198
+ service_timeout=tool.service_timeout,
195
199
  )
196
200
  sys.exit(0)
197
201
 
@@ -26,6 +26,9 @@ class RestController(BaseModel):
26
26
  image: str
27
27
  command: list[str] | str
28
28
  resources: Resources = Field(default_factory=Resources)
29
+ service_timeout: int | None = Field(
30
+ default=None, description="service timeout in seconds"
31
+ )
29
32
 
30
33
  def print_rest_service_definition(
31
34
  service_description: Service,
@@ -33,6 +36,7 @@ def print_rest_service_definition(
33
36
  service_id: str | None = None,
34
37
  name: str | None = None,
35
38
  path: str | None = None,
39
+ service_timeout: int | None = None,
36
40
  ):
37
41
  sd = create_rest_service_definition(
38
42
  service_description,
@@ -40,6 +44,7 @@ def print_rest_service_definition(
40
44
  service_id=service_id,
41
45
  name=name,
42
46
  path=path,
47
+ service_timeout=service_timeout,
43
48
  )
44
49
  print(sd.model_dump_json(indent=2, by_alias=True, exclude_none=True))
45
50
 
@@ -49,13 +54,23 @@ def create_rest_service_definition(
49
54
  service_id: str | None = None,
50
55
  name: str | None = None,
51
56
  path: str | None = None,
57
+ service_timeout: int | None = None,
52
58
  ) -> ServiceDefinition:
53
59
  # controller
54
60
  image = os.getenv("DOCKER_IMG", IMAGE_PLACEHOLDER)
55
61
 
56
62
  command = find_command()
57
63
  resources = find_resources_file()
58
- controller = RestController(path=path, image=image, command=command, resources=resources)
64
+ env_timeout = os.getenv("IVCAP_SERVICE_TIMEOUT")
65
+ if env_timeout:
66
+ service_timeout = int(env_timeout)
67
+ controller = RestController(
68
+ path=path,
69
+ image=image,
70
+ command=command,
71
+ resources=resources,
72
+ service_timeout=service_timeout,
73
+ )
59
74
  if name is not None:
60
75
  service_description = service_description.model_copy(update={"name": name})
61
76
  return create_service_definition(service_description, fn, REST_CONTROLLER_SCHEMA, controller, service_id)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "ivcap-lambda"
3
- version = "0.8.9"
3
+ version = "0.8.10"
4
4
  description = "Helper functions for building lambda-style services on the IVCAP platform"
5
5
 
6
6
  authors = ["Max Ott <max.ott@csiro.au>"]
File without changes
File without changes
File without changes