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,274 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2001-2026 JCMwave GmbH
|
|
3
|
+
|
|
4
|
+
"""Editor integration entrypoint for `jcmsuite`."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import asyncio
|
|
9
|
+
import os
|
|
10
|
+
from collections.abc import Coroutine
|
|
11
|
+
from logging import Logger
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import Literal, overload
|
|
14
|
+
|
|
15
|
+
from ..context import SolverContext, resolve_context
|
|
16
|
+
from ..daemon.transport import (
|
|
17
|
+
DaemonTransportConnection,
|
|
18
|
+
close_daemon_connection,
|
|
19
|
+
send_daemon_message,
|
|
20
|
+
start_daemon_service,
|
|
21
|
+
)
|
|
22
|
+
from ..exceptions import (
|
|
23
|
+
BackendUnavailableError,
|
|
24
|
+
InvalidConfigurationError,
|
|
25
|
+
RuntimeContextError,
|
|
26
|
+
)
|
|
27
|
+
from ..logging import get_logger
|
|
28
|
+
|
|
29
|
+
_logger: Logger = get_logger(__name__)
|
|
30
|
+
_EDIT_STATUS_BY_CONTEXT_ID: dict[int, bool] = {}
|
|
31
|
+
_EDIT_CONNECTION_BY_CONTEXT_ID: dict[int, DaemonTransportConnection] = {}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@overload
|
|
35
|
+
def edit(
|
|
36
|
+
file_name: str | Path | None = None,
|
|
37
|
+
*,
|
|
38
|
+
line: int = 1,
|
|
39
|
+
col: int = 1,
|
|
40
|
+
set_status: Literal["on", "off"] | None = None,
|
|
41
|
+
hint: str = "",
|
|
42
|
+
context: SolverContext | None = None,
|
|
43
|
+
asynchronous: Literal[False] = False,
|
|
44
|
+
) -> None: ...
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
@overload
|
|
48
|
+
def edit(
|
|
49
|
+
file_name: str | Path | None = None,
|
|
50
|
+
*,
|
|
51
|
+
line: int = 1,
|
|
52
|
+
col: int = 1,
|
|
53
|
+
set_status: Literal["on", "off"] | None = None,
|
|
54
|
+
hint: str = "",
|
|
55
|
+
context: SolverContext | None = None,
|
|
56
|
+
asynchronous: Literal[True],
|
|
57
|
+
) -> Coroutine[object, object, None]: ...
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def edit(
|
|
61
|
+
file_name: str | Path | None = None,
|
|
62
|
+
*,
|
|
63
|
+
line: int = 1,
|
|
64
|
+
col: int = 1,
|
|
65
|
+
set_status: Literal["on", "off"] | None = None,
|
|
66
|
+
hint: str = "",
|
|
67
|
+
context: SolverContext | None = None,
|
|
68
|
+
asynchronous: bool = False,
|
|
69
|
+
) -> None | Coroutine[object, object, None]:
|
|
70
|
+
"""Open a project file or template in `JCMedit`.
|
|
71
|
+
|
|
72
|
+
Parameters
|
|
73
|
+
----------
|
|
74
|
+
file_name : str | Path | None, optional
|
|
75
|
+
File to open. If omitted, open `JCMedit` without a selected file.
|
|
76
|
+
line : int, optional
|
|
77
|
+
One-based line number to select.
|
|
78
|
+
col : int, optional
|
|
79
|
+
One-based column number to select.
|
|
80
|
+
set_status : {"on", "off"} | None, optional
|
|
81
|
+
Use `"on"` to enable automatic editor windows. Use `"off"` to disable
|
|
82
|
+
them.
|
|
83
|
+
hint : str, optional
|
|
84
|
+
Text to send to the editor with the selected source position.
|
|
85
|
+
context : SolverContext | None, optional
|
|
86
|
+
JCMsuite settings to use. If omitted, use the active context or the
|
|
87
|
+
default context.
|
|
88
|
+
asynchronous : bool, optional
|
|
89
|
+
If `True`, return a value that you must use with `await`.
|
|
90
|
+
|
|
91
|
+
Returns
|
|
92
|
+
-------
|
|
93
|
+
None | Coroutine[object, object, None]
|
|
94
|
+
`None` after `JCMedit` starts or when automatic editor windows are
|
|
95
|
+
disabled. If `asynchronous` is `True`, returns a coroutine that performs
|
|
96
|
+
the operation.
|
|
97
|
+
|
|
98
|
+
Raises
|
|
99
|
+
------
|
|
100
|
+
InvalidConfigurationError
|
|
101
|
+
If `file_name` does not identify an existing file.
|
|
102
|
+
RuntimeContextError
|
|
103
|
+
If the `JCMedit` service cannot start.
|
|
104
|
+
RuntimeError
|
|
105
|
+
If asynchronous code calls the function without `asynchronous=True`.
|
|
106
|
+
ValueError
|
|
107
|
+
If `line`, `col`, or `set_status` is not valid.
|
|
108
|
+
"""
|
|
109
|
+
|
|
110
|
+
if asynchronous:
|
|
111
|
+
return _edit_impl(
|
|
112
|
+
file_name=file_name,
|
|
113
|
+
line=line,
|
|
114
|
+
col=col,
|
|
115
|
+
set_status=set_status,
|
|
116
|
+
hint=hint,
|
|
117
|
+
context=context,
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
try:
|
|
121
|
+
asyncio.get_running_loop()
|
|
122
|
+
except RuntimeError:
|
|
123
|
+
return asyncio.run(
|
|
124
|
+
_edit_impl(
|
|
125
|
+
file_name=file_name,
|
|
126
|
+
line=line,
|
|
127
|
+
col=col,
|
|
128
|
+
set_status=set_status,
|
|
129
|
+
hint=hint,
|
|
130
|
+
context=context,
|
|
131
|
+
)
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
raise RuntimeError(
|
|
135
|
+
"edit() called from a running event loop; use `await edit(..., asynchronous=True)`."
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
async def _edit_impl(
|
|
140
|
+
*,
|
|
141
|
+
file_name: str | Path | None,
|
|
142
|
+
line: int,
|
|
143
|
+
col: int,
|
|
144
|
+
set_status: Literal["on", "off"] | None,
|
|
145
|
+
hint: str,
|
|
146
|
+
context: SolverContext | None,
|
|
147
|
+
) -> None:
|
|
148
|
+
"""Internal edit implementation shared by sync and async wrappers.
|
|
149
|
+
|
|
150
|
+
Notes
|
|
151
|
+
-----
|
|
152
|
+
Edit integration behavior:
|
|
153
|
+
- Start one socket service via ``JCMsolve --start_edit``.
|
|
154
|
+
- Send popup/edit messages over that socket.
|
|
155
|
+
This avoids direct ``JCMcontrol`` CLI argument handling, which can split
|
|
156
|
+
whitespace-containing hints in shell wrappers.
|
|
157
|
+
"""
|
|
158
|
+
|
|
159
|
+
resolved_context: SolverContext = resolve_context(context)
|
|
160
|
+
|
|
161
|
+
context_id: int = id(resolved_context)
|
|
162
|
+
message: str = "__popup__"
|
|
163
|
+
|
|
164
|
+
if file_name is not None:
|
|
165
|
+
file_path: Path = Path(file_name).expanduser().resolve()
|
|
166
|
+
if not file_path.is_file():
|
|
167
|
+
raise InvalidConfigurationError(f"Cannot access file {file_path}.")
|
|
168
|
+
|
|
169
|
+
resolved_line: int = int(line)
|
|
170
|
+
resolved_col: int = int(col)
|
|
171
|
+
if resolved_line < 1:
|
|
172
|
+
raise ValueError(f"Invalid parameter for line: {resolved_line}.")
|
|
173
|
+
if resolved_col < 1:
|
|
174
|
+
raise ValueError(f"Invalid parameter for col: {resolved_col}.")
|
|
175
|
+
|
|
176
|
+
# The edit backend interprets column coordinates one step higher than
|
|
177
|
+
# the user-facing value passed through this API.
|
|
178
|
+
# Keep external API 1-based and apply the backend offset here.
|
|
179
|
+
backend_col: int = resolved_col + 1
|
|
180
|
+
message = f"{file_path}!;!{resolved_line}!;!{backend_col}!;!{hint}"
|
|
181
|
+
|
|
182
|
+
if set_status is not None:
|
|
183
|
+
if set_status not in ("on", "off"):
|
|
184
|
+
raise ValueError('set_status must be either "on" or "off".')
|
|
185
|
+
_EDIT_STATUS_BY_CONTEXT_ID[context_id] = set_status == "on"
|
|
186
|
+
if set_status == "off":
|
|
187
|
+
message = "shutdown"
|
|
188
|
+
|
|
189
|
+
is_enabled: bool = _EDIT_STATUS_BY_CONTEXT_ID.get(context_id, True)
|
|
190
|
+
if not is_enabled and set_status != "on" and message != "shutdown":
|
|
191
|
+
_logger.warning(
|
|
192
|
+
'JCMedit was switched off. Use edit(set_status="on") to switch it on again.'
|
|
193
|
+
)
|
|
194
|
+
return
|
|
195
|
+
|
|
196
|
+
try:
|
|
197
|
+
_send_edit_message_with_restart(context=resolved_context, message=message)
|
|
198
|
+
except BackendUnavailableError as error:
|
|
199
|
+
_logger.warning("Could not start JCMedit. %s", error)
|
|
200
|
+
return
|
|
201
|
+
if message == "shutdown":
|
|
202
|
+
_close_edit_connection(context_id)
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def _send_edit_message_with_restart(*, context: SolverContext, message: str) -> None:
|
|
206
|
+
"""Send one edit message and restart socket transport once on failure."""
|
|
207
|
+
|
|
208
|
+
context_id: int = id(context)
|
|
209
|
+
connection: DaemonTransportConnection = _get_or_start_edit_connection(context)
|
|
210
|
+
try:
|
|
211
|
+
_ = send_daemon_message(
|
|
212
|
+
connection=connection,
|
|
213
|
+
message=message,
|
|
214
|
+
get_answer=False,
|
|
215
|
+
)
|
|
216
|
+
return
|
|
217
|
+
except Exception:
|
|
218
|
+
_logger.debug(
|
|
219
|
+
"Edit socket send failed; restarting edit service once.",
|
|
220
|
+
exc_info=True,
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
_close_edit_connection(context_id)
|
|
224
|
+
restarted_connection: DaemonTransportConnection = _get_or_start_edit_connection(
|
|
225
|
+
context
|
|
226
|
+
)
|
|
227
|
+
try:
|
|
228
|
+
_ = send_daemon_message(
|
|
229
|
+
connection=restarted_connection,
|
|
230
|
+
message=message,
|
|
231
|
+
get_answer=False,
|
|
232
|
+
)
|
|
233
|
+
except Exception as exception:
|
|
234
|
+
_close_edit_connection(context_id)
|
|
235
|
+
raise RuntimeContextError("Could not start JCMedit service.") from exception
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def _get_or_start_edit_connection(context: SolverContext) -> DaemonTransportConnection:
|
|
239
|
+
"""Return context-bound edit socket connection, starting it if needed."""
|
|
240
|
+
|
|
241
|
+
context_id: int = id(context)
|
|
242
|
+
existing_connection: DaemonTransportConnection | None = (
|
|
243
|
+
_EDIT_CONNECTION_BY_CONTEXT_ID.get(context_id)
|
|
244
|
+
)
|
|
245
|
+
if existing_connection is not None:
|
|
246
|
+
return existing_connection
|
|
247
|
+
|
|
248
|
+
solve_binary: Path | None = context.jcm_solve
|
|
249
|
+
if solve_binary is None or not solve_binary.is_file():
|
|
250
|
+
raise RuntimeContextError(
|
|
251
|
+
"JCMsolve binary is not available; cannot start JCMedit service."
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
try:
|
|
255
|
+
calling_pid: int = os.getppid()
|
|
256
|
+
except Exception:
|
|
257
|
+
calling_pid = 0
|
|
258
|
+
|
|
259
|
+
new_connection: DaemonTransportConnection = start_daemon_service(
|
|
260
|
+
jcm_solve_binary=solve_binary,
|
|
261
|
+
calling_pid=calling_pid,
|
|
262
|
+
start_command="--start_edit",
|
|
263
|
+
)
|
|
264
|
+
_EDIT_CONNECTION_BY_CONTEXT_ID[context_id] = new_connection
|
|
265
|
+
return new_connection
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def _close_edit_connection(context_id: int) -> None:
|
|
269
|
+
"""Close and remove a context-bound edit socket connection."""
|
|
270
|
+
|
|
271
|
+
connection: DaemonTransportConnection | None = _EDIT_CONNECTION_BY_CONTEXT_ID.pop(
|
|
272
|
+
context_id, None
|
|
273
|
+
)
|
|
274
|
+
close_daemon_connection(connection)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2001-2026 JCMwave GmbH
|
|
3
|
+
|
|
4
|
+
"""Public exception namespace for `jcmsuite`."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from .errors import (
|
|
9
|
+
BackendUnavailableError,
|
|
10
|
+
ConfigMappingError,
|
|
11
|
+
ContextConflictError,
|
|
12
|
+
InvalidConfigurationError,
|
|
13
|
+
JCMsuiteError,
|
|
14
|
+
RuntimeContextError,
|
|
15
|
+
SolveExecutionError,
|
|
16
|
+
SourceMappingError,
|
|
17
|
+
TemplateMappingError,
|
|
18
|
+
UnsupportedExportError,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
__all__: list[str] = [
|
|
22
|
+
"BackendUnavailableError",
|
|
23
|
+
"ConfigMappingError",
|
|
24
|
+
"ContextConflictError",
|
|
25
|
+
"InvalidConfigurationError",
|
|
26
|
+
"JCMsuiteError",
|
|
27
|
+
"RuntimeContextError",
|
|
28
|
+
"SourceMappingError",
|
|
29
|
+
"SolveExecutionError",
|
|
30
|
+
"TemplateMappingError",
|
|
31
|
+
"UnsupportedExportError",
|
|
32
|
+
]
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2001-2026 JCMwave GmbH
|
|
3
|
+
|
|
4
|
+
"""Exception hierarchy for `jcmsuite`."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
from collections.abc import Mapping
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Literal
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class JCMsuiteError(Exception):
|
|
14
|
+
"""Common parent for errors reported by `jcmsuite`."""
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class RuntimeContextError(JCMsuiteError):
|
|
18
|
+
"""Error raised when JCMsuite settings are missing or cannot be used."""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class InvalidConfigurationError(JCMsuiteError):
|
|
22
|
+
"""Error raised when an input or setting is not valid."""
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class UnsupportedExportError(JCMsuiteError, NotImplementedError):
|
|
26
|
+
"""Error raised when result data cannot use the requested export format."""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class BackendUnavailableError(JCMsuiteError):
|
|
30
|
+
"""Error raised when the requested execution method is not available."""
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class SolveExecutionError(RuntimeError):
|
|
34
|
+
"""Error raised when a local or daemon solve fails.
|
|
35
|
+
|
|
36
|
+
Public solve and deferred-wait calls trim deep internal traceback frames
|
|
37
|
+
before they re-raise this error. The exception and its solver diagnostics
|
|
38
|
+
remain available to callers.
|
|
39
|
+
|
|
40
|
+
Parameters
|
|
41
|
+
----------
|
|
42
|
+
backend : Literal["local", "daemon"]
|
|
43
|
+
Backend that executed the solve.
|
|
44
|
+
exit_code : int
|
|
45
|
+
Exit code reported by the solver or daemon.
|
|
46
|
+
log : str
|
|
47
|
+
Diagnostic text reported by the backend.
|
|
48
|
+
job_id : int | None
|
|
49
|
+
Daemon job identifier, or `None` for a local solve.
|
|
50
|
+
job_info : Mapping[str, object] | None
|
|
51
|
+
Additional daemon information, or `None` for a local solve.
|
|
52
|
+
|
|
53
|
+
Attributes
|
|
54
|
+
----------
|
|
55
|
+
backend : Literal["local", "daemon"]
|
|
56
|
+
Backend that executed the solve.
|
|
57
|
+
exit_code : int
|
|
58
|
+
Exit code reported by the solver or daemon.
|
|
59
|
+
log : str
|
|
60
|
+
Diagnostic text reported by the backend.
|
|
61
|
+
job_id : int | None
|
|
62
|
+
Daemon job identifier, or `None` for a local solve.
|
|
63
|
+
job_info : dict[str, object] | None
|
|
64
|
+
Additional daemon information, or `None` for a local solve.
|
|
65
|
+
"""
|
|
66
|
+
|
|
67
|
+
def __init__(
|
|
68
|
+
self,
|
|
69
|
+
*,
|
|
70
|
+
backend: Literal["local", "daemon"],
|
|
71
|
+
exit_code: int,
|
|
72
|
+
log: str,
|
|
73
|
+
job_id: int | None = None,
|
|
74
|
+
job_info: Mapping[str, object] | None = None,
|
|
75
|
+
) -> None:
|
|
76
|
+
|
|
77
|
+
self.backend: Literal["local", "daemon"] = backend
|
|
78
|
+
self.job_id: int | None = job_id
|
|
79
|
+
self.exit_code: int = exit_code
|
|
80
|
+
self.log: str = log
|
|
81
|
+
self.job_info: dict[str, object] | None = (
|
|
82
|
+
None if job_info is None else dict(job_info)
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
message: str
|
|
86
|
+
if backend == "local":
|
|
87
|
+
message = f"*** JCMsolve failed. ==>\n\n{log}"
|
|
88
|
+
elif log.strip():
|
|
89
|
+
message = (
|
|
90
|
+
f"Daemon job {job_id} failed with exit code {exit_code}. ==>\n\n"
|
|
91
|
+
f"{log}"
|
|
92
|
+
)
|
|
93
|
+
else:
|
|
94
|
+
message = (
|
|
95
|
+
f"Daemon job {job_id} failed with exit code {exit_code}, "
|
|
96
|
+
"but daemon returned an empty log. "
|
|
97
|
+
f"Raw job info: {self.job_info!r}"
|
|
98
|
+
)
|
|
99
|
+
super().__init__(message)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class ContextConflictError(JCMsuiteError):
|
|
103
|
+
"""Error raised when one operation receives two different contexts."""
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class SourceMappingError(JCMsuiteError):
|
|
107
|
+
"""Error raised for a problem at a known position in a source file.
|
|
108
|
+
|
|
109
|
+
Parameters
|
|
110
|
+
----------
|
|
111
|
+
message : str
|
|
112
|
+
Description of the problem.
|
|
113
|
+
source : str | Path | None, optional
|
|
114
|
+
Source file associated with the diagnostic.
|
|
115
|
+
line : int | None, optional
|
|
116
|
+
One-based source line, if known.
|
|
117
|
+
column : int | None, optional
|
|
118
|
+
One-based source column, if known.
|
|
119
|
+
"""
|
|
120
|
+
|
|
121
|
+
def __init__(
|
|
122
|
+
self,
|
|
123
|
+
message: str,
|
|
124
|
+
*,
|
|
125
|
+
source: str | Path | None = None,
|
|
126
|
+
line: int | None = None,
|
|
127
|
+
column: int | None = None,
|
|
128
|
+
) -> None:
|
|
129
|
+
|
|
130
|
+
source_text: str = str(source) if source is not None else "<unknown>"
|
|
131
|
+
line_text: str = "?" if line is None else str(line)
|
|
132
|
+
column_text: str = "?" if column is None else str(column)
|
|
133
|
+
detail: str = (
|
|
134
|
+
f"{message} (source={source_text}, line={line_text}, column={column_text})"
|
|
135
|
+
)
|
|
136
|
+
super().__init__(detail)
|
|
137
|
+
self.source: str | Path | None = source
|
|
138
|
+
self.line: int | None = line
|
|
139
|
+
self.column: int | None = column
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
class TemplateMappingError(SourceMappingError):
|
|
143
|
+
"""Error raised for a problem in a JCMsuite template file.
|
|
144
|
+
|
|
145
|
+
Parameters
|
|
146
|
+
----------
|
|
147
|
+
message : str
|
|
148
|
+
Description of the problem.
|
|
149
|
+
source : str | Path | None, optional
|
|
150
|
+
Template file associated with the diagnostic.
|
|
151
|
+
line : int | None, optional
|
|
152
|
+
One-based source line, if known.
|
|
153
|
+
column : int | None, optional
|
|
154
|
+
One-based source column, if known.
|
|
155
|
+
"""
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
class ConfigMappingError(SourceMappingError):
|
|
159
|
+
"""Error raised for a JCMsuite input error at a known source position.
|
|
160
|
+
|
|
161
|
+
Parameters
|
|
162
|
+
----------
|
|
163
|
+
message : str
|
|
164
|
+
Description of the problem.
|
|
165
|
+
source : str | Path | None, optional
|
|
166
|
+
Original JCMsuite input file associated with the diagnostic. For daemon
|
|
167
|
+
execution in a separate working directory, this is the source file, not
|
|
168
|
+
its staged copy.
|
|
169
|
+
line : int | None, optional
|
|
170
|
+
One-based source line, if known.
|
|
171
|
+
column : int | None, optional
|
|
172
|
+
One-based source column, if known.
|
|
173
|
+
"""
|