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,142 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT
|
|
2
|
+
# Copyright (c) 2001-2026 JCMwave GmbH
|
|
3
|
+
|
|
4
|
+
"""Source-file metadata helpers for Resultbag."""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import hashlib
|
|
9
|
+
import json
|
|
10
|
+
from collections.abc import Sequence
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Protocol, cast
|
|
13
|
+
|
|
14
|
+
from ....exceptions import InvalidConfigurationError
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class _ResultbagMetadataProtocol(Protocol):
|
|
18
|
+
"""Protocol for metadata methods consumed by source-file mixin."""
|
|
19
|
+
|
|
20
|
+
def _set_metadata(self, key: str, value: str) -> None:
|
|
21
|
+
"""Persist one metadata key/value pair."""
|
|
22
|
+
|
|
23
|
+
def _get_metadata(self, key: str) -> str | None:
|
|
24
|
+
"""Read one metadata value by key."""
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class ResultbagSourceFilesMixin:
|
|
28
|
+
"""Source-file consistency helper methods for Resultbag internals."""
|
|
29
|
+
|
|
30
|
+
def ignore_source_files(self, ignore: bool = True) -> None:
|
|
31
|
+
"""Toggle source-file consistency checks.
|
|
32
|
+
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
ignore : bool, optional
|
|
36
|
+
Whether source-file checks should be skipped.
|
|
37
|
+
|
|
38
|
+
Returns
|
|
39
|
+
-------
|
|
40
|
+
None
|
|
41
|
+
Stores the ignore flag in metadata.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
owner: _ResultbagMetadataProtocol = cast(_ResultbagMetadataProtocol, self)
|
|
45
|
+
owner._set_metadata("ignore_source_files", json.dumps(bool(ignore)))
|
|
46
|
+
|
|
47
|
+
def _hash_source_file(self, source_file: Path) -> str:
|
|
48
|
+
"""Compute a SHA-256 digest for source-file consistency checks.
|
|
49
|
+
|
|
50
|
+
Parameters
|
|
51
|
+
----------
|
|
52
|
+
source_file : Path
|
|
53
|
+
Filesystem path supplied via `source_file`.
|
|
54
|
+
|
|
55
|
+
Returns
|
|
56
|
+
-------
|
|
57
|
+
str
|
|
58
|
+
Normalized string value.
|
|
59
|
+
|
|
60
|
+
Notes
|
|
61
|
+
-----
|
|
62
|
+
Internal API: this helper is an implementation detail and may change
|
|
63
|
+
without notice.
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
hasher = hashlib.sha256()
|
|
67
|
+
with source_file.open("rb") as source_stream:
|
|
68
|
+
chunk: bytes
|
|
69
|
+
for chunk in iter(lambda: source_stream.read(65536), b""):
|
|
70
|
+
hasher.update(chunk)
|
|
71
|
+
return hasher.hexdigest()
|
|
72
|
+
|
|
73
|
+
def set_source_files(self, files: Sequence[str | Path]) -> None:
|
|
74
|
+
"""Store source-file hashes used for current result validity.
|
|
75
|
+
|
|
76
|
+
Parameters
|
|
77
|
+
----------
|
|
78
|
+
files : Sequence[str | Path]
|
|
79
|
+
Source files defining current result validity.
|
|
80
|
+
|
|
81
|
+
Returns
|
|
82
|
+
-------
|
|
83
|
+
None
|
|
84
|
+
Stores normalized path/hash metadata for later checks.
|
|
85
|
+
|
|
86
|
+
Raises
|
|
87
|
+
------
|
|
88
|
+
InvalidConfigurationError
|
|
89
|
+
If any provided path is missing or not a regular file.
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
source_metadata: dict[str, str] = {}
|
|
93
|
+
raw_file: str | Path
|
|
94
|
+
for raw_file in files:
|
|
95
|
+
source_path: Path = Path(raw_file).expanduser().resolve()
|
|
96
|
+
if not source_path.is_file():
|
|
97
|
+
raise InvalidConfigurationError(
|
|
98
|
+
f"Source file is missing or not a file: {source_path}"
|
|
99
|
+
)
|
|
100
|
+
source_metadata[str(source_path)] = self._hash_source_file(source_path)
|
|
101
|
+
owner: _ResultbagMetadataProtocol = cast(_ResultbagMetadataProtocol, self)
|
|
102
|
+
owner._set_metadata("source_files", json.dumps(source_metadata, sort_keys=True))
|
|
103
|
+
|
|
104
|
+
def check_source_files(self, files: Sequence[str | Path]) -> bool:
|
|
105
|
+
"""Check whether source files still match stored source metadata.
|
|
106
|
+
|
|
107
|
+
Parameters
|
|
108
|
+
----------
|
|
109
|
+
files : Sequence[str | Path]
|
|
110
|
+
Source files to validate against stored metadata.
|
|
111
|
+
|
|
112
|
+
Returns
|
|
113
|
+
-------
|
|
114
|
+
bool
|
|
115
|
+
`True` when current hashes match stored hashes, or when source-file
|
|
116
|
+
checks are explicitly ignored.
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
owner: _ResultbagMetadataProtocol = cast(_ResultbagMetadataProtocol, self)
|
|
120
|
+
ignore_raw: str | None = owner._get_metadata("ignore_source_files")
|
|
121
|
+
if ignore_raw is not None and json.loads(ignore_raw):
|
|
122
|
+
return True
|
|
123
|
+
|
|
124
|
+
stored_raw: str | None = owner._get_metadata("source_files")
|
|
125
|
+
if stored_raw is None:
|
|
126
|
+
return False
|
|
127
|
+
stored_metadata: object = json.loads(stored_raw)
|
|
128
|
+
if not isinstance(stored_metadata, dict):
|
|
129
|
+
return False
|
|
130
|
+
stored_hashes: dict[str, str] = {
|
|
131
|
+
str(key): str(value) for key, value in stored_metadata.items()
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
current_hashes: dict[str, str] = {}
|
|
135
|
+
raw_file: str | Path
|
|
136
|
+
for raw_file in files:
|
|
137
|
+
source_path: Path = Path(raw_file).expanduser().resolve()
|
|
138
|
+
if not source_path.is_file():
|
|
139
|
+
return False
|
|
140
|
+
current_hashes[str(source_path)] = self._hash_source_file(source_path)
|
|
141
|
+
|
|
142
|
+
return current_hashes == stored_hashes
|