jcmsuite 7.4.2__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.

Potentially problematic release.


This version of jcmsuite might be problematic. Click here for more details.

Files changed (119) hide show
  1. jcmsuite/__init__.py +22 -0
  2. jcmsuite/_build_info.py +4 -0
  3. jcmsuite/context/__init__.py +44 -0
  4. jcmsuite/context/interface_metadata.py +158 -0
  5. jcmsuite/context/models.py +213 -0
  6. jcmsuite/context/scope.py +210 -0
  7. jcmsuite/context/solver_context.py +569 -0
  8. jcmsuite/context/subprocess_tools.py +172 -0
  9. jcmsuite/contract.py +47 -0
  10. jcmsuite/daemon/__init__.py +19 -0
  11. jcmsuite/daemon/handler.py +925 -0
  12. jcmsuite/daemon/internal/__init__.py +4 -0
  13. jcmsuite/daemon/internal/bundle_protocol.py +64 -0
  14. jcmsuite/daemon/internal/handler_helpers.py +368 -0
  15. jcmsuite/daemon/internal/handler_resource_jobs.py +227 -0
  16. jcmsuite/daemon/internal/handler_wait.py +564 -0
  17. jcmsuite/daemon/models.py +349 -0
  18. jcmsuite/daemon/namespaces.py +250 -0
  19. jcmsuite/daemon/protocol.py +801 -0
  20. jcmsuite/daemon/resources.py +407 -0
  21. jcmsuite/daemon/scope.py +53 -0
  22. jcmsuite/daemon/transport.py +223 -0
  23. jcmsuite/editing/__init__.py +10 -0
  24. jcmsuite/editing/editor.py +274 -0
  25. jcmsuite/exceptions/__init__.py +32 -0
  26. jcmsuite/exceptions/errors.py +173 -0
  27. jcmsuite/geo/__init__.py +10 -0
  28. jcmsuite/geo/mesh.py +302 -0
  29. jcmsuite/info/__init__.py +10 -0
  30. jcmsuite/info/runtime_info.py +45 -0
  31. jcmsuite/internal/__init__.py +2 -0
  32. jcmsuite/internal/diagnostics.py +74 -0
  33. jcmsuite/internal/progress.py +80 -0
  34. jcmsuite/loaders/__init__.py +18 -0
  35. jcmsuite/loaders/blob_header.py +315 -0
  36. jcmsuite/loaders/cartesian_field_reader.py +249 -0
  37. jcmsuite/loaders/cartesian_fields.py +324 -0
  38. jcmsuite/loaders/nested_mapping.py +69 -0
  39. jcmsuite/loaders/powerflux.py +136 -0
  40. jcmsuite/loaders/table.py +637 -0
  41. jcmsuite/logging/__init__.py +22 -0
  42. jcmsuite/logging/runtime.py +210 -0
  43. jcmsuite/results/__init__.py +126 -0
  44. jcmsuite/results/artifacts.py +806 -0
  45. jcmsuite/results/discovery.py +82 -0
  46. jcmsuite/results/field_exports.py +1062 -0
  47. jcmsuite/results/field_payloads.py +453 -0
  48. jcmsuite/results/internal/__init__.py +4 -0
  49. jcmsuite/results/internal/export/__init__.py +4 -0
  50. jcmsuite/results/internal/export/common.py +56 -0
  51. jcmsuite/results/internal/export/pandas/__init__.py +4 -0
  52. jcmsuite/results/internal/export/pandas/common.py +165 -0
  53. jcmsuite/results/internal/export/pandas/payload.py +480 -0
  54. jcmsuite/results/internal/export/pandas/rows.py +484 -0
  55. jcmsuite/results/internal/export/preview.py +178 -0
  56. jcmsuite/results/internal/export/xarray/__init__.py +4 -0
  57. jcmsuite/results/internal/export/xarray/export.py +688 -0
  58. jcmsuite/results/internal/export/xarray/grouped.py +608 -0
  59. jcmsuite/results/internal/export/xarray/headers.py +290 -0
  60. jcmsuite/results/internal/export/xarray/runtime.py +99 -0
  61. jcmsuite/results/internal/export/xarray/shared.py +246 -0
  62. jcmsuite/results/internal/export/xarray/tabular.py +304 -0
  63. jcmsuite/results/internal/export/xarray/types.py +28 -0
  64. jcmsuite/results/internal/models/__init__.py +4 -0
  65. jcmsuite/results/internal/models/batch.py +1081 -0
  66. jcmsuite/results/internal/models/batch_postprocess.py +1728 -0
  67. jcmsuite/results/internal/models/bundle.py +343 -0
  68. jcmsuite/results/internal/models/core.py +556 -0
  69. jcmsuite/results/internal/models/submission.py +1157 -0
  70. jcmsuite/results/internal/resultbag/__init__.py +4 -0
  71. jcmsuite/results/internal/resultbag/access.py +489 -0
  72. jcmsuite/results/internal/resultbag/iteration.py +199 -0
  73. jcmsuite/results/internal/resultbag/query.py +226 -0
  74. jcmsuite/results/internal/resultbag/raw.py +407 -0
  75. jcmsuite/results/internal/resultbag/source_files.py +142 -0
  76. jcmsuite/results/internal/resultbag/store.py +881 -0
  77. jcmsuite/results/internal/resultbag/utils.py +258 -0
  78. jcmsuite/results/models.py +76 -0
  79. jcmsuite/results/opening.py +55 -0
  80. jcmsuite/results/pandas_export.py +325 -0
  81. jcmsuite/results/payloads.py +478 -0
  82. jcmsuite/results/postprocess.py +97 -0
  83. jcmsuite/results/postprocess_payloads.py +757 -0
  84. jcmsuite/results/postprocess_record.py +418 -0
  85. jcmsuite/results/resultbag.py +279 -0
  86. jcmsuite/results/resultbag_management.py +433 -0
  87. jcmsuite/results/structured_derivatives.py +387 -0
  88. jcmsuite/solve/__init__.py +10 -0
  89. jcmsuite/solve/daemon_bundle_staging.py +100 -0
  90. jcmsuite/solve/daemon_bundle_wait.py +89 -0
  91. jcmsuite/solve/orchestration.py +1576 -0
  92. jcmsuite/solve/orchestration_execution.py +180 -0
  93. jcmsuite/solve/orchestration_routing.py +128 -0
  94. jcmsuite/solve/orchestration_support.py +323 -0
  95. jcmsuite/solve/path_resolution.py +98 -0
  96. jcmsuite/solve/progress.py +20 -0
  97. jcmsuite/solve/solver.py +709 -0
  98. jcmsuite/solve/staging.py +264 -0
  99. jcmsuite/solve/types.py +25 -0
  100. jcmsuite/solve/working_dirs.py +227 -0
  101. jcmsuite/templates/__init__.py +11 -0
  102. jcmsuite/templates/converter.py +71 -0
  103. jcmsuite/templates/formatting.py +335 -0
  104. jcmsuite/templates/formatting_cli.py +47 -0
  105. jcmsuite/templates/rendering.py +666 -0
  106. jcmsuite/torch/__init__.py +25 -0
  107. jcmsuite/torch/autograd.py +488 -0
  108. jcmsuite/torch/coordinate_policy.py +82 -0
  109. jcmsuite/torch/core.py +312 -0
  110. jcmsuite/torch/results/__init__.py +51 -0
  111. jcmsuite/torch/types.py +84 -0
  112. jcmsuite/torch/validation.py +208 -0
  113. jcmsuite/torch/wrappers.py +4332 -0
  114. jcmsuite/view/__init__.py +10 -0
  115. jcmsuite/view/viewer.py +122 -0
  116. jcmsuite-7.4.2.dist-info/METADATA +180 -0
  117. jcmsuite-7.4.2.dist-info/RECORD +119 -0
  118. jcmsuite-7.4.2.dist-info/WHEEL +4 -0
  119. jcmsuite-7.4.2.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,349 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # Copyright (c) 2001-2026 JCMwave GmbH
3
+
4
+ """Data models for daemon lifecycle state."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from dataclasses import dataclass, field
9
+ from pathlib import Path
10
+ from typing import TYPE_CHECKING, Literal
11
+
12
+ if TYPE_CHECKING:
13
+ from collections.abc import Sequence
14
+
15
+ from ..results import Resultbag
16
+
17
+
18
+ @dataclass(slots=True, frozen=True)
19
+ class ClusterNode:
20
+ """Describe one compute node in a cluster.
21
+
22
+ Parameters
23
+ ----------
24
+ hostname : str
25
+ Node name used from the cluster access host.
26
+ jcm_root : Path | str | None, optional
27
+ JCMsuite installation directory on this node. Pass a remote path as a
28
+ string; its spelling is preserved without client-side path resolution.
29
+ memory_limit_mb : int | None, optional
30
+ Maximum solver memory on this node in megabytes.
31
+ gpu : int | None, optional
32
+ Graphics processing unit (GPU) identifier to use on this node. One
33
+ `ClusterNode` can select one GPU. To select multiple GPUs on one node,
34
+ add one `ClusterNode` for each GPU identifier.
35
+ """
36
+
37
+ hostname: str
38
+ jcm_root: Path | str | None = None
39
+ memory_limit_mb: int | None = None
40
+ gpu: int | None = None
41
+
42
+
43
+ @dataclass(slots=True, frozen=True)
44
+ class Workstation:
45
+ """Describe a workstation that can run solves.
46
+
47
+ Parameters
48
+ ----------
49
+ hostname : str | Sequence[str]
50
+ Workstation name. For a connection through other hosts, give the host
51
+ names in connection order.
52
+ login : str | Sequence[str | None] | None, optional
53
+ User name for each host in the connection path.
54
+ ssh_client : str | Sequence[str | None] | None, optional
55
+ Secure Shell (SSH) program for each host in the connection path.
56
+ pem_file : Path | str | Sequence[Path | str | None] | None, optional
57
+ SSH private-key file in PEM format for each host in the connection
58
+ path.
59
+ ssh_agent_forwarding : bool | None, optional
60
+ If `True`, enable SSH agent forwarding.
61
+ ssh_timeout_s : int | None, optional
62
+ SSH connection timeout in seconds.
63
+ jcm_root : Path | str | None, optional
64
+ JCMsuite installation directory on the workstation. Pass a remote path as a
65
+ string; its spelling is preserved without client-side path resolution.
66
+ multiplicity : int, optional
67
+ Maximum number of solves that can run at the same time.
68
+ n_threads : int, optional
69
+ Number of solver threads for each solve.
70
+ gpus : Literal["all", "no"] | int | Sequence[int] | None, optional
71
+ GPUs to use. Use `"all"` for all available GPUs. Use `"no"` to disable
72
+ GPU use. Give one identifier or an ordered collection of identifiers
73
+ to select specific GPUs.
74
+ working_dir : Path | str, optional
75
+ Directory in which the workstation runs solves.
76
+ ooc_dir : Path | str | None, optional
77
+ Optional out-of-core directory.
78
+ max_core_size_mb : int | None, optional
79
+ Maximum memory for each solver core in megabytes.
80
+ memory_limit_mb : int | None, optional
81
+ Maximum total solver memory in megabytes.
82
+ license_server_port : int | None, optional
83
+ Network port for license-server forwarding.
84
+ """
85
+
86
+ hostname: str | Sequence[str]
87
+ login: str | Sequence[str | None] | None = None
88
+ ssh_client: str | Sequence[str | None] | None = None
89
+ pem_file: Path | str | Sequence[Path | str | None] | None = None
90
+ ssh_agent_forwarding: bool | None = None
91
+ ssh_timeout_s: int | None = None
92
+ jcm_root: Path | str | None = None
93
+ multiplicity: int = 1
94
+ n_threads: int = 1
95
+ gpus: Literal["all", "no"] | int | Sequence[int] | None = None
96
+ working_dir: Path | str = ""
97
+ ooc_dir: Path | str | None = None
98
+ max_core_size_mb: int | None = None
99
+ memory_limit_mb: int | None = None
100
+ license_server_port: int | None = None
101
+
102
+
103
+ @dataclass(slots=True, frozen=True)
104
+ class Cluster:
105
+ """Describe a cluster that can run solves.
106
+
107
+ Parameters
108
+ ----------
109
+ hostname : str | Sequence[str]
110
+ Cluster access host. For a connection through other hosts, give the
111
+ host names in connection order.
112
+ nodes : Sequence[ClusterNode]
113
+ Compute nodes that belong to the cluster.
114
+ login : str | Sequence[str | None] | None, optional
115
+ User name for each host in the connection path.
116
+ ssh_client : str | Sequence[str | None] | None, optional
117
+ Secure Shell (SSH) program for each host in the connection path.
118
+ pem_file : Path | str | Sequence[Path | str | None] | None, optional
119
+ SSH private-key file in PEM format for each host in the connection
120
+ path.
121
+ ssh_agent_forwarding : bool | None, optional
122
+ Enable or disable SSH agent forwarding.
123
+ ssh_timeout_s : int | None, optional
124
+ SSH connection timeout in seconds.
125
+ jcm_root : Path | str | None, optional
126
+ JCMsuite installation root on the cluster. Pass a remote path as a
127
+ string; its spelling is preserved without client-side path resolution.
128
+ multiplicity : int, optional
129
+ Maximum number of solves that can run at the same time.
130
+ n_threads : int, optional
131
+ Number of threads for each submitted solve.
132
+ working_dir : Path | str, optional
133
+ Working directory on the cluster.
134
+ ooc_dir : Path | str | None, optional
135
+ Out-of-core directory on the cluster.
136
+ max_core_size_mb : int | None, optional
137
+ Maximum memory for each solver core in megabytes.
138
+ license_server_port : int | None, optional
139
+ Port for license-server forwarding.
140
+ """
141
+
142
+ hostname: str | Sequence[str]
143
+ nodes: Sequence[ClusterNode]
144
+ login: str | Sequence[str | None] | None = None
145
+ ssh_client: str | Sequence[str | None] | None = None
146
+ pem_file: Path | str | Sequence[Path | str | None] | None = None
147
+ ssh_agent_forwarding: bool | None = None
148
+ ssh_timeout_s: int | None = None
149
+ jcm_root: Path | str | None = None
150
+ multiplicity: int = 1
151
+ n_threads: int = 1
152
+ working_dir: Path | str = ""
153
+ ooc_dir: Path | str | None = None
154
+ max_core_size_mb: int | None = None
155
+ license_server_port: int | None = None
156
+
157
+
158
+ @dataclass(slots=True, frozen=True)
159
+ class Queue:
160
+ """Describe a SLURM queue that can run solves.
161
+
162
+ Parameters
163
+ ----------
164
+ hostname : str | Sequence[str]
165
+ Queue access host. For a connection through other hosts, give the host
166
+ names in connection order.
167
+ queue_type : {"slurm"}, optional
168
+ Queue scheduler type.
169
+ login : str | Sequence[str | None] | None, optional
170
+ User name for each host in the connection path.
171
+ ssh_client : str | Sequence[str | None] | None, optional
172
+ Secure Shell (SSH) program for each host in the connection path.
173
+ pem_file : Path | str | Sequence[Path | str | None] | None, optional
174
+ SSH private-key file in PEM format for each host in the connection
175
+ path.
176
+ ssh_agent_forwarding : bool | None, optional
177
+ Enable or disable SSH agent forwarding.
178
+ ssh_timeout_s : int | None, optional
179
+ SSH connection timeout in seconds.
180
+ jcm_root : Path | str | None, optional
181
+ JCMsuite installation root on the queue system. Pass a remote path as a
182
+ string; its spelling is preserved without client-side path resolution.
183
+ multiplicity : int, optional
184
+ Maximum number of solves that can run at the same time.
185
+ account : str, optional
186
+ SLURM account name.
187
+ job_name : str, optional
188
+ SLURM job name.
189
+ partition_name : str, optional
190
+ SLURM partition name.
191
+ n_nodes : int | None, optional
192
+ Number of requested nodes.
193
+ n_tasks : int | None, optional
194
+ Number of requested tasks.
195
+ n_tasks_per_node : int | None, optional
196
+ Number of requested tasks on each node.
197
+ node_list : str, optional
198
+ SLURM node-list expression.
199
+ exclude_node : str, optional
200
+ SLURM node-exclusion expression.
201
+ cmd_line_args : str, optional
202
+ Additional options for the SLURM command.
203
+ working_dir : Path | str, optional
204
+ Working directory on the queue system.
205
+ n_threads : int, optional
206
+ Number of threads for each submitted solve.
207
+ gpu_type : str | None, optional
208
+ Requested GPU type.
209
+ n_gpus : int | None, optional
210
+ Number of requested GPUs.
211
+ gres : str | None, optional
212
+ SLURM generic resource (GRES) setting.
213
+ time_minutes : float | int | None, optional
214
+ Queue time limit in minutes.
215
+ features : str | None, optional
216
+ Required SLURM node features.
217
+ exclusive : bool | None, optional
218
+ Request exclusive node allocation.
219
+ memory_per_job_mb : int | None, optional
220
+ Memory limit for each job in megabytes.
221
+ ooc_dir : Path | str | None, optional
222
+ Out-of-core directory on the queue system.
223
+ max_core_size_mb : int | None, optional
224
+ Maximum memory for each solver core in megabytes.
225
+ environment : str | None, optional
226
+ Environment setup command or script.
227
+ remote_daemon_port : int | None, optional
228
+ Port of an existing remote daemon.
229
+ remote_daemon_signature : str | None, optional
230
+ Signature of an existing remote daemon.
231
+ """
232
+
233
+ hostname: str | Sequence[str]
234
+ queue_type: Literal["slurm"] = "slurm"
235
+ login: str | Sequence[str | None] | None = None
236
+ ssh_client: str | Sequence[str | None] | None = None
237
+ pem_file: Path | str | Sequence[Path | str | None] | None = None
238
+ ssh_agent_forwarding: bool | None = None
239
+ ssh_timeout_s: int | None = None
240
+ jcm_root: Path | str | None = None
241
+ multiplicity: int = 10
242
+ account: str = ""
243
+ job_name: str = ""
244
+ partition_name: str = ""
245
+ n_nodes: int | None = None
246
+ n_tasks: int | None = None
247
+ n_tasks_per_node: int | None = None
248
+ node_list: str = ""
249
+ exclude_node: str = ""
250
+ cmd_line_args: str = ""
251
+ working_dir: Path | str = ""
252
+ n_threads: int = 1
253
+ gpu_type: str | None = None
254
+ n_gpus: int | None = None
255
+ gres: str | None = None
256
+ time_minutes: float | int | None = None
257
+ features: str | None = None
258
+ exclusive: bool | None = None
259
+ memory_per_job_mb: int | None = None
260
+ ooc_dir: Path | str | None = None
261
+ max_core_size_mb: int | None = None
262
+ environment: str | None = None
263
+ remote_daemon_port: int | None = None
264
+ remote_daemon_signature: str | None = None
265
+
266
+
267
+ @dataclass(slots=True, frozen=True)
268
+ class SlurmNodes:
269
+ """Use compute nodes from the current SLURM allocation.
270
+
271
+ Parameters
272
+ ----------
273
+ task_ids : Sequence[int] | set[int] | int | None, optional
274
+ SLURM task identifiers to use. If omitted, use the current allocation.
275
+ cluster : bool, optional
276
+ If `True`, use the allocation as one Message Passing Interface (MPI)
277
+ cluster. If `False`, use the allocation as separate workers.
278
+
279
+ Notes
280
+ -----
281
+ The daemon registers this resource on `localhost` and uses one scheduler
282
+ slot. These settings cannot be changed.
283
+ """
284
+
285
+ task_ids: Sequence[int] | set[int] | int | None = None
286
+ cluster: bool = False
287
+ hostname: str = field(default="localhost", init=False)
288
+ multiplicity: int = field(default=1, init=False)
289
+ n_threads: int = field(default=1, init=False)
290
+
291
+
292
+ type DaemonResource = Workstation | Cluster | Queue | SlurmNodes
293
+
294
+
295
+ @dataclass(slots=True, frozen=True)
296
+ class DaemonStatus:
297
+ """Daemon status snapshot.
298
+
299
+ Parameters
300
+ ----------
301
+ started : bool
302
+ Whether the daemon lifecycle has been started.
303
+ connected : bool
304
+ Whether the handler currently represents an active daemon connection.
305
+ resources : tuple[DaemonResource, ...]
306
+ Configured resources known to this handler.
307
+ daemon_payload : object | None
308
+ Optional raw status payload returned by the daemon backend.
309
+ """
310
+
311
+ started: bool
312
+ """Whether the daemon lifecycle has been started."""
313
+ connected: bool
314
+ """Whether the handler represents an active daemon connection."""
315
+ resources: tuple[DaemonResource, ...]
316
+ """Configured resources known to this handler."""
317
+ daemon_payload: object | None = None
318
+ """Optional raw status payload returned by the daemon backend."""
319
+
320
+ @property
321
+ def resource_count(self) -> int:
322
+ """Return number of configured resources."""
323
+
324
+ return len(self.resources)
325
+
326
+
327
+ @dataclass(slots=True)
328
+ class PendingDaemonJob:
329
+ """Tracked daemon submission metadata used for wait/resultbag wiring.
330
+
331
+ Parameters
332
+ ----------
333
+ result : object
334
+ Result object returned by `solve(...)` at submit time.
335
+ keys : dict[str, object] | None
336
+ Optional key payload associated with this job submission.
337
+ resultbag : Resultbag | None
338
+ Optional resultbag receiving final result/log payload on wait.
339
+ suffix_pattern : str | None, optional
340
+ Optional suffix pattern for the persisted result.
341
+ source_project_mappings : tuple[tuple[Path, Path], ...], optional
342
+ Prepared project paths and their original input paths.
343
+ """
344
+
345
+ result: object
346
+ keys: dict[str, object] | None
347
+ resultbag: Resultbag | None
348
+ suffix_pattern: str | None = None
349
+ source_project_mappings: tuple[tuple[Path, Path], ...] = ()
@@ -0,0 +1,250 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # Copyright (c) 2001-2026 JCMwave GmbH
3
+
4
+ """Daemon namespaced API facades."""
5
+
6
+ from __future__ import annotations
7
+
8
+ from collections.abc import Coroutine, Sequence
9
+ from typing import TYPE_CHECKING, Literal, overload
10
+
11
+ if TYPE_CHECKING:
12
+ from ..results import (
13
+ BatchSolveResult,
14
+ BatchSolveSubmission,
15
+ SolveResult,
16
+ SolveSubmission,
17
+ )
18
+ from .handler import DaemonHandler
19
+ from .models import DaemonStatus
20
+
21
+
22
+ class DaemonLifecycle:
23
+ """Lifecycle namespace facade."""
24
+
25
+ def __init__(self, *, handler: DaemonHandler) -> None:
26
+
27
+ self._handler: DaemonHandler = handler
28
+
29
+ def startup(self) -> None:
30
+ """Start the daemon and connect the handler.
31
+
32
+ Returns
33
+ -------
34
+ None
35
+ The handler is connected to the running daemon.
36
+ """
37
+
38
+ self._handler.start()
39
+ self._handler.connect()
40
+
41
+ def shutdown(self) -> None:
42
+ """Disconnect and stop the daemon.
43
+
44
+ Returns
45
+ -------
46
+ None
47
+ The daemon is stopped.
48
+ """
49
+
50
+ self._handler.shutdown()
51
+
52
+ def status(self) -> DaemonStatus:
53
+ """Return the current daemon status.
54
+
55
+ Returns
56
+ -------
57
+ DaemonStatus
58
+ Information about the connection and registered resources.
59
+ """
60
+
61
+ return self._handler.status()
62
+
63
+
64
+ class DaemonJobs:
65
+ """Jobs namespace facade."""
66
+
67
+ def __init__(self, *, handler: DaemonHandler) -> None:
68
+
69
+ self._handler: DaemonHandler = handler
70
+
71
+ @overload
72
+ def wait(
73
+ self,
74
+ submission: SolveSubmission,
75
+ *,
76
+ asynchronous: Literal[False] = False,
77
+ break_when: Literal["all", "any"] = "all",
78
+ timeout: float | None = None,
79
+ on_timeout: Literal["raise", "return"] = "raise",
80
+ on_error: Literal["raise", "collect"] = "raise",
81
+ progress: bool = False,
82
+ progress_label: str | None = None,
83
+ ) -> SolveResult: ...
84
+
85
+ @overload
86
+ def wait(
87
+ self,
88
+ submission: BatchSolveSubmission,
89
+ *,
90
+ asynchronous: Literal[False] = False,
91
+ break_when: Literal["all", "any"] = "all",
92
+ timeout: float | None = None,
93
+ on_timeout: Literal["raise", "return"] = "raise",
94
+ on_error: Literal["raise", "collect"] = "raise",
95
+ progress: bool = False,
96
+ progress_label: str | None = None,
97
+ ) -> BatchSolveResult: ...
98
+
99
+ @overload
100
+ def wait(
101
+ self,
102
+ submission: SolveSubmission,
103
+ *,
104
+ asynchronous: Literal[True],
105
+ break_when: Literal["all", "any"] = "all",
106
+ timeout: float | None = None,
107
+ on_timeout: Literal["raise", "return"] = "raise",
108
+ on_error: Literal["raise", "collect"] = "raise",
109
+ progress: bool = False,
110
+ progress_label: str | None = None,
111
+ ) -> Coroutine[object, object, SolveResult]: ...
112
+
113
+ @overload
114
+ def wait(
115
+ self,
116
+ submission: BatchSolveSubmission,
117
+ *,
118
+ asynchronous: Literal[True],
119
+ break_when: Literal["all", "any"] = "all",
120
+ timeout: float | None = None,
121
+ on_timeout: Literal["raise", "return"] = "raise",
122
+ on_error: Literal["raise", "collect"] = "raise",
123
+ progress: bool = False,
124
+ progress_label: str | None = None,
125
+ ) -> Coroutine[object, object, BatchSolveResult]: ...
126
+
127
+ def wait(
128
+ self,
129
+ submission: SolveSubmission | BatchSolveSubmission,
130
+ *,
131
+ asynchronous: bool = False,
132
+ break_when: Literal["all", "any"] = "all",
133
+ timeout: float | None = None,
134
+ on_timeout: Literal["raise", "return"] = "raise",
135
+ on_error: Literal["raise", "collect"] = "raise",
136
+ progress: bool = False,
137
+ progress_label: str | None = None,
138
+ ) -> (
139
+ SolveResult
140
+ | BatchSolveResult
141
+ | Coroutine[object, object, SolveResult | BatchSolveResult]
142
+ ):
143
+ """Wait for a daemon submission and return its results.
144
+
145
+ Parameters
146
+ ----------
147
+ submission : SolveSubmission | BatchSolveSubmission
148
+ submission returned by `solve(..., dispatch="submit")`.
149
+ asynchronous : bool, optional
150
+ If `True`, return a value that you must use with `await`.
151
+ break_when : {"all", "any"}, optional
152
+ Condition that ends a batch wait. `"all"` waits for all requested
153
+ solves. `"any"` returns after the first requested solve finishes.
154
+ timeout : float | None, optional
155
+ Maximum number of seconds to wait. If omitted, wait without a time
156
+ limit.
157
+ on_timeout : {"raise", "return"}, optional
158
+ Action at the time limit. `"raise"` raises an error. `"return"`
159
+ returns the results that are available.
160
+ on_error : {"raise", "collect"}, optional
161
+ Action for a failed batch entry. `"raise"` raises an error.
162
+ `"collect"` stores a `BatchSolveFailure` in the batch result.
163
+ progress : bool, optional
164
+ If `True`, show progress while waiting for a batch.
165
+ progress_label : str | None, optional
166
+ Text to show with the progress display. If omitted, use
167
+ `"daemon.wait"`.
168
+
169
+ Returns
170
+ -------
171
+ SolveResult | BatchSolveResult | Coroutine[...]
172
+ Result that matches the submission. If `asynchronous=True`, return
173
+ a value that you must use with `await`.
174
+ """
175
+
176
+ if asynchronous:
177
+ return self._handler.wait(
178
+ submission=submission,
179
+ asynchronous=True,
180
+ break_when=break_when,
181
+ timeout=timeout,
182
+ on_timeout=on_timeout,
183
+ on_error=on_error,
184
+ progress=progress,
185
+ progress_label=progress_label,
186
+ )
187
+ return self._handler.wait(
188
+ submission=submission,
189
+ asynchronous=False,
190
+ break_when=break_when,
191
+ timeout=timeout,
192
+ on_timeout=on_timeout,
193
+ on_error=on_error,
194
+ progress=progress,
195
+ progress_label=progress_label,
196
+ )
197
+
198
+ def info(
199
+ self,
200
+ job_ids: Sequence[str | int] | None = None,
201
+ *,
202
+ status_only: bool = False,
203
+ ) -> object:
204
+ """Return information about submitted daemon solves.
205
+
206
+ Parameters
207
+ ----------
208
+ job_ids : Sequence[str | int] | None, optional
209
+ Daemon submission identifiers to select. If omitted, select all known
210
+ daemon submissions.
211
+ status_only : bool, optional
212
+ If `True`, request only status information when the daemon supports
213
+ this option.
214
+
215
+ Returns
216
+ -------
217
+ object
218
+ Information supplied by the daemon. The available fields depend on
219
+ the daemon version.
220
+ """
221
+
222
+ return self._handler._job_info_impl( # noqa: SLF001
223
+ job_ids=job_ids,
224
+ status_only=status_only,
225
+ )
226
+
227
+ def kill(self, job_ids: Sequence[str | int] | None = None) -> tuple[int, ...]:
228
+ """Stop submitted daemon solves.
229
+
230
+ Parameters
231
+ ----------
232
+ job_ids : Sequence[str | int] | None, optional
233
+ Daemon submission identifiers to stop. If omitted, stop all known daemon
234
+ submissions.
235
+
236
+ Returns
237
+ -------
238
+ tuple[int, ...]
239
+ Identifiers of the stopped daemon jobs.
240
+ """
241
+
242
+ return self._handler._kill_jobs_impl(job_ids=job_ids) # noqa: SLF001
243
+
244
+
245
+ class DaemonEnvironment:
246
+ """Environment namespace facade."""
247
+
248
+ def __init__(self, *, handler: DaemonHandler) -> None:
249
+
250
+ self._handler: DaemonHandler = handler