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.
- jcmsuite/__init__.py +22 -0
- jcmsuite/_build_info.py +4 -0
- jcmsuite/context/__init__.py +44 -0
- jcmsuite/context/interface_metadata.py +158 -0
- jcmsuite/context/models.py +213 -0
- jcmsuite/context/scope.py +210 -0
- jcmsuite/context/solver_context.py +569 -0
- jcmsuite/context/subprocess_tools.py +172 -0
- jcmsuite/contract.py +47 -0
- jcmsuite/daemon/__init__.py +19 -0
- jcmsuite/daemon/handler.py +925 -0
- jcmsuite/daemon/internal/__init__.py +4 -0
- jcmsuite/daemon/internal/bundle_protocol.py +64 -0
- jcmsuite/daemon/internal/handler_helpers.py +368 -0
- jcmsuite/daemon/internal/handler_resource_jobs.py +227 -0
- jcmsuite/daemon/internal/handler_wait.py +564 -0
- jcmsuite/daemon/models.py +349 -0
- jcmsuite/daemon/namespaces.py +250 -0
- jcmsuite/daemon/protocol.py +801 -0
- jcmsuite/daemon/resources.py +407 -0
- jcmsuite/daemon/scope.py +53 -0
- jcmsuite/daemon/transport.py +223 -0
- jcmsuite/editing/__init__.py +10 -0
- jcmsuite/editing/editor.py +274 -0
- jcmsuite/exceptions/__init__.py +32 -0
- jcmsuite/exceptions/errors.py +173 -0
- jcmsuite/geo/__init__.py +10 -0
- jcmsuite/geo/mesh.py +302 -0
- jcmsuite/info/__init__.py +10 -0
- jcmsuite/info/runtime_info.py +45 -0
- jcmsuite/internal/__init__.py +2 -0
- jcmsuite/internal/diagnostics.py +74 -0
- jcmsuite/internal/progress.py +80 -0
- jcmsuite/loaders/__init__.py +18 -0
- jcmsuite/loaders/blob_header.py +315 -0
- jcmsuite/loaders/cartesian_field_reader.py +249 -0
- jcmsuite/loaders/cartesian_fields.py +324 -0
- jcmsuite/loaders/nested_mapping.py +69 -0
- jcmsuite/loaders/powerflux.py +136 -0
- jcmsuite/loaders/table.py +637 -0
- jcmsuite/logging/__init__.py +22 -0
- jcmsuite/logging/runtime.py +210 -0
- jcmsuite/results/__init__.py +126 -0
- jcmsuite/results/artifacts.py +806 -0
- jcmsuite/results/discovery.py +82 -0
- jcmsuite/results/field_exports.py +1062 -0
- jcmsuite/results/field_payloads.py +453 -0
- jcmsuite/results/internal/__init__.py +4 -0
- jcmsuite/results/internal/export/__init__.py +4 -0
- jcmsuite/results/internal/export/common.py +56 -0
- jcmsuite/results/internal/export/pandas/__init__.py +4 -0
- jcmsuite/results/internal/export/pandas/common.py +165 -0
- jcmsuite/results/internal/export/pandas/payload.py +480 -0
- jcmsuite/results/internal/export/pandas/rows.py +484 -0
- jcmsuite/results/internal/export/preview.py +178 -0
- jcmsuite/results/internal/export/xarray/__init__.py +4 -0
- jcmsuite/results/internal/export/xarray/export.py +688 -0
- jcmsuite/results/internal/export/xarray/grouped.py +608 -0
- jcmsuite/results/internal/export/xarray/headers.py +290 -0
- jcmsuite/results/internal/export/xarray/runtime.py +99 -0
- jcmsuite/results/internal/export/xarray/shared.py +246 -0
- jcmsuite/results/internal/export/xarray/tabular.py +304 -0
- jcmsuite/results/internal/export/xarray/types.py +28 -0
- jcmsuite/results/internal/models/__init__.py +4 -0
- jcmsuite/results/internal/models/batch.py +1081 -0
- jcmsuite/results/internal/models/batch_postprocess.py +1728 -0
- jcmsuite/results/internal/models/bundle.py +343 -0
- jcmsuite/results/internal/models/core.py +556 -0
- jcmsuite/results/internal/models/submission.py +1157 -0
- jcmsuite/results/internal/resultbag/__init__.py +4 -0
- jcmsuite/results/internal/resultbag/access.py +489 -0
- jcmsuite/results/internal/resultbag/iteration.py +199 -0
- jcmsuite/results/internal/resultbag/query.py +226 -0
- jcmsuite/results/internal/resultbag/raw.py +407 -0
- jcmsuite/results/internal/resultbag/source_files.py +142 -0
- jcmsuite/results/internal/resultbag/store.py +881 -0
- jcmsuite/results/internal/resultbag/utils.py +258 -0
- jcmsuite/results/models.py +76 -0
- jcmsuite/results/opening.py +55 -0
- jcmsuite/results/pandas_export.py +325 -0
- jcmsuite/results/payloads.py +478 -0
- jcmsuite/results/postprocess.py +97 -0
- jcmsuite/results/postprocess_payloads.py +757 -0
- jcmsuite/results/postprocess_record.py +418 -0
- jcmsuite/results/resultbag.py +279 -0
- jcmsuite/results/resultbag_management.py +433 -0
- jcmsuite/results/structured_derivatives.py +387 -0
- jcmsuite/solve/__init__.py +10 -0
- jcmsuite/solve/daemon_bundle_staging.py +100 -0
- jcmsuite/solve/daemon_bundle_wait.py +89 -0
- jcmsuite/solve/orchestration.py +1576 -0
- jcmsuite/solve/orchestration_execution.py +180 -0
- jcmsuite/solve/orchestration_routing.py +128 -0
- jcmsuite/solve/orchestration_support.py +323 -0
- jcmsuite/solve/path_resolution.py +98 -0
- jcmsuite/solve/progress.py +20 -0
- jcmsuite/solve/solver.py +709 -0
- jcmsuite/solve/staging.py +264 -0
- jcmsuite/solve/types.py +25 -0
- jcmsuite/solve/working_dirs.py +227 -0
- jcmsuite/templates/__init__.py +11 -0
- jcmsuite/templates/converter.py +71 -0
- jcmsuite/templates/formatting.py +335 -0
- jcmsuite/templates/formatting_cli.py +47 -0
- jcmsuite/templates/rendering.py +666 -0
- jcmsuite/torch/__init__.py +25 -0
- jcmsuite/torch/autograd.py +488 -0
- jcmsuite/torch/coordinate_policy.py +82 -0
- jcmsuite/torch/core.py +312 -0
- jcmsuite/torch/results/__init__.py +51 -0
- jcmsuite/torch/types.py +84 -0
- jcmsuite/torch/validation.py +208 -0
- jcmsuite/torch/wrappers.py +4332 -0
- jcmsuite/view/__init__.py +10 -0
- jcmsuite/view/viewer.py +122 -0
- jcmsuite-7.4.2.dist-info/METADATA +180 -0
- jcmsuite-7.4.2.dist-info/RECORD +119 -0
- jcmsuite-7.4.2.dist-info/WHEEL +4 -0
- jcmsuite-7.4.2.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2001-2026 JCMwave GmbH
|
|
3
|
+
|
|
4
|
+
"""Ordered project-bundle solve models."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from collections.abc import Iterator
|
|
9
|
+
from dataclasses import dataclass, field
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from .batch import BatchSolveEntry, BatchSolveFailure, BatchSolveResult
|
|
13
|
+
from .core import SolveExecutionLog, SolveResult
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@dataclass(slots=True, frozen=True)
|
|
17
|
+
class BundledSolveEntry:
|
|
18
|
+
"""Store one project result in an ordered project bundle.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
project_file : Path
|
|
23
|
+
Path to the project file.
|
|
24
|
+
result : SolveResult
|
|
25
|
+
Result for the project.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
project_file: Path | None
|
|
29
|
+
result: SolveResult
|
|
30
|
+
_project_identity: str | None = field(default=None, repr=False, compare=False)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass(slots=True, frozen=True)
|
|
34
|
+
class BundledBatchSolveEntry:
|
|
35
|
+
"""Store one batch entry for a complete ordered project bundle.
|
|
36
|
+
|
|
37
|
+
Parameters
|
|
38
|
+
----------
|
|
39
|
+
index : int
|
|
40
|
+
Position in the batched project keys.
|
|
41
|
+
keys : dict[str, object]
|
|
42
|
+
project keys used for this batch entry.
|
|
43
|
+
result : BundledSolveResult | None
|
|
44
|
+
Result for a successful ordered project bundle.
|
|
45
|
+
failure : BatchSolveFailure | None
|
|
46
|
+
Failure information when the solve did not succeed.
|
|
47
|
+
project_files : tuple[Path, ...], optional
|
|
48
|
+
project files in ordered project bundle order. The files remain
|
|
49
|
+
available if the solve fails before it produces a project result.
|
|
50
|
+
log : SolveExecutionLog | None, optional
|
|
51
|
+
Execution log for a failed ordered project bundle.
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
index: int
|
|
55
|
+
keys: dict[str, object]
|
|
56
|
+
result: BundledSolveResult | None
|
|
57
|
+
failure: BatchSolveFailure | None
|
|
58
|
+
project_files: tuple[Path | None, ...] = ()
|
|
59
|
+
log: SolveExecutionLog | None = field(default=None, repr=False)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
@dataclass(slots=True, frozen=True)
|
|
63
|
+
class BundledSolveResult:
|
|
64
|
+
"""Provide results for one ordered project bundle.
|
|
65
|
+
|
|
66
|
+
Parameters
|
|
67
|
+
----------
|
|
68
|
+
entries : tuple[BundledSolveEntry, ...]
|
|
69
|
+
project results in ordered project bundle order.
|
|
70
|
+
|
|
71
|
+
Notes
|
|
72
|
+
-----
|
|
73
|
+
`result[index]` returns one project result. Iteration yields project results
|
|
74
|
+
in ordered project bundle order.
|
|
75
|
+
"""
|
|
76
|
+
|
|
77
|
+
entries: tuple[BundledSolveEntry, ...]
|
|
78
|
+
|
|
79
|
+
def __len__(self) -> int:
|
|
80
|
+
"""Return the number of project results in the bundle.
|
|
81
|
+
|
|
82
|
+
Returns
|
|
83
|
+
-------
|
|
84
|
+
int
|
|
85
|
+
Number of projects in the ordered project bundle.
|
|
86
|
+
"""
|
|
87
|
+
|
|
88
|
+
return len(self.entries)
|
|
89
|
+
|
|
90
|
+
def __iter__(self) -> Iterator[SolveResult]:
|
|
91
|
+
"""Iterate over project results in ordered project bundle order.
|
|
92
|
+
|
|
93
|
+
Returns
|
|
94
|
+
-------
|
|
95
|
+
Iterator[SolveResult]
|
|
96
|
+
Iterator over the project results.
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
entry: BundledSolveEntry
|
|
100
|
+
for entry in self.entries:
|
|
101
|
+
yield entry.result
|
|
102
|
+
|
|
103
|
+
def __getitem__(self, index: int) -> SolveResult:
|
|
104
|
+
"""Return one project result by its position.
|
|
105
|
+
|
|
106
|
+
Parameters
|
|
107
|
+
----------
|
|
108
|
+
index : int
|
|
109
|
+
Position in the ordered project bundle. Negative positions count
|
|
110
|
+
from the end of the bundle.
|
|
111
|
+
|
|
112
|
+
Returns
|
|
113
|
+
-------
|
|
114
|
+
SolveResult
|
|
115
|
+
Result for the selected project.
|
|
116
|
+
|
|
117
|
+
Raises
|
|
118
|
+
------
|
|
119
|
+
TypeError
|
|
120
|
+
If `index` is not an integer.
|
|
121
|
+
IndexError
|
|
122
|
+
If `index` is outside the ordered project bundle.
|
|
123
|
+
"""
|
|
124
|
+
|
|
125
|
+
if not isinstance(index, int):
|
|
126
|
+
raise TypeError("BundledSolveResult indexing requires an integer index.")
|
|
127
|
+
return self.entries[index].result
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def project_files(self) -> tuple[Path | None, ...]:
|
|
131
|
+
"""Return the project file paths in ordered project bundle order.
|
|
132
|
+
|
|
133
|
+
Returns
|
|
134
|
+
-------
|
|
135
|
+
tuple[Path, ...]
|
|
136
|
+
Absolute project file paths.
|
|
137
|
+
"""
|
|
138
|
+
|
|
139
|
+
return tuple(
|
|
140
|
+
(
|
|
141
|
+
None
|
|
142
|
+
if entry.project_file is None
|
|
143
|
+
else entry.project_file.expanduser().resolve()
|
|
144
|
+
)
|
|
145
|
+
for entry in self.entries
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
def project(self, selector: int) -> SolveResult:
|
|
149
|
+
"""Return one project result by its position.
|
|
150
|
+
|
|
151
|
+
Parameters
|
|
152
|
+
----------
|
|
153
|
+
selector : int
|
|
154
|
+
Position of the project in the ordered project bundle.
|
|
155
|
+
|
|
156
|
+
Returns
|
|
157
|
+
-------
|
|
158
|
+
SolveResult
|
|
159
|
+
Result for the selected project.
|
|
160
|
+
"""
|
|
161
|
+
|
|
162
|
+
if not isinstance(selector, int):
|
|
163
|
+
raise TypeError(
|
|
164
|
+
"BundledSolveResult project selection requires an integer index."
|
|
165
|
+
)
|
|
166
|
+
return self[selector]
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
@dataclass(slots=True, frozen=True)
|
|
170
|
+
class BundledBatchSolveResult:
|
|
171
|
+
"""Provide project-first access to batched ordered project bundles.
|
|
172
|
+
|
|
173
|
+
Parameters
|
|
174
|
+
----------
|
|
175
|
+
entries : tuple[BundledBatchSolveEntry, ...]
|
|
176
|
+
Results in batched project keys order.
|
|
177
|
+
|
|
178
|
+
Notes
|
|
179
|
+
-----
|
|
180
|
+
List-style access is project-first. `result[index]` returns the
|
|
181
|
+
`BatchSolveResult` for one project across all batched project keys.
|
|
182
|
+
Iteration yields these project batch results in ordered project bundle
|
|
183
|
+
order.
|
|
184
|
+
"""
|
|
185
|
+
|
|
186
|
+
entries: tuple[BundledBatchSolveEntry, ...]
|
|
187
|
+
|
|
188
|
+
def _project_axis_files(self) -> tuple[Path | None, ...]:
|
|
189
|
+
"""Return the ordered project axis for this bundle batch.
|
|
190
|
+
|
|
191
|
+
The bundle-batch public API is project-oriented even though the stored
|
|
192
|
+
entries are batch-oriented. Successful bundle results already carry the
|
|
193
|
+
public project axis directly; failed entries preserve the same axis via
|
|
194
|
+
stored `project_files` metadata.
|
|
195
|
+
"""
|
|
196
|
+
|
|
197
|
+
entry: BundledBatchSolveEntry
|
|
198
|
+
for entry in self.entries:
|
|
199
|
+
if entry.result is not None:
|
|
200
|
+
project_files: tuple[Path | None, ...] = entry.result.project_files
|
|
201
|
+
if project_files:
|
|
202
|
+
return project_files
|
|
203
|
+
if entry.project_files:
|
|
204
|
+
return tuple(
|
|
205
|
+
(
|
|
206
|
+
None
|
|
207
|
+
if project_file is None
|
|
208
|
+
else project_file.expanduser().resolve()
|
|
209
|
+
)
|
|
210
|
+
for project_file in entry.project_files
|
|
211
|
+
)
|
|
212
|
+
return ()
|
|
213
|
+
|
|
214
|
+
def _require_project_axis_files(self) -> tuple[Path | None, ...]:
|
|
215
|
+
"""Return ordered project files for the public bundle axis."""
|
|
216
|
+
|
|
217
|
+
project_files: tuple[Path | None, ...] = self._project_axis_files()
|
|
218
|
+
if not project_files:
|
|
219
|
+
raise TypeError(
|
|
220
|
+
"BundledBatchSolveResult cannot expose a project axis because no "
|
|
221
|
+
"bundle project metadata is available; inspect `.entries` for "
|
|
222
|
+
"collected failures."
|
|
223
|
+
)
|
|
224
|
+
return project_files
|
|
225
|
+
|
|
226
|
+
def _resolve_project_index(self, selector: int) -> int:
|
|
227
|
+
"""Resolve one project selector against the public bundle axis."""
|
|
228
|
+
|
|
229
|
+
project_files: tuple[Path | None, ...] = self._require_project_axis_files()
|
|
230
|
+
if isinstance(selector, bool) or not isinstance(selector, int):
|
|
231
|
+
raise TypeError(
|
|
232
|
+
"BundledBatchSolveResult project selection requires an integer index."
|
|
233
|
+
)
|
|
234
|
+
resolved_index: int = selector
|
|
235
|
+
if resolved_index < 0:
|
|
236
|
+
resolved_index += len(project_files)
|
|
237
|
+
if resolved_index < 0 or resolved_index >= len(project_files):
|
|
238
|
+
raise IndexError("BundledBatchSolveResult project index out of range.")
|
|
239
|
+
return resolved_index
|
|
240
|
+
|
|
241
|
+
def __len__(self) -> int:
|
|
242
|
+
"""Return the number of projects in the ordered project bundle.
|
|
243
|
+
|
|
244
|
+
Returns
|
|
245
|
+
-------
|
|
246
|
+
int
|
|
247
|
+
Number of available project positions.
|
|
248
|
+
"""
|
|
249
|
+
|
|
250
|
+
return len(self._project_axis_files())
|
|
251
|
+
|
|
252
|
+
def __iter__(self) -> Iterator[BatchSolveResult]:
|
|
253
|
+
"""Iterate over project batch results in bundle order.
|
|
254
|
+
|
|
255
|
+
Returns
|
|
256
|
+
-------
|
|
257
|
+
Iterator[BatchSolveResult]
|
|
258
|
+
Iterator with one batch result for each project.
|
|
259
|
+
"""
|
|
260
|
+
|
|
261
|
+
project_index: int
|
|
262
|
+
for project_index in range(len(self)):
|
|
263
|
+
yield self[project_index]
|
|
264
|
+
|
|
265
|
+
def __getitem__(self, index: int) -> BatchSolveResult:
|
|
266
|
+
"""Return the batch result for one project position.
|
|
267
|
+
|
|
268
|
+
Parameters
|
|
269
|
+
----------
|
|
270
|
+
index : int
|
|
271
|
+
Position in the ordered project bundle. Negative positions count
|
|
272
|
+
from the end of the bundle.
|
|
273
|
+
|
|
274
|
+
Returns
|
|
275
|
+
-------
|
|
276
|
+
BatchSolveResult
|
|
277
|
+
Results for the selected project in batched project keys order.
|
|
278
|
+
|
|
279
|
+
Raises
|
|
280
|
+
------
|
|
281
|
+
TypeError
|
|
282
|
+
If `index` is not an integer or is a Boolean value.
|
|
283
|
+
IndexError
|
|
284
|
+
If `index` is outside the ordered project bundle.
|
|
285
|
+
"""
|
|
286
|
+
|
|
287
|
+
return self.project(index)
|
|
288
|
+
|
|
289
|
+
@property
|
|
290
|
+
def project_files(self) -> tuple[Path | None, ...]:
|
|
291
|
+
"""Return the project files in ordered project bundle order.
|
|
292
|
+
|
|
293
|
+
Returns
|
|
294
|
+
-------
|
|
295
|
+
tuple[Path | None, ...]
|
|
296
|
+
Absolute project file paths, or an empty tuple if no project
|
|
297
|
+
information is available.
|
|
298
|
+
"""
|
|
299
|
+
|
|
300
|
+
return self._project_axis_files()
|
|
301
|
+
|
|
302
|
+
def project(self, selector: int) -> BatchSolveResult:
|
|
303
|
+
"""Return the batch results for one project in the bundle.
|
|
304
|
+
|
|
305
|
+
Parameters
|
|
306
|
+
----------
|
|
307
|
+
selector : int
|
|
308
|
+
Position of the project in the ordered project bundle.
|
|
309
|
+
|
|
310
|
+
Returns
|
|
311
|
+
-------
|
|
312
|
+
BatchSolveResult
|
|
313
|
+
Results for the selected project in batched project keys order.
|
|
314
|
+
The result includes failures that were collected during the solve.
|
|
315
|
+
"""
|
|
316
|
+
|
|
317
|
+
project_index: int = self._resolve_project_index(selector)
|
|
318
|
+
|
|
319
|
+
selected_entries: list[BatchSolveEntry] = []
|
|
320
|
+
bundle_entry: BundledBatchSolveEntry
|
|
321
|
+
for bundle_entry in self.entries:
|
|
322
|
+
if bundle_entry.result is None:
|
|
323
|
+
selected_entries.append(
|
|
324
|
+
BatchSolveEntry(
|
|
325
|
+
index=bundle_entry.index,
|
|
326
|
+
keys=bundle_entry.keys,
|
|
327
|
+
result=None,
|
|
328
|
+
failure=bundle_entry.failure,
|
|
329
|
+
_log=bundle_entry.log,
|
|
330
|
+
)
|
|
331
|
+
)
|
|
332
|
+
continue
|
|
333
|
+
selected_result: SolveResult = bundle_entry.result[project_index]
|
|
334
|
+
selected_entries.append(
|
|
335
|
+
BatchSolveEntry(
|
|
336
|
+
index=bundle_entry.index,
|
|
337
|
+
keys=bundle_entry.keys,
|
|
338
|
+
result=selected_result,
|
|
339
|
+
failure=None,
|
|
340
|
+
_log=bundle_entry.log,
|
|
341
|
+
)
|
|
342
|
+
)
|
|
343
|
+
return BatchSolveResult(entries=tuple(selected_entries))
|