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,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