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,258 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2001-2026 JCMwave GmbH
|
|
3
|
+
|
|
4
|
+
"""Resultbag filter and key canonicalization helpers."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import json
|
|
9
|
+
import sqlite3
|
|
10
|
+
from collections.abc import Mapping
|
|
11
|
+
from dataclasses import dataclass
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import Any, Literal, cast
|
|
14
|
+
|
|
15
|
+
import numpy as np
|
|
16
|
+
|
|
17
|
+
from ....exceptions import InvalidConfigurationError
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass(frozen=True, slots=True)
|
|
21
|
+
class _BetweenFilter:
|
|
22
|
+
"""Inclusive bounds marker used by `Resultbag.filter(...)`."""
|
|
23
|
+
|
|
24
|
+
lower: object
|
|
25
|
+
upper: object
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def between(lower: object, upper: object) -> _BetweenFilter:
|
|
29
|
+
"""Create an inclusive bounds filter for `Resultbag.filter(...)`.
|
|
30
|
+
|
|
31
|
+
Parameters
|
|
32
|
+
----------
|
|
33
|
+
lower : object
|
|
34
|
+
Inclusive lower bound.
|
|
35
|
+
upper : object
|
|
36
|
+
Inclusive upper bound.
|
|
37
|
+
|
|
38
|
+
Returns
|
|
39
|
+
-------
|
|
40
|
+
object
|
|
41
|
+
Filter value that selects values from `lower` through `upper`.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
return _BetweenFilter(lower=lower, upper=upper)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
FilterInput = object | _BetweenFilter
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _canonicalize_key_value(value: object) -> object:
|
|
51
|
+
"""Convert key values to a deterministic, JSON-serializable structure."""
|
|
52
|
+
|
|
53
|
+
if value is None or isinstance(value, (bool, int, float, str)):
|
|
54
|
+
return value
|
|
55
|
+
if isinstance(value, np.generic):
|
|
56
|
+
return {
|
|
57
|
+
"__numpy_scalar__": {
|
|
58
|
+
"dtype": value.dtype.str,
|
|
59
|
+
"value": _canonicalize_key_value(value.item()),
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if isinstance(value, np.ndarray):
|
|
63
|
+
return {
|
|
64
|
+
"__ndarray__": {
|
|
65
|
+
"dtype": value.dtype.str,
|
|
66
|
+
"shape": [int(axis) for axis in value.shape],
|
|
67
|
+
"data": _canonicalize_key_value(value.tolist()),
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if isinstance(value, Path):
|
|
71
|
+
return {"__path__": str(value)}
|
|
72
|
+
if isinstance(value, complex):
|
|
73
|
+
return {"__complex__": [value.real, value.imag]}
|
|
74
|
+
if isinstance(value, Mapping):
|
|
75
|
+
normalized_mapping: dict[str, object] = {}
|
|
76
|
+
raw_key: object
|
|
77
|
+
raw_value: object
|
|
78
|
+
for raw_key, raw_value in sorted(value.items(), key=lambda item: str(item[0])):
|
|
79
|
+
normalized_mapping[str(raw_key)] = _canonicalize_key_value(raw_value)
|
|
80
|
+
return normalized_mapping
|
|
81
|
+
if isinstance(value, (list, tuple)):
|
|
82
|
+
return [_canonicalize_key_value(item) for item in value]
|
|
83
|
+
if isinstance(value, (set, frozenset)):
|
|
84
|
+
# Sets are unordered by nature. We normalize each element and then sort by
|
|
85
|
+
# its canonical JSON representation so the resulting order is stable.
|
|
86
|
+
normalized_set_items: list[object] = [
|
|
87
|
+
_canonicalize_key_value(item) for item in value
|
|
88
|
+
]
|
|
89
|
+
normalized_set_items.sort(
|
|
90
|
+
key=lambda item: json.dumps(item, sort_keys=True, separators=(",", ":"))
|
|
91
|
+
)
|
|
92
|
+
return {"__set__": normalized_set_items}
|
|
93
|
+
raise InvalidConfigurationError(
|
|
94
|
+
f"Unsupported key value type for Resultbag keys: {type(value)!r}"
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _decanonicalize_key_value(value: object) -> object:
|
|
99
|
+
"""Convert canonical JSON structures back to Python key structures."""
|
|
100
|
+
|
|
101
|
+
if isinstance(value, list):
|
|
102
|
+
return [_decanonicalize_key_value(item) for item in value]
|
|
103
|
+
if isinstance(value, dict):
|
|
104
|
+
if "__numpy_scalar__" in value and len(value) == 1:
|
|
105
|
+
scalar_spec: object = value["__numpy_scalar__"]
|
|
106
|
+
if isinstance(scalar_spec, dict):
|
|
107
|
+
dtype_name: object = scalar_spec.get("dtype")
|
|
108
|
+
scalar_value: object = scalar_spec.get("value")
|
|
109
|
+
if isinstance(dtype_name, str):
|
|
110
|
+
reconstructed_scalar: object = _decanonicalize_key_value(
|
|
111
|
+
scalar_value
|
|
112
|
+
)
|
|
113
|
+
scalar_array = np.asarray(
|
|
114
|
+
reconstructed_scalar, dtype=np.dtype(dtype_name)
|
|
115
|
+
)
|
|
116
|
+
return cast(object, scalar_array[()])
|
|
117
|
+
if "__ndarray__" in value and len(value) == 1:
|
|
118
|
+
array_spec: object = value["__ndarray__"]
|
|
119
|
+
if isinstance(array_spec, dict):
|
|
120
|
+
dtype_name = array_spec.get("dtype")
|
|
121
|
+
raw_shape = array_spec.get("shape")
|
|
122
|
+
raw_data = array_spec.get("data")
|
|
123
|
+
if isinstance(dtype_name, str) and isinstance(raw_shape, list):
|
|
124
|
+
reconstructed_data: object = _decanonicalize_key_value(raw_data)
|
|
125
|
+
shape: tuple[int, ...] = tuple(int(axis) for axis in raw_shape)
|
|
126
|
+
array = np.asarray(reconstructed_data, dtype=np.dtype(dtype_name))
|
|
127
|
+
return array.reshape(shape)
|
|
128
|
+
if "__path__" in value and len(value) == 1:
|
|
129
|
+
return Path(str(value["__path__"]))
|
|
130
|
+
if "__complex__" in value and len(value) == 1:
|
|
131
|
+
complex_parts: object = value["__complex__"]
|
|
132
|
+
if isinstance(complex_parts, list) and len(complex_parts) == 2:
|
|
133
|
+
return complex(float(complex_parts[0]), float(complex_parts[1]))
|
|
134
|
+
if "__set__" in value and len(value) == 1:
|
|
135
|
+
set_items: object = value["__set__"]
|
|
136
|
+
if isinstance(set_items, list):
|
|
137
|
+
return {_decanonicalize_key_value(item) for item in set_items}
|
|
138
|
+
return {
|
|
139
|
+
key: _decanonicalize_key_value(raw_value)
|
|
140
|
+
for key, raw_value in value.items()
|
|
141
|
+
}
|
|
142
|
+
return value
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def _safe_close_connection(connection: sqlite3.Connection) -> None:
|
|
146
|
+
"""Best-effort connection close helper used by finalizers.
|
|
147
|
+
|
|
148
|
+
Finalizers may run after partial interpreter teardown or after an explicit
|
|
149
|
+
manual close. In those cases, a second close can raise sqlite errors that
|
|
150
|
+
should not escape cleanup code paths.
|
|
151
|
+
"""
|
|
152
|
+
|
|
153
|
+
try:
|
|
154
|
+
connection.close()
|
|
155
|
+
except Exception:
|
|
156
|
+
pass
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
@dataclass(frozen=True, slots=True)
|
|
160
|
+
class _FilterSpec:
|
|
161
|
+
"""Normalized filter spec used by Resultbag query views."""
|
|
162
|
+
|
|
163
|
+
key: str
|
|
164
|
+
mode: Literal["exact", "bounds"]
|
|
165
|
+
exact_value: object | None = None
|
|
166
|
+
lower_bound: object | None = None
|
|
167
|
+
upper_bound: object | None = None
|
|
168
|
+
|
|
169
|
+
@classmethod
|
|
170
|
+
def from_input(cls, key: str, filter_value: FilterInput) -> _FilterSpec:
|
|
171
|
+
"""Create normalized filter spec from user-facing filter argument."""
|
|
172
|
+
|
|
173
|
+
if not key:
|
|
174
|
+
raise InvalidConfigurationError("Filter key must be a non-empty string.")
|
|
175
|
+
if isinstance(filter_value, _BetweenFilter):
|
|
176
|
+
return cls(
|
|
177
|
+
key=key,
|
|
178
|
+
mode="bounds",
|
|
179
|
+
lower_bound=filter_value.lower,
|
|
180
|
+
upper_bound=filter_value.upper,
|
|
181
|
+
)
|
|
182
|
+
return cls(key=key, mode="exact", exact_value=filter_value)
|
|
183
|
+
|
|
184
|
+
def matches(self, keys: Mapping[str, object]) -> bool:
|
|
185
|
+
"""Return whether a key dictionary matches this filter."""
|
|
186
|
+
|
|
187
|
+
if self.key not in keys:
|
|
188
|
+
return False
|
|
189
|
+
candidate_value: object = keys[self.key]
|
|
190
|
+
if self.mode == "exact":
|
|
191
|
+
return _canonicalize_key_value(candidate_value) == _canonicalize_key_value(
|
|
192
|
+
self.exact_value
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
try:
|
|
196
|
+
# Bounds filters are intentionally dynamic: stored key payloads may be
|
|
197
|
+
# numeric, datetime-like, or other orderable runtime types.
|
|
198
|
+
# We narrow to Any only at this operator boundary.
|
|
199
|
+
lower_any: Any = self.lower_bound
|
|
200
|
+
candidate_any: Any = candidate_value
|
|
201
|
+
upper_any: Any = self.upper_bound
|
|
202
|
+
return cast(
|
|
203
|
+
bool,
|
|
204
|
+
lower_any <= candidate_any <= upper_any,
|
|
205
|
+
)
|
|
206
|
+
except TypeError as error:
|
|
207
|
+
raise InvalidConfigurationError(
|
|
208
|
+
"Cannot apply bounds filter for key "
|
|
209
|
+
f"`{self.key}` to stored value of type {type(candidate_value)!r}."
|
|
210
|
+
) from error
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def _build_filter_specs(
|
|
214
|
+
key: str | None,
|
|
215
|
+
filter_value: FilterInput | None,
|
|
216
|
+
criteria: Mapping[str, FilterInput],
|
|
217
|
+
) -> tuple[_FilterSpec, ...]:
|
|
218
|
+
"""Normalize positional/keyword filter inputs into spec tuples."""
|
|
219
|
+
|
|
220
|
+
if key is None and filter_value is not None:
|
|
221
|
+
raise InvalidConfigurationError(
|
|
222
|
+
"Positional filter value requires a positional filter key."
|
|
223
|
+
)
|
|
224
|
+
if key is not None and filter_value is None:
|
|
225
|
+
raise InvalidConfigurationError(
|
|
226
|
+
"Positional filter key requires a positional filter value."
|
|
227
|
+
)
|
|
228
|
+
if key is None and filter_value is None and not criteria:
|
|
229
|
+
raise InvalidConfigurationError("Provide at least one filter criterion.")
|
|
230
|
+
|
|
231
|
+
specs: list[_FilterSpec] = []
|
|
232
|
+
seen_keys: set[str] = set()
|
|
233
|
+
if key is not None:
|
|
234
|
+
if key in criteria:
|
|
235
|
+
raise InvalidConfigurationError(
|
|
236
|
+
f"Duplicate filter criterion for key `{key}`."
|
|
237
|
+
)
|
|
238
|
+
if filter_value is None:
|
|
239
|
+
raise InvalidConfigurationError(
|
|
240
|
+
"Positional filter key requires a positional filter value."
|
|
241
|
+
)
|
|
242
|
+
positional_spec: _FilterSpec = _FilterSpec.from_input(key, filter_value)
|
|
243
|
+
specs.append(positional_spec)
|
|
244
|
+
seen_keys.add(key)
|
|
245
|
+
|
|
246
|
+
criterion_key: str
|
|
247
|
+
criterion_value: FilterInput
|
|
248
|
+
for criterion_key, criterion_value in criteria.items():
|
|
249
|
+
if not criterion_key:
|
|
250
|
+
raise InvalidConfigurationError("Filter key must be a non-empty string.")
|
|
251
|
+
if criterion_key in seen_keys:
|
|
252
|
+
raise InvalidConfigurationError(
|
|
253
|
+
f"Duplicate filter criterion for key `{criterion_key}`."
|
|
254
|
+
)
|
|
255
|
+
seen_keys.add(criterion_key)
|
|
256
|
+
specs.append(_FilterSpec.from_input(criterion_key, criterion_value))
|
|
257
|
+
|
|
258
|
+
return tuple(specs)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2001-2026 JCMwave GmbH
|
|
3
|
+
|
|
4
|
+
"""Result-model namespace for `jcmsuite`."""
|
|
5
|
+
|
|
6
|
+
from .internal.models.batch import (
|
|
7
|
+
BatchComputationalCosts,
|
|
8
|
+
BatchEigenvalues,
|
|
9
|
+
BatchExportablePayload,
|
|
10
|
+
BatchMetadataPayload,
|
|
11
|
+
BatchSolveEntry,
|
|
12
|
+
BatchSolveFailure,
|
|
13
|
+
BatchSolveKeys,
|
|
14
|
+
BatchSolveResult,
|
|
15
|
+
BatchStructuredPayload,
|
|
16
|
+
BatchTableCollectionPayload,
|
|
17
|
+
BatchTablePayload,
|
|
18
|
+
)
|
|
19
|
+
from .internal.models.batch_postprocess import (
|
|
20
|
+
BatchFieldExportPayload,
|
|
21
|
+
BatchIntensityFieldExportPayload,
|
|
22
|
+
BatchPostprocessCollection,
|
|
23
|
+
BatchPostprocessRecord,
|
|
24
|
+
)
|
|
25
|
+
from .internal.models.bundle import (
|
|
26
|
+
BundledBatchSolveEntry,
|
|
27
|
+
BundledBatchSolveResult,
|
|
28
|
+
BundledSolveEntry,
|
|
29
|
+
BundledSolveResult,
|
|
30
|
+
)
|
|
31
|
+
from .internal.models.core import (
|
|
32
|
+
SolveExecutionLog,
|
|
33
|
+
SolveKeysPayload,
|
|
34
|
+
SolveResult,
|
|
35
|
+
TemplateRenderInfo,
|
|
36
|
+
)
|
|
37
|
+
from .internal.models.submission import (
|
|
38
|
+
BatchSolveSubmission,
|
|
39
|
+
BundledBatchSolveSubmission,
|
|
40
|
+
BundledBatchSolveSubmissionEntry,
|
|
41
|
+
BundledSolveSubmission,
|
|
42
|
+
SolveSubmission,
|
|
43
|
+
)
|
|
44
|
+
from .payloads import SolveKeys
|
|
45
|
+
|
|
46
|
+
__all__ = [
|
|
47
|
+
"BatchExportablePayload",
|
|
48
|
+
"BatchFieldExportPayload",
|
|
49
|
+
"BatchIntensityFieldExportPayload",
|
|
50
|
+
"BatchMetadataPayload",
|
|
51
|
+
"BatchComputationalCosts",
|
|
52
|
+
"BatchEigenvalues",
|
|
53
|
+
"BatchTablePayload",
|
|
54
|
+
"BatchStructuredPayload",
|
|
55
|
+
"BatchTableCollectionPayload",
|
|
56
|
+
"BatchSolveKeys",
|
|
57
|
+
"BatchPostprocessCollection",
|
|
58
|
+
"BatchPostprocessRecord",
|
|
59
|
+
"BundledBatchSolveEntry",
|
|
60
|
+
"BundledBatchSolveResult",
|
|
61
|
+
"BatchSolveEntry",
|
|
62
|
+
"BatchSolveFailure",
|
|
63
|
+
"BatchSolveResult",
|
|
64
|
+
"BundledBatchSolveSubmissionEntry",
|
|
65
|
+
"BundledBatchSolveSubmission",
|
|
66
|
+
"BatchSolveSubmission",
|
|
67
|
+
"SolveExecutionLog",
|
|
68
|
+
"BundledSolveEntry",
|
|
69
|
+
"BundledSolveResult",
|
|
70
|
+
"BundledSolveSubmission",
|
|
71
|
+
"SolveKeys",
|
|
72
|
+
"SolveKeysPayload",
|
|
73
|
+
"SolveResult",
|
|
74
|
+
"SolveSubmission",
|
|
75
|
+
"TemplateRenderInfo",
|
|
76
|
+
]
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2001-2026 JCMwave GmbH
|
|
3
|
+
|
|
4
|
+
"""Existing-result opening helpers for post-run analysis workflows."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from ..exceptions import InvalidConfigurationError
|
|
11
|
+
from .models import SolveResult
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def open(
|
|
15
|
+
path: str | Path,
|
|
16
|
+
*,
|
|
17
|
+
project_file: str | Path | None = None,
|
|
18
|
+
) -> SolveResult:
|
|
19
|
+
"""Open an existing solve result without running `solve(...)`.
|
|
20
|
+
|
|
21
|
+
Parameters
|
|
22
|
+
----------
|
|
23
|
+
path : str | Path
|
|
24
|
+
Path to a rendered project file (`.jcmp` or `.jcm`) or a
|
|
25
|
+
``*_results`` directory.
|
|
26
|
+
project_file : str | Path | None, optional
|
|
27
|
+
project file associated with a result directory. Use this option only
|
|
28
|
+
if `path` is a result directory.
|
|
29
|
+
|
|
30
|
+
Returns
|
|
31
|
+
-------
|
|
32
|
+
SolveResult
|
|
33
|
+
Solve result with its available result data loaded.
|
|
34
|
+
|
|
35
|
+
Raises
|
|
36
|
+
------
|
|
37
|
+
InvalidConfigurationError
|
|
38
|
+
If `path` does not point to a readable project file or result directory.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
resolved_path: Path = Path(path).expanduser().resolve()
|
|
42
|
+
if resolved_path.is_dir():
|
|
43
|
+
return SolveResult.from_result_dir(
|
|
44
|
+
resolved_path,
|
|
45
|
+
project_file=project_file,
|
|
46
|
+
)
|
|
47
|
+
if project_file is not None:
|
|
48
|
+
raise InvalidConfigurationError(
|
|
49
|
+
"`project_file` is only supported when opening from a result directory."
|
|
50
|
+
)
|
|
51
|
+
if not resolved_path.is_file():
|
|
52
|
+
raise InvalidConfigurationError(
|
|
53
|
+
f"Open path is missing or invalid: {resolved_path}"
|
|
54
|
+
)
|
|
55
|
+
return SolveResult.from_project_file(resolved_path)
|