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,709 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # Copyright (c) 2001-2026 JCMwave GmbH
3
+
4
+ """Public solve entrypoint for `jcmsuite`."""
5
+
6
+ from __future__ import annotations
7
+
8
+ import asyncio
9
+ from collections.abc import Coroutine
10
+ from pathlib import Path
11
+ from typing import Literal, overload
12
+
13
+ from ..context import BackendMode, SolverContext
14
+ from ..exceptions import SolveExecutionError, SourceMappingError
15
+ from ..internal.diagnostics import trim_exception_traceback
16
+ from ..results import (
17
+ BatchSolveResult,
18
+ BatchSolveSubmission,
19
+ BundledBatchSolveResult,
20
+ BundledBatchSolveSubmission,
21
+ BundledSolveResult,
22
+ BundledSolveSubmission,
23
+ Resultbag,
24
+ SolveResult,
25
+ SolveSubmission,
26
+ )
27
+ from .orchestration import solve_impl
28
+ from .path_resolution import resolve_solve_call_site_file
29
+ from .types import (
30
+ BatchOnError,
31
+ BatchSolveKeysInput,
32
+ DispatchMode,
33
+ ProjectBundleInput,
34
+ ProjectPathInput,
35
+ SolveKeysInput,
36
+ SolveMode,
37
+ WaitBreakWhen,
38
+ WaitOnTimeout,
39
+ WorkingDirInput,
40
+ )
41
+
42
+
43
+ @overload
44
+ def solve(
45
+ project_file: ProjectPathInput,
46
+ *,
47
+ keys: SolveKeysInput = None,
48
+ resultbag: Resultbag | None = None,
49
+ recompute: bool = False,
50
+ max_retries: int = 0,
51
+ on_error: BatchOnError = "raise",
52
+ context: SolverContext | None = None,
53
+ backend: BackendMode | None = None,
54
+ working_dir: str | Path | None = None,
55
+ suffix_pattern: str | None = None,
56
+ temporary: bool = False,
57
+ dispatch: Literal["wait"] = "wait",
58
+ wait_break_when: WaitBreakWhen = "all",
59
+ wait_timeout: float | None = None,
60
+ wait_on_timeout: WaitOnTimeout = "raise",
61
+ wait_progress: bool = False,
62
+ wait_progress_label: str | None = None,
63
+ quiet: bool = False,
64
+ mode: SolveMode = "solve",
65
+ asynchronous: Literal[False] = False,
66
+ ) -> SolveResult: ...
67
+
68
+
69
+ @overload
70
+ def solve(
71
+ project_file: ProjectPathInput,
72
+ *,
73
+ keys: SolveKeysInput = None,
74
+ resultbag: Resultbag | None = None,
75
+ recompute: bool = False,
76
+ max_retries: int = 0,
77
+ on_error: BatchOnError = "raise",
78
+ context: SolverContext | None = None,
79
+ backend: BackendMode | None = None,
80
+ working_dir: str | Path | None = None,
81
+ suffix_pattern: str | None = None,
82
+ temporary: bool = False,
83
+ dispatch: Literal["submit"],
84
+ wait_break_when: WaitBreakWhen = "all",
85
+ wait_timeout: float | None = None,
86
+ wait_on_timeout: WaitOnTimeout = "raise",
87
+ wait_progress: bool = False,
88
+ wait_progress_label: str | None = None,
89
+ quiet: bool = False,
90
+ mode: SolveMode = "solve",
91
+ asynchronous: Literal[False] = False,
92
+ ) -> SolveSubmission: ...
93
+
94
+
95
+ @overload
96
+ def solve(
97
+ project_file: ProjectPathInput,
98
+ *,
99
+ keys: BatchSolveKeysInput,
100
+ resultbag: Resultbag | None = None,
101
+ recompute: bool = False,
102
+ max_retries: int = 0,
103
+ on_error: BatchOnError = "raise",
104
+ context: SolverContext | None = None,
105
+ backend: BackendMode | None = None,
106
+ working_dir: WorkingDirInput = None,
107
+ suffix_pattern: str | None = None,
108
+ temporary: bool = False,
109
+ dispatch: Literal["wait"] = "wait",
110
+ wait_break_when: WaitBreakWhen = "all",
111
+ wait_timeout: float | None = None,
112
+ wait_on_timeout: WaitOnTimeout = "raise",
113
+ wait_progress: bool = False,
114
+ wait_progress_label: str | None = None,
115
+ quiet: bool = False,
116
+ mode: SolveMode = "solve",
117
+ asynchronous: Literal[False] = False,
118
+ ) -> BatchSolveResult: ...
119
+
120
+
121
+ @overload
122
+ def solve(
123
+ project_file: ProjectPathInput,
124
+ *,
125
+ keys: BatchSolveKeysInput,
126
+ resultbag: Resultbag | None = None,
127
+ recompute: bool = False,
128
+ max_retries: int = 0,
129
+ on_error: BatchOnError = "raise",
130
+ context: SolverContext | None = None,
131
+ backend: BackendMode | None = None,
132
+ working_dir: WorkingDirInput = None,
133
+ suffix_pattern: str | None = None,
134
+ temporary: bool = False,
135
+ dispatch: Literal["submit"],
136
+ wait_break_when: WaitBreakWhen = "all",
137
+ wait_timeout: float | None = None,
138
+ wait_on_timeout: WaitOnTimeout = "raise",
139
+ wait_progress: bool = False,
140
+ wait_progress_label: str | None = None,
141
+ quiet: bool = False,
142
+ mode: SolveMode = "solve",
143
+ asynchronous: Literal[False] = False,
144
+ ) -> BatchSolveSubmission: ...
145
+
146
+
147
+ @overload
148
+ def solve(
149
+ project_file: ProjectPathInput,
150
+ *,
151
+ keys: SolveKeysInput = None,
152
+ resultbag: Resultbag | None = None,
153
+ recompute: bool = False,
154
+ max_retries: int = 0,
155
+ on_error: BatchOnError = "raise",
156
+ context: SolverContext | None = None,
157
+ backend: BackendMode | None = None,
158
+ working_dir: str | Path | None = None,
159
+ suffix_pattern: str | None = None,
160
+ temporary: bool = False,
161
+ dispatch: Literal["wait"] = "wait",
162
+ wait_break_when: WaitBreakWhen = "all",
163
+ wait_timeout: float | None = None,
164
+ wait_on_timeout: WaitOnTimeout = "raise",
165
+ wait_progress: bool = False,
166
+ wait_progress_label: str | None = None,
167
+ quiet: bool = False,
168
+ mode: SolveMode = "solve",
169
+ asynchronous: Literal[True],
170
+ ) -> Coroutine[object, object, SolveResult]: ...
171
+
172
+
173
+ @overload
174
+ def solve(
175
+ project_file: ProjectPathInput,
176
+ *,
177
+ keys: SolveKeysInput = None,
178
+ resultbag: Resultbag | None = None,
179
+ recompute: bool = False,
180
+ max_retries: int = 0,
181
+ on_error: BatchOnError = "raise",
182
+ context: SolverContext | None = None,
183
+ backend: BackendMode | None = None,
184
+ working_dir: str | Path | None = None,
185
+ suffix_pattern: str | None = None,
186
+ temporary: bool = False,
187
+ dispatch: Literal["submit"],
188
+ wait_break_when: WaitBreakWhen = "all",
189
+ wait_timeout: float | None = None,
190
+ wait_on_timeout: WaitOnTimeout = "raise",
191
+ wait_progress: bool = False,
192
+ wait_progress_label: str | None = None,
193
+ quiet: bool = False,
194
+ mode: SolveMode = "solve",
195
+ asynchronous: Literal[True],
196
+ ) -> Coroutine[object, object, SolveSubmission]: ...
197
+
198
+
199
+ @overload
200
+ def solve(
201
+ project_file: ProjectPathInput,
202
+ *,
203
+ keys: BatchSolveKeysInput,
204
+ resultbag: Resultbag | None = None,
205
+ recompute: bool = False,
206
+ max_retries: int = 0,
207
+ on_error: BatchOnError = "raise",
208
+ context: SolverContext | None = None,
209
+ backend: BackendMode | None = None,
210
+ working_dir: WorkingDirInput = None,
211
+ suffix_pattern: str | None = None,
212
+ temporary: bool = False,
213
+ dispatch: Literal["wait"] = "wait",
214
+ wait_break_when: WaitBreakWhen = "all",
215
+ wait_timeout: float | None = None,
216
+ wait_on_timeout: WaitOnTimeout = "raise",
217
+ wait_progress: bool = False,
218
+ wait_progress_label: str | None = None,
219
+ quiet: bool = False,
220
+ mode: SolveMode = "solve",
221
+ asynchronous: Literal[True],
222
+ ) -> Coroutine[object, object, BatchSolveResult]: ...
223
+
224
+
225
+ @overload
226
+ def solve(
227
+ project_file: ProjectPathInput,
228
+ *,
229
+ keys: BatchSolveKeysInput,
230
+ resultbag: Resultbag | None = None,
231
+ recompute: bool = False,
232
+ max_retries: int = 0,
233
+ on_error: BatchOnError = "raise",
234
+ context: SolverContext | None = None,
235
+ backend: BackendMode | None = None,
236
+ working_dir: WorkingDirInput = None,
237
+ suffix_pattern: str | None = None,
238
+ temporary: bool = False,
239
+ dispatch: Literal["submit"],
240
+ wait_break_when: WaitBreakWhen = "all",
241
+ wait_timeout: float | None = None,
242
+ wait_on_timeout: WaitOnTimeout = "raise",
243
+ wait_progress: bool = False,
244
+ wait_progress_label: str | None = None,
245
+ quiet: bool = False,
246
+ mode: SolveMode = "solve",
247
+ asynchronous: Literal[True],
248
+ ) -> Coroutine[object, object, BatchSolveSubmission]: ...
249
+
250
+
251
+ @overload
252
+ def solve(
253
+ project_file: ProjectBundleInput,
254
+ *,
255
+ keys: SolveKeysInput = None,
256
+ resultbag: Resultbag | None = None,
257
+ recompute: bool = False,
258
+ max_retries: int = 0,
259
+ on_error: BatchOnError = "raise",
260
+ context: SolverContext | None = None,
261
+ backend: BackendMode | None = None,
262
+ working_dir: str | Path | None = None,
263
+ suffix_pattern: str | None = None,
264
+ temporary: bool = False,
265
+ dispatch: Literal["wait"] = "wait",
266
+ wait_break_when: WaitBreakWhen = "all",
267
+ wait_timeout: float | None = None,
268
+ wait_on_timeout: WaitOnTimeout = "raise",
269
+ wait_progress: bool = False,
270
+ wait_progress_label: str | None = None,
271
+ quiet: bool = False,
272
+ mode: SolveMode = "solve",
273
+ asynchronous: Literal[False] = False,
274
+ ) -> BundledSolveResult: ...
275
+
276
+
277
+ @overload
278
+ def solve(
279
+ project_file: ProjectBundleInput,
280
+ *,
281
+ keys: SolveKeysInput = None,
282
+ resultbag: Resultbag | None = None,
283
+ recompute: bool = False,
284
+ max_retries: int = 0,
285
+ on_error: BatchOnError = "raise",
286
+ context: SolverContext | None = None,
287
+ backend: BackendMode | None = None,
288
+ working_dir: str | Path | None = None,
289
+ suffix_pattern: str | None = None,
290
+ temporary: bool = False,
291
+ dispatch: Literal["submit"],
292
+ wait_break_when: WaitBreakWhen = "all",
293
+ wait_timeout: float | None = None,
294
+ wait_on_timeout: WaitOnTimeout = "raise",
295
+ wait_progress: bool = False,
296
+ wait_progress_label: str | None = None,
297
+ quiet: bool = False,
298
+ mode: SolveMode = "solve",
299
+ asynchronous: Literal[False] = False,
300
+ ) -> BundledSolveSubmission: ...
301
+
302
+
303
+ @overload
304
+ def solve(
305
+ project_file: ProjectBundleInput,
306
+ *,
307
+ keys: BatchSolveKeysInput,
308
+ resultbag: Resultbag | None = None,
309
+ recompute: bool = False,
310
+ max_retries: int = 0,
311
+ on_error: BatchOnError = "raise",
312
+ context: SolverContext | None = None,
313
+ backend: BackendMode | None = None,
314
+ working_dir: WorkingDirInput = None,
315
+ suffix_pattern: str | None = None,
316
+ temporary: bool = False,
317
+ dispatch: Literal["wait"] = "wait",
318
+ wait_break_when: WaitBreakWhen = "all",
319
+ wait_timeout: float | None = None,
320
+ wait_on_timeout: WaitOnTimeout = "raise",
321
+ wait_progress: bool = False,
322
+ wait_progress_label: str | None = None,
323
+ quiet: bool = False,
324
+ mode: SolveMode = "solve",
325
+ asynchronous: Literal[False] = False,
326
+ ) -> BundledBatchSolveResult: ...
327
+
328
+
329
+ @overload
330
+ def solve(
331
+ project_file: ProjectBundleInput,
332
+ *,
333
+ keys: BatchSolveKeysInput,
334
+ resultbag: Resultbag | None = None,
335
+ recompute: bool = False,
336
+ max_retries: int = 0,
337
+ on_error: BatchOnError = "raise",
338
+ context: SolverContext | None = None,
339
+ backend: BackendMode | None = None,
340
+ working_dir: WorkingDirInput = None,
341
+ suffix_pattern: str | None = None,
342
+ temporary: bool = False,
343
+ dispatch: Literal["submit"],
344
+ wait_break_when: WaitBreakWhen = "all",
345
+ wait_timeout: float | None = None,
346
+ wait_on_timeout: WaitOnTimeout = "raise",
347
+ wait_progress: bool = False,
348
+ wait_progress_label: str | None = None,
349
+ quiet: bool = False,
350
+ mode: SolveMode = "solve",
351
+ asynchronous: Literal[False] = False,
352
+ ) -> BundledBatchSolveSubmission: ...
353
+
354
+
355
+ @overload
356
+ def solve(
357
+ project_file: ProjectBundleInput,
358
+ *,
359
+ keys: SolveKeysInput = None,
360
+ resultbag: Resultbag | None = None,
361
+ recompute: bool = False,
362
+ max_retries: int = 0,
363
+ on_error: BatchOnError = "raise",
364
+ context: SolverContext | None = None,
365
+ backend: BackendMode | None = None,
366
+ working_dir: str | Path | None = None,
367
+ suffix_pattern: str | None = None,
368
+ temporary: bool = False,
369
+ dispatch: Literal["wait"] = "wait",
370
+ wait_break_when: WaitBreakWhen = "all",
371
+ wait_timeout: float | None = None,
372
+ wait_on_timeout: WaitOnTimeout = "raise",
373
+ wait_progress: bool = False,
374
+ wait_progress_label: str | None = None,
375
+ quiet: bool = False,
376
+ mode: SolveMode = "solve",
377
+ asynchronous: Literal[True],
378
+ ) -> Coroutine[object, object, BundledSolveResult]: ...
379
+
380
+
381
+ @overload
382
+ def solve(
383
+ project_file: ProjectBundleInput,
384
+ *,
385
+ keys: BatchSolveKeysInput,
386
+ resultbag: Resultbag | None = None,
387
+ recompute: bool = False,
388
+ max_retries: int = 0,
389
+ on_error: BatchOnError = "raise",
390
+ context: SolverContext | None = None,
391
+ backend: BackendMode | None = None,
392
+ working_dir: WorkingDirInput = None,
393
+ suffix_pattern: str | None = None,
394
+ temporary: bool = False,
395
+ dispatch: Literal["submit"],
396
+ wait_break_when: WaitBreakWhen = "all",
397
+ wait_timeout: float | None = None,
398
+ wait_on_timeout: WaitOnTimeout = "raise",
399
+ wait_progress: bool = False,
400
+ wait_progress_label: str | None = None,
401
+ quiet: bool = False,
402
+ mode: SolveMode = "solve",
403
+ asynchronous: Literal[True],
404
+ ) -> Coroutine[object, object, BundledBatchSolveSubmission]: ...
405
+
406
+
407
+ @overload
408
+ def solve(
409
+ project_file: ProjectBundleInput,
410
+ *,
411
+ keys: SolveKeysInput = None,
412
+ resultbag: Resultbag | None = None,
413
+ recompute: bool = False,
414
+ max_retries: int = 0,
415
+ on_error: BatchOnError = "raise",
416
+ context: SolverContext | None = None,
417
+ backend: BackendMode | None = None,
418
+ working_dir: str | Path | None = None,
419
+ suffix_pattern: str | None = None,
420
+ temporary: bool = False,
421
+ dispatch: Literal["submit"],
422
+ wait_break_when: WaitBreakWhen = "all",
423
+ wait_timeout: float | None = None,
424
+ wait_on_timeout: WaitOnTimeout = "raise",
425
+ wait_progress: bool = False,
426
+ wait_progress_label: str | None = None,
427
+ quiet: bool = False,
428
+ mode: SolveMode = "solve",
429
+ asynchronous: Literal[True],
430
+ ) -> Coroutine[object, object, BundledSolveSubmission]: ...
431
+
432
+
433
+ @overload
434
+ def solve(
435
+ project_file: ProjectBundleInput,
436
+ *,
437
+ keys: BatchSolveKeysInput,
438
+ resultbag: Resultbag | None = None,
439
+ recompute: bool = False,
440
+ max_retries: int = 0,
441
+ on_error: BatchOnError = "raise",
442
+ context: SolverContext | None = None,
443
+ backend: BackendMode | None = None,
444
+ working_dir: WorkingDirInput = None,
445
+ suffix_pattern: str | None = None,
446
+ temporary: bool = False,
447
+ dispatch: Literal["wait"] = "wait",
448
+ wait_break_when: WaitBreakWhen = "all",
449
+ wait_timeout: float | None = None,
450
+ wait_on_timeout: WaitOnTimeout = "raise",
451
+ wait_progress: bool = False,
452
+ wait_progress_label: str | None = None,
453
+ quiet: bool = False,
454
+ mode: SolveMode = "solve",
455
+ asynchronous: Literal[True],
456
+ ) -> Coroutine[object, object, BundledBatchSolveResult]: ...
457
+
458
+
459
+ def solve(
460
+ project_file: ProjectPathInput | ProjectBundleInput,
461
+ *,
462
+ keys: SolveKeysInput | BatchSolveKeysInput = None,
463
+ resultbag: Resultbag | None = None,
464
+ recompute: bool = False,
465
+ max_retries: int = 0,
466
+ on_error: BatchOnError = "raise",
467
+ context: SolverContext | None = None,
468
+ backend: BackendMode | None = None,
469
+ working_dir: WorkingDirInput = None,
470
+ suffix_pattern: str | None = None,
471
+ temporary: bool = False,
472
+ dispatch: DispatchMode = "wait",
473
+ wait_break_when: WaitBreakWhen = "all",
474
+ wait_timeout: float | None = None,
475
+ wait_on_timeout: WaitOnTimeout = "raise",
476
+ wait_progress: bool = False,
477
+ wait_progress_label: str | None = None,
478
+ quiet: bool = False,
479
+ mode: SolveMode = "solve",
480
+ asynchronous: bool = False,
481
+ ) -> (
482
+ SolveResult
483
+ | BatchSolveResult
484
+ | BundledSolveResult
485
+ | BundledBatchSolveResult
486
+ | SolveSubmission
487
+ | BundledSolveSubmission
488
+ | BundledBatchSolveSubmission
489
+ | BatchSolveSubmission
490
+ | Coroutine[
491
+ object,
492
+ object,
493
+ SolveResult
494
+ | BatchSolveResult
495
+ | BundledSolveResult
496
+ | BundledBatchSolveResult
497
+ | SolveSubmission
498
+ | BundledSolveSubmission
499
+ | BundledBatchSolveSubmission
500
+ | BatchSolveSubmission,
501
+ ]
502
+ ):
503
+ """Solve one project or one ordered project bundle.
504
+
505
+ Parameters
506
+ ----------
507
+ project_file : str | Path | Sequence[str | Path]
508
+ project file (`.jcmp` or `.jcm`) or one ordered project bundle.
509
+ You can give an ordered project bundle as a list or tuple of project
510
+ files. JCMsuite runs the projects in the given order. If `keys`
511
+ contains batched project keys, JCMsuite runs the complete bundle for
512
+ each set of project keys. JCMsuite first resolves a relative path from
513
+ the Python file that calls `solve(...)`. If this is not possible, it
514
+ resolves the path from the current working directory.
515
+ keys : Mapping[str, object] | Sequence[Mapping[str, object]] | None, optional
516
+ One set of project keys, batched project keys, or `None` if the
517
+ project does not use project keys.
518
+ resultbag : Resultbag | None, optional
519
+ Resultbag in which to store and find results. An ordered project bundle
520
+ is one Resultbag entry for each set of project keys.
521
+ recompute : bool, optional
522
+ If `False`, reuse matching Resultbag entries. If `True`, run the solve
523
+ again.
524
+ max_retries : int, optional
525
+ Number of times to try a failed solve again. Use `0` to disable
526
+ retries. For a daemon-backed ordered project bundle, an execution
527
+ failure retries the complete bundle. A timeout does not resubmit the
528
+ bundle. This option requires `dispatch="wait"`.
529
+ on_error : {"raise", "collect"}, optional
530
+ Error policy for batched project keys. `"raise"` stops at the first
531
+ failed entry. `"collect"` stores failures as `BatchSolveFailure`
532
+ records and continues with the remaining entries.
533
+ context : SolverContext | None, optional
534
+ JCMsuite settings to use. If omitted, use the active context or the
535
+ default context.
536
+ backend : BackendMode | None, optional
537
+ Execution method to use. If omitted, use the method from `context`.
538
+ working_dir : WorkingDirInput, optional
539
+ Directory in which to run each solve. For batched project keys, give
540
+ one directory for each set of project keys. For a batch with one entry,
541
+ one directory is also valid. For an ordered project bundle, one
542
+ directory contains all project working directories. JCMsuite preserves
543
+ the relative project paths and copies shared project support files into
544
+ this directory. If you set `working_dir`, JCMsuite uses it even if
545
+ `temporary=True`. For a daemon-backed bundle batch, omitted directories
546
+ create separate temporary roots for uncached entries. Explicit live
547
+ roots must not overlap. If several entries execute, their roots must
548
+ not contain the source project files.
549
+ suffix_pattern : str | None, optional
550
+ Suffix pattern for project support files. The solve first tries
551
+ `name.<suffix>.jcmt` or `name.<suffix>.jcm`, then uses the unsuffixed
552
+ file.
553
+ temporary : bool, optional
554
+ If `True` and `working_dir` is omitted, create a temporary working
555
+ directory for each solve entry. If the context defines a temporary
556
+ directory root, the solve creates the directories below that root. If
557
+ `False` and `working_dir` is omitted, the solve runs in the project
558
+ directory, except for daemon-backed bundle batches, which use separate
559
+ temporary roots for uncached entries.
560
+ dispatch : {"wait", "submit"}, optional
561
+ Daemon return behavior. `"wait"` waits for the solve and returns its
562
+ result. `"submit"` returns a submission before the solve is complete.
563
+ For an ordered project bundle, both options submit the complete bundle
564
+ as one daemon job. `"submit"` returns its Submission after all projects
565
+ are prepared and submitted. A subsequent `wait()` collects the bundle
566
+ results without submitting further projects.
567
+ wait_break_when : {"all", "any"}, optional
568
+ Condition that ends a daemon wait. `"all"` waits for all requested
569
+ solves. `"any"` returns after the first requested solve finishes.
570
+ Daemon-backed ordered bundles and bundle batches require `"all"`.
571
+ wait_timeout : float | None, optional
572
+ Maximum number of seconds to wait for daemon results. If omitted, wait
573
+ without a time limit.
574
+ wait_on_timeout : {"raise", "return"}, optional
575
+ Action at the daemon time limit. `"raise"` raises an error. `"return"`
576
+ returns the results that are available. Daemon-backed ordered bundles
577
+ and bundle batches require `"raise"`.
578
+ wait_progress : bool, optional
579
+ If `True`, show progress while waiting for a batch.
580
+ wait_progress_label : str | None, optional
581
+ Text to show with the progress display. If omitted, use
582
+ `"daemon.wait"` for a daemon wait or `"solve(batch)"` for a local
583
+ batch.
584
+ quiet : bool, optional
585
+ If `True`, do not show output from a local solve.
586
+ mode : Literal["solve", "postprocess"], optional
587
+ Defaults to ``"solve"``; use ``"postprocess"`` to run only declared
588
+ postprocesses with accessible saved fieldbags.
589
+ Resultbag is not supported in postprocess mode.
590
+ asynchronous : bool, optional
591
+ If `True`, return a value that you must use with `await`.
592
+
593
+ Returns
594
+ -------
595
+ SolveResult | BatchSolveResult | BundledSolveResult | BundledBatchSolveResult | SolveSubmission | BatchSolveSubmission | BundledSolveSubmission | BundledBatchSolveSubmission | Coroutine[...]
596
+ One project with one set of project keys returns `SolveResult`. One
597
+ project with batched project keys returns `BatchSolveResult`. An
598
+ ordered project bundle returns `BundledSolveResult` or
599
+ `BundledBatchSolveResult`. If `dispatch="submit"`, the function returns
600
+ the corresponding submission. If `asynchronous=True`, the function
601
+ returns a value that you must use with `await`.
602
+
603
+ Raises
604
+ ------
605
+ RuntimeError
606
+ If asynchronous code calls the function without `asynchronous=True`.
607
+ SourceMappingError
608
+ If a template or JCMsuite input error identifies a source position.
609
+ SolveExecutionError
610
+ If JCMsuite reports a solve failure. The call trims internal traceback
611
+ frames and preserves the solver's diagnostic details.
612
+ InvalidConfigurationError
613
+ If the project input or option combination is not valid.
614
+ """
615
+
616
+ if asynchronous:
617
+ caller_file: Path | None = resolve_solve_call_site_file()
618
+
619
+ async def _solve_asynchronously() -> (
620
+ SolveResult
621
+ | BatchSolveResult
622
+ | BundledSolveResult
623
+ | BundledBatchSolveResult
624
+ | SolveSubmission
625
+ | BundledSolveSubmission
626
+ | BundledBatchSolveSubmission
627
+ | BatchSolveSubmission
628
+ ):
629
+ try:
630
+ return await solve_impl(
631
+ project_file=project_file,
632
+ caller_file=caller_file,
633
+ keys=keys,
634
+ resultbag=resultbag,
635
+ recompute=recompute,
636
+ max_retries=max_retries,
637
+ on_error=on_error,
638
+ context=context,
639
+ backend=backend,
640
+ working_dir=working_dir,
641
+ suffix_pattern=suffix_pattern,
642
+ temporary=temporary,
643
+ dispatch=dispatch,
644
+ wait_break_when=wait_break_when,
645
+ wait_timeout=wait_timeout,
646
+ wait_on_timeout=wait_on_timeout,
647
+ wait_progress=wait_progress,
648
+ wait_progress_label=wait_progress_label,
649
+ quiet=quiet,
650
+ mode=mode,
651
+ )
652
+ except SolveExecutionError as error:
653
+ raise trim_exception_traceback(error) from None
654
+ except SourceMappingError as error:
655
+ cause: BaseException | None = (
656
+ error.__cause__
657
+ if isinstance(error.__cause__, SolveExecutionError)
658
+ else None
659
+ )
660
+ raise trim_exception_traceback(error) from cause
661
+
662
+ return _solve_asynchronously()
663
+
664
+ try:
665
+ asyncio.get_running_loop()
666
+ except RuntimeError:
667
+ try:
668
+ caller_file = resolve_solve_call_site_file()
669
+ return asyncio.run(
670
+ solve_impl(
671
+ project_file=project_file,
672
+ caller_file=caller_file,
673
+ keys=keys,
674
+ resultbag=resultbag,
675
+ recompute=recompute,
676
+ max_retries=max_retries,
677
+ on_error=on_error,
678
+ context=context,
679
+ backend=backend,
680
+ working_dir=working_dir,
681
+ suffix_pattern=suffix_pattern,
682
+ temporary=temporary,
683
+ dispatch=dispatch,
684
+ wait_break_when=wait_break_when,
685
+ wait_timeout=wait_timeout,
686
+ wait_on_timeout=wait_on_timeout,
687
+ wait_progress=wait_progress,
688
+ wait_progress_label=wait_progress_label,
689
+ quiet=quiet,
690
+ mode=mode,
691
+ )
692
+ )
693
+ except SolveExecutionError as error:
694
+ # Keep solver diagnostics available while removing the internal
695
+ # async execution stack from the synchronous public boundary.
696
+ raise trim_exception_traceback(error) from None
697
+ except SourceMappingError as error:
698
+ # Keep user-facing diagnostics concise in sync mode by removing
699
+ # deep internal async/template call stacks.
700
+ cause: BaseException | None = (
701
+ error.__cause__
702
+ if isinstance(error.__cause__, SolveExecutionError)
703
+ else None
704
+ )
705
+ raise trim_exception_traceback(error) from cause
706
+
707
+ raise RuntimeError(
708
+ "solve() called from a running event loop; use `await solve(..., asynchronous=True)`."
709
+ )