sillon 2.2.0__tar.gz → 2.3.0__tar.gz
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.
- {sillon-2.2.0/sillon.egg-info → sillon-2.3.0}/PKG-INFO +1 -1
- {sillon-2.2.0 → sillon-2.3.0}/packages/common/src/silloncommon/__init__.py +1 -1
- {sillon-2.2.0 → sillon-2.3.0}/packages/core/src/silloncore/diff.py +142 -43
- {sillon-2.2.0 → sillon-2.3.0}/packages/core/src/silloncore/display.py +65 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/core/src/silloncore/engine.py +105 -12
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/versions.py +48 -9
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/project.py +6 -1
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/views/output_view.py +52 -5
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/sillonlab/src/sillonlab/project.py +66 -0
- {sillon-2.2.0 → sillon-2.3.0/sillon.egg-info}/PKG-INFO +1 -1
- {sillon-2.2.0 → sillon-2.3.0}/LICENSE +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/README.md +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/common/src/silloncommon/access_log.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/common/src/silloncommon/codeversion.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/common/src/silloncommon/commands.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/common/src/silloncommon/database.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/common/src/silloncommon/framing.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/common/src/silloncommon/hashing.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/common/src/silloncommon/hdf5_staging.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/common/src/silloncommon/project_config.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/common/src/silloncommon/registry.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/common/src/silloncommon/rpcHandler.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/common/src/silloncommon/socket_path.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/common/src/silloncommon/source_store.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/common/src/silloncommon/timestamps.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/common/src/silloncommon/transport.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/common/src/silloncommon/user_paths.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/core/src/silloncore/__init__.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/core/src/silloncore/bundle.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/core/src/silloncore/check.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/core/src/silloncore/envhandler.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/core/src/silloncore/glob.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/core/src/silloncore/project_paths.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/core/src/silloncore/projects.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/core/src/silloncore/server/__init__.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/core/src/silloncore/server/main.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/core/src/silloncore/server/server.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/core/src/silloncore/server/visitor.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/core/src/silloncore/simulation.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/core/src/silloncore/transfer.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/core/src/silloncore/versioncontrol.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/__init__.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/__init__.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/add.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/check.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/delete.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/diff.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/export.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/fetch.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/gui.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/import_cmd.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/init.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/like.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/lineage.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/list.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/projects.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/prune.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/query.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/rename.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/report.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/show.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/commands/trace.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/context.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/cli/src/silloncli/main.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/__init__.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/__main__.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/app.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/models/__init__.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/models/run_model.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/preferences.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/query.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/theme.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/views/__init__.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/views/data_tab.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/views/data_view.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/views/details_view.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/views/errors.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/views/export_dialog.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/views/figure_view.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/views/main_window.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/views/query_bar.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/views/run_list.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/views/settings_dialog.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/views/source_view.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/views/title_bar.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/views/vibrancy.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/views/widgets.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/workers/__init__.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/gui/src/sillongui/workers/task.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/sillonlab/src/sillonlab/__init__.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/sillonlab/src/sillonlab/display.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/sillonlab/src/sillonlab/projects.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/interface/sillonlab/src/sillonlab/run.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/pyapi/src/sillonpy/__init__.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/pyapi/src/sillonpy/api.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/pyapi/src/sillonpy/daemon.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/pyapi/src/sillonpy/metadata.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/pyapi/src/sillonpy/serverCom.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/packages/pyapi/src/sillonpy/tracker.py +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/pyproject.toml +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/setup.cfg +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/sillon.egg-info/SOURCES.txt +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/sillon.egg-info/dependency_links.txt +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/sillon.egg-info/entry_points.txt +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/sillon.egg-info/requires.txt +0 -0
- {sillon-2.2.0 → sillon-2.3.0}/sillon.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sillon
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: Git for simulations — log, track, query and analyze simulation runs.
|
|
5
5
|
Author-email: Guillaume Tassotti <placeholder@email.com>, Baptiste Lerat <lerat.baptiste99@proton.ch>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -17,8 +17,9 @@ were not compared, rather than stalling a diff on a gigabyte.
|
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
19
|
import math
|
|
20
|
-
from difflib import unified_diff
|
|
20
|
+
from difflib import SequenceMatcher, unified_diff
|
|
21
21
|
|
|
22
|
+
from silloncommon.codeversion import source_hash
|
|
22
23
|
from silloncommon.source_store import read_source
|
|
23
24
|
|
|
24
25
|
from silloncore.glob import glob_descriptors, read_glob
|
|
@@ -28,7 +29,7 @@ from silloncore.glob import glob_descriptors, read_glob
|
|
|
28
29
|
# still covering most of what people actually compare.
|
|
29
30
|
DEFAULT_MAX_COMPARE_BYTES = 64 * 1024 * 1024
|
|
30
31
|
|
|
31
|
-
__all__ = ["diff_runs", "diff_across", "percent_delta", "DEFAULT_MAX_COMPARE_BYTES"]
|
|
32
|
+
__all__ = ["diff_runs", "compare_code", "diff_across", "percent_delta", "DEFAULT_MAX_COMPARE_BYTES"]
|
|
32
33
|
|
|
33
34
|
|
|
34
35
|
# ==========================================
|
|
@@ -172,62 +173,160 @@ def _code_files(snapshot) -> dict:
|
|
|
172
173
|
return version.get("files") or {}
|
|
173
174
|
|
|
174
175
|
|
|
176
|
+
# A version recovered by `backfill_code_versions` names its one file this way.
|
|
177
|
+
ENTRY_PLACEHOLDER = "<entry script>"
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
class _Lazy:
|
|
181
|
+
"""A value computed on first use: a run's main source is an HDF5 read,
|
|
182
|
+
needed only when the source store lacks a file."""
|
|
183
|
+
|
|
184
|
+
def __init__(self, compute):
|
|
185
|
+
self._compute, self._done, self._value = compute, compute is None, None
|
|
186
|
+
|
|
187
|
+
def get(self):
|
|
188
|
+
if not self._done:
|
|
189
|
+
self._value, self._done = self._compute(), True
|
|
190
|
+
return self._value
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def _read_text(storage_root, hashes: dict, main: _Lazy):
|
|
194
|
+
"""A file's text from the source store; for an entry script logged before
|
|
195
|
+
the store kept it, the run's own copy (same hash, same text)."""
|
|
196
|
+
digest = hashes.get("source_hash")
|
|
197
|
+
if not digest:
|
|
198
|
+
return None
|
|
199
|
+
text = read_source(storage_root, digest)
|
|
200
|
+
if text is None:
|
|
201
|
+
recorded = main.get()
|
|
202
|
+
if recorded is not None and source_hash(recorded) == digest:
|
|
203
|
+
text = recorded
|
|
204
|
+
return text
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
# Below this, a placeholder and a file are unrelated scripts, not two versions of one.
|
|
208
|
+
_SAME_SCRIPT = 0.5
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def _closest(storage_root, hashes: dict, main: _Lazy, candidates: dict, other_main: _Lazy):
|
|
212
|
+
"""The candidate file most like the script behind `hashes`, if any is alike."""
|
|
213
|
+
for name, candidate in candidates.items():
|
|
214
|
+
if candidate.get("source_hash") == hashes.get("source_hash"):
|
|
215
|
+
return name
|
|
216
|
+
text = _read_text(storage_root, hashes, main)
|
|
217
|
+
if text is None:
|
|
218
|
+
return None
|
|
219
|
+
best, score = None, _SAME_SCRIPT
|
|
220
|
+
for name, candidate in candidates.items():
|
|
221
|
+
other = _read_text(storage_root, candidate, other_main)
|
|
222
|
+
if other is None:
|
|
223
|
+
continue
|
|
224
|
+
ratio = SequenceMatcher(None, text, other, autojunk=False).quick_ratio()
|
|
225
|
+
if ratio > score:
|
|
226
|
+
best, score = name, ratio
|
|
227
|
+
return best
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def _file_status(a: dict, b: dict) -> str:
|
|
231
|
+
if a.get("logic_hash") != b.get("logic_hash"):
|
|
232
|
+
return "changed"
|
|
233
|
+
if a.get("ast_hash") != b.get("ast_hash"):
|
|
234
|
+
return "constants" # same program, different literals
|
|
235
|
+
if a.get("source_hash") != b.get("source_hash"):
|
|
236
|
+
return "cosmetic" # comments or formatting only
|
|
237
|
+
return "same"
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def compare_code(storage_root, files_a: dict, files_b: dict, label_a: str, label_b: str,
|
|
241
|
+
main_a=None, main_b=None) -> dict:
|
|
242
|
+
"""Compares two sets of recorded code files, down to the changed lines.
|
|
243
|
+
|
|
244
|
+
Args:
|
|
245
|
+
storage_root: The project's storage root (holds the source store).
|
|
246
|
+
files_a, files_b (dict): `{name: {"source_hash", "ast_hash",
|
|
247
|
+
"logic_hash"}}`, as in `sillon.code.version`.
|
|
248
|
+
label_a, label_b (str): What each side is called in the diff headers
|
|
249
|
+
(a run name, a version prefix).
|
|
250
|
+
main_a, main_b (callable, optional): Return the side's recorded main
|
|
251
|
+
source, used when the store lacks the entry script. Called at most
|
|
252
|
+
once, and only when needed.
|
|
253
|
+
|
|
254
|
+
Returns:
|
|
255
|
+
dict: `{"files": {name: {"status", "diff", "missing"}},
|
|
256
|
+
"constants_differ", "source_diff"}`. `status` is one of
|
|
257
|
+
added, removed, changed, constants, cosmetic, same; `diff` is that
|
|
258
|
+
file's unified diff; `missing` is True when its text could not be
|
|
259
|
+
read, so no diff could be made.
|
|
260
|
+
"""
|
|
261
|
+
mains = (_Lazy(main_a), _Lazy(main_b))
|
|
262
|
+
files_a, files_b = dict(files_a), dict(files_b)
|
|
263
|
+
# A backfilled version knows its entry script only as a placeholder: pair
|
|
264
|
+
# it with the file it most resembles on the other side rather than report
|
|
265
|
+
# one file removed and another added.
|
|
266
|
+
for this, other, sides in ((files_a, files_b, mains), (files_b, files_a, mains[::-1])):
|
|
267
|
+
if ENTRY_PLACEHOLDER in this and ENTRY_PLACEHOLDER not in other:
|
|
268
|
+
name = _closest(storage_root, this[ENTRY_PLACEHOLDER], sides[0],
|
|
269
|
+
{n: h for n, h in other.items() if n not in this}, sides[1])
|
|
270
|
+
if name:
|
|
271
|
+
this[name] = this.pop(ENTRY_PLACEHOLDER)
|
|
272
|
+
|
|
273
|
+
files, diffs, constants = {}, [], False
|
|
274
|
+
for name in sorted(set(files_a) | set(files_b)):
|
|
275
|
+
a, b = files_a.get(name), files_b.get(name)
|
|
276
|
+
if a is None:
|
|
277
|
+
status = "added"
|
|
278
|
+
elif b is None:
|
|
279
|
+
status = "removed"
|
|
280
|
+
else:
|
|
281
|
+
status = _file_status(a, b)
|
|
282
|
+
constants = constants or status == "constants"
|
|
283
|
+
info = {"status": status, "diff": "", "missing": False}
|
|
284
|
+
if status != "same":
|
|
285
|
+
text_a = "" if a is None else _read_text(storage_root, a, mains[0])
|
|
286
|
+
text_b = "" if b is None else _read_text(storage_root, b, mains[1])
|
|
287
|
+
if text_a is None or text_b is None:
|
|
288
|
+
info["missing"] = True
|
|
289
|
+
else:
|
|
290
|
+
info["diff"] = "".join(
|
|
291
|
+
unified_diff(
|
|
292
|
+
text_a.splitlines(keepends=True),
|
|
293
|
+
text_b.splitlines(keepends=True),
|
|
294
|
+
fromfile="/dev/null" if a is None else f"{name} @ {label_a}",
|
|
295
|
+
tofile="/dev/null" if b is None else f"{name} @ {label_b}",
|
|
296
|
+
)
|
|
297
|
+
)
|
|
298
|
+
if info["diff"] and not info["diff"].endswith("\n"):
|
|
299
|
+
info["diff"] += "\n"
|
|
300
|
+
diffs.append(info["diff"])
|
|
301
|
+
files[name] = info
|
|
302
|
+
|
|
303
|
+
return {"files": files, "constants_differ": constants, "source_diff": "".join(diffs)}
|
|
304
|
+
|
|
305
|
+
|
|
175
306
|
def _diff_code(storage_root, snap_a, snap_b) -> dict:
|
|
176
307
|
"""Compare the code behind two runs, using the recorded version hashes.
|
|
177
308
|
|
|
178
309
|
The useful distinction, and the reason code versions exist: *same logic,
|
|
179
310
|
only a constant differs* is a comparable pair; a changed expression is not.
|
|
180
311
|
"""
|
|
312
|
+
from silloncore.engine import load_run_source
|
|
313
|
+
|
|
181
314
|
files_a, files_b = _code_files(snap_a), _code_files(snap_b)
|
|
182
315
|
version_a = snap_a.get("logic_version")
|
|
183
316
|
version_b = snap_b.get("logic_version")
|
|
184
317
|
|
|
185
|
-
|
|
318
|
+
compared = compare_code(
|
|
319
|
+
storage_root, files_a, files_b, snap_a["name"], snap_b["name"],
|
|
320
|
+
main_a=lambda: load_run_source(storage_root, snap_a),
|
|
321
|
+
main_b=lambda: load_run_source(storage_root, snap_b),
|
|
322
|
+
)
|
|
323
|
+
return {
|
|
186
324
|
"logic_version": (version_a, version_b),
|
|
187
325
|
"same_logic": bool(version_a) and version_a == version_b,
|
|
188
326
|
"known": bool(files_a or files_b or version_a or version_b),
|
|
189
|
-
|
|
190
|
-
"constants_differ": False,
|
|
191
|
-
"source_diff": "",
|
|
327
|
+
**compared,
|
|
192
328
|
}
|
|
193
329
|
|
|
194
|
-
diffs = []
|
|
195
|
-
for name in sorted(set(files_a) | set(files_b)):
|
|
196
|
-
a, b = files_a.get(name), files_b.get(name)
|
|
197
|
-
if a is None:
|
|
198
|
-
result["files"][name] = {"status": "added"}
|
|
199
|
-
continue
|
|
200
|
-
if b is None:
|
|
201
|
-
result["files"][name] = {"status": "removed"}
|
|
202
|
-
continue
|
|
203
|
-
|
|
204
|
-
if a["logic_hash"] != b["logic_hash"]:
|
|
205
|
-
status = "changed"
|
|
206
|
-
elif a["ast_hash"] != b["ast_hash"]:
|
|
207
|
-
status = "constants" # same program, different literals
|
|
208
|
-
result["constants_differ"] = True
|
|
209
|
-
elif a["source_hash"] != b["source_hash"]:
|
|
210
|
-
status = "cosmetic" # comments or formatting only
|
|
211
|
-
else:
|
|
212
|
-
status = "same"
|
|
213
|
-
result["files"][name] = {"status": status}
|
|
214
|
-
|
|
215
|
-
if status in ("changed", "constants"):
|
|
216
|
-
text_a = read_source(storage_root, a["source_hash"])
|
|
217
|
-
text_b = read_source(storage_root, b["source_hash"])
|
|
218
|
-
if text_a is not None and text_b is not None:
|
|
219
|
-
diffs.extend(
|
|
220
|
-
unified_diff(
|
|
221
|
-
text_a.splitlines(keepends=True),
|
|
222
|
-
text_b.splitlines(keepends=True),
|
|
223
|
-
fromfile=f"{name} @ {snap_a['name']}",
|
|
224
|
-
tofile=f"{name} @ {snap_b['name']}",
|
|
225
|
-
)
|
|
226
|
-
)
|
|
227
|
-
|
|
228
|
-
result["source_diff"] = "".join(diffs)
|
|
229
|
-
return result
|
|
230
|
-
|
|
231
330
|
|
|
232
331
|
# ==========================================
|
|
233
332
|
# PAIRWISE
|
|
@@ -373,6 +373,8 @@ __all__ = [
|
|
|
373
373
|
"print_projects",
|
|
374
374
|
"print_code_versions",
|
|
375
375
|
"print_code_version_files",
|
|
376
|
+
"print_code_version_runs",
|
|
377
|
+
"print_code_version_diff",
|
|
376
378
|
"print_diff",
|
|
377
379
|
"print_source_diff",
|
|
378
380
|
"print_diff_across",
|
|
@@ -486,6 +488,69 @@ def print_code_version_files(detail: dict) -> None:
|
|
|
486
488
|
)
|
|
487
489
|
|
|
488
490
|
|
|
491
|
+
def print_code_version_runs(detail: dict) -> None:
|
|
492
|
+
"""Prints a `silloncore.engine.get_code_version_runs` payload."""
|
|
493
|
+
table = themed_table(padding=(0, 2))
|
|
494
|
+
table.add_column("Run", style=f"bold {c('spray')}", overflow="fold", ratio=1)
|
|
495
|
+
table.add_column("Status")
|
|
496
|
+
table.add_column("Date", style=S_DIM)
|
|
497
|
+
table.add_column("Tags", style=c("wake"))
|
|
498
|
+
for run in detail["runs"]:
|
|
499
|
+
table.add_row(
|
|
500
|
+
Text(run["name"]),
|
|
501
|
+
status_text(run["status"]),
|
|
502
|
+
relative_time(run["date"]) if run["date"] else "—",
|
|
503
|
+
", ".join(str(t) for t in run["tags"]) or "—",
|
|
504
|
+
)
|
|
505
|
+
count = len(detail["runs"])
|
|
506
|
+
summary = f"{count} run{'s' if count != 1 else ''} used this version"
|
|
507
|
+
if detail.get("partial"):
|
|
508
|
+
summary += " — entry script only"
|
|
509
|
+
subtitle = Text(summary, style=f"italic {c('ember')}")
|
|
510
|
+
console.print(
|
|
511
|
+
themed_panel(
|
|
512
|
+
Group(subtitle, Text(""), table),
|
|
513
|
+
title=f"version · {short_id(detail['logic_version'])}",
|
|
514
|
+
)
|
|
515
|
+
)
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
_CODE_STATUS = {
|
|
519
|
+
"added": ("added", "#6FCF8E"),
|
|
520
|
+
"removed": ("removed", "#E06C75"),
|
|
521
|
+
"changed": ("logic changed", "#E06C75"),
|
|
522
|
+
"constants": ("constants only", None),
|
|
523
|
+
"cosmetic": ("comments or formatting", None),
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
def print_code_version_diff(result: dict) -> None:
|
|
528
|
+
"""Prints a `silloncore.engine.diff_code_versions` payload: which files
|
|
529
|
+
moved, then the unified source diff."""
|
|
530
|
+
old, new = (short_id(v) for v in result["versions"])
|
|
531
|
+
moved = {n: f for n, f in result["files"].items() if f["status"] != "same"}
|
|
532
|
+
title = f"{old} → {new}"
|
|
533
|
+
if not moved:
|
|
534
|
+
console.print(themed_panel(
|
|
535
|
+
Text("The two versions have the same source.", style=S_DIM), title=title))
|
|
536
|
+
return
|
|
537
|
+
|
|
538
|
+
table = themed_table(padding=(0, 2))
|
|
539
|
+
table.add_column("File", style=f"bold {c('spray')}", overflow="fold", ratio=1)
|
|
540
|
+
table.add_column("Change")
|
|
541
|
+
table.add_column("", style=S_DIM)
|
|
542
|
+
for name, info in moved.items():
|
|
543
|
+
label, colour = _CODE_STATUS.get(info["status"], (info["status"], None))
|
|
544
|
+
note = "source not recorded" if info["missing"] else ""
|
|
545
|
+
table.add_row(Text(name), Text(label, style=colour or c("ember")), note)
|
|
546
|
+
same = len(result["files"]) - len(moved)
|
|
547
|
+
subtitle = Text(f"{same} file(s) unchanged", style=f"italic {c('slate')}")
|
|
548
|
+
if any(result.get("partial") or ()):
|
|
549
|
+
subtitle.append(" — a version recovered by --backfill covers its entry script only")
|
|
550
|
+
console.print(themed_panel(Group(table, Text(""), subtitle), title=title))
|
|
551
|
+
print_source_diff(result["source_diff"])
|
|
552
|
+
|
|
553
|
+
|
|
489
554
|
def _fmt_delta(pct):
|
|
490
555
|
if pct is None:
|
|
491
556
|
return ""
|
|
@@ -1453,6 +1453,22 @@ def get_code_versions(engine) -> list:
|
|
|
1453
1453
|
return out
|
|
1454
1454
|
|
|
1455
1455
|
|
|
1456
|
+
def _find_code_version(groups: list, logic_version: str) -> dict:
|
|
1457
|
+
"""The one group of `get_code_versions` whose version starts with `logic_version`."""
|
|
1458
|
+
matches = [
|
|
1459
|
+
group
|
|
1460
|
+
for group in groups
|
|
1461
|
+
if group["logic_version"] and group["logic_version"].startswith(logic_version)
|
|
1462
|
+
]
|
|
1463
|
+
if not matches:
|
|
1464
|
+
raise LookupError(f"No code version matching '{logic_version}'.")
|
|
1465
|
+
if len(matches) > 1:
|
|
1466
|
+
raise LookupError(
|
|
1467
|
+
f"'{logic_version}' matches {len(matches)} code versions — use more characters."
|
|
1468
|
+
)
|
|
1469
|
+
return matches[0]
|
|
1470
|
+
|
|
1471
|
+
|
|
1456
1472
|
def get_code_version_files(engine, logic_version: str) -> dict:
|
|
1457
1473
|
"""The per-file hashes of one code version.
|
|
1458
1474
|
|
|
@@ -1466,18 +1482,7 @@ def get_code_version_files(engine, logic_version: str) -> dict:
|
|
|
1466
1482
|
Returns:
|
|
1467
1483
|
dict: `{"logic_version": str, "files": {name: {hashes}}, "run_count": int}`.
|
|
1468
1484
|
"""
|
|
1469
|
-
|
|
1470
|
-
group
|
|
1471
|
-
for group in get_code_versions(engine)
|
|
1472
|
-
if group["logic_version"] and group["logic_version"].startswith(logic_version)
|
|
1473
|
-
]
|
|
1474
|
-
if not matches:
|
|
1475
|
-
raise LookupError(f"No code version matching '{logic_version}'.")
|
|
1476
|
-
if len(matches) > 1:
|
|
1477
|
-
raise LookupError(
|
|
1478
|
-
f"'{logic_version}' matches {len(matches)} code versions — use more characters."
|
|
1479
|
-
)
|
|
1480
|
-
group = matches[0]
|
|
1485
|
+
group = _find_code_version(get_code_versions(engine), logic_version)
|
|
1481
1486
|
return {
|
|
1482
1487
|
"logic_version": group["logic_version"],
|
|
1483
1488
|
"files": group["files"],
|
|
@@ -1485,6 +1490,94 @@ def get_code_version_files(engine, logic_version: str) -> dict:
|
|
|
1485
1490
|
}
|
|
1486
1491
|
|
|
1487
1492
|
|
|
1493
|
+
def get_code_version_runs(engine, logic_version: str) -> dict:
|
|
1494
|
+
"""Every run that one code version produced, newest first.
|
|
1495
|
+
|
|
1496
|
+
Args:
|
|
1497
|
+
engine (Engine): The active SQLAlchemy database engine.
|
|
1498
|
+
logic_version (str): A full version hash or an unambiguous prefix.
|
|
1499
|
+
|
|
1500
|
+
Raises:
|
|
1501
|
+
LookupError: If no version matches, or a prefix matches several.
|
|
1502
|
+
|
|
1503
|
+
Returns:
|
|
1504
|
+
dict: `{"logic_version", "partial", "files", "runs"}`, where each run
|
|
1505
|
+
is `{"name", "uuid", "date", "status", "tags"}`.
|
|
1506
|
+
"""
|
|
1507
|
+
group = _find_code_version(get_code_versions(engine), logic_version)
|
|
1508
|
+
entries = [e for e in select_run_index(engine) if e.get("logic_version") == group["logic_version"]]
|
|
1509
|
+
entries.sort(key=lambda e: e.get("when") or "", reverse=True)
|
|
1510
|
+
return {
|
|
1511
|
+
"logic_version": group["logic_version"],
|
|
1512
|
+
"partial": group["partial"],
|
|
1513
|
+
"files": group["files"],
|
|
1514
|
+
"runs": [
|
|
1515
|
+
{
|
|
1516
|
+
"name": e["name"],
|
|
1517
|
+
"uuid": e["uuid"],
|
|
1518
|
+
"date": e.get("date"),
|
|
1519
|
+
"status": e.get("status"),
|
|
1520
|
+
"tags": list(e.get("tag") or []),
|
|
1521
|
+
}
|
|
1522
|
+
for e in entries
|
|
1523
|
+
],
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
|
|
1527
|
+
def diff_code_versions(engine, storage_root, version_a: str, version_b: str) -> dict:
|
|
1528
|
+
"""The source change between two code versions, file by file.
|
|
1529
|
+
|
|
1530
|
+
Texts come from the project's source store. An entry script logged before
|
|
1531
|
+
the store kept it is read from a run of that version instead.
|
|
1532
|
+
|
|
1533
|
+
Args:
|
|
1534
|
+
engine (Engine): The active SQLAlchemy database engine.
|
|
1535
|
+
storage_root (str | Path): The project storage root.
|
|
1536
|
+
version_a (str): The baseline version (hash or unambiguous prefix).
|
|
1537
|
+
version_b (str): The version compared with it.
|
|
1538
|
+
|
|
1539
|
+
Raises:
|
|
1540
|
+
LookupError: If either version cannot be found unambiguously.
|
|
1541
|
+
|
|
1542
|
+
Returns:
|
|
1543
|
+
dict: `{"versions": (a, b), "partial": (bool, bool)}` plus the keys of
|
|
1544
|
+
`silloncore.diff.compare_code`: `files` (name -> `status`, `diff`,
|
|
1545
|
+
`missing`), `constants_differ` and `source_diff`.
|
|
1546
|
+
"""
|
|
1547
|
+
from silloncore.diff import compare_code
|
|
1548
|
+
|
|
1549
|
+
groups = get_code_versions(engine)
|
|
1550
|
+
group_a = _find_code_version(groups, version_a)
|
|
1551
|
+
group_b = _find_code_version(groups, version_b)
|
|
1552
|
+
index = select_run_index(engine)
|
|
1553
|
+
|
|
1554
|
+
def main_of(group):
|
|
1555
|
+
def load():
|
|
1556
|
+
for entry in index:
|
|
1557
|
+
if entry.get("logic_version") == group["logic_version"]:
|
|
1558
|
+
text = load_run_source(storage_root, entry)
|
|
1559
|
+
if text is not None:
|
|
1560
|
+
return text
|
|
1561
|
+
return None
|
|
1562
|
+
|
|
1563
|
+
return load
|
|
1564
|
+
|
|
1565
|
+
compared = compare_code(
|
|
1566
|
+
storage_root,
|
|
1567
|
+
group_a["files"],
|
|
1568
|
+
group_b["files"],
|
|
1569
|
+
group_a["logic_version"][:8],
|
|
1570
|
+
group_b["logic_version"][:8],
|
|
1571
|
+
main_a=main_of(group_a),
|
|
1572
|
+
main_b=main_of(group_b),
|
|
1573
|
+
)
|
|
1574
|
+
return {
|
|
1575
|
+
"versions": (group_a["logic_version"], group_b["logic_version"]),
|
|
1576
|
+
"partial": (group_a["partial"], group_b["partial"]),
|
|
1577
|
+
**compared,
|
|
1578
|
+
}
|
|
1579
|
+
|
|
1580
|
+
|
|
1488
1581
|
def backfill_code_versions(engine, storage_root, dry_run: bool = False) -> dict:
|
|
1489
1582
|
"""Computes code versions for runs logged before versioning existed.
|
|
1490
1583
|
|
|
@@ -1,21 +1,43 @@
|
|
|
1
1
|
from silloncore.engine import (
|
|
2
2
|
get_code_versions,
|
|
3
3
|
get_code_version_files,
|
|
4
|
+
get_code_version_runs,
|
|
5
|
+
diff_code_versions,
|
|
4
6
|
backfill_code_versions,
|
|
5
7
|
)
|
|
6
|
-
from silloncore.display import
|
|
8
|
+
from silloncore.display import (
|
|
9
|
+
print_code_versions,
|
|
10
|
+
print_code_version_files,
|
|
11
|
+
print_code_version_runs,
|
|
12
|
+
print_code_version_diff,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
USAGE = (
|
|
16
|
+
"sillon versions every code version\n"
|
|
17
|
+
" sillon versions <version> its files\n"
|
|
18
|
+
" sillon versions <version> list the runs it produced\n"
|
|
19
|
+
" sillon versions diff <old> <new> the source change between two versions"
|
|
20
|
+
)
|
|
7
21
|
|
|
8
22
|
|
|
9
23
|
def add_parser(command_subparser):
|
|
10
24
|
versions_parser = command_subparser.add_parser(
|
|
11
25
|
"versions",
|
|
12
26
|
help="Group runs by the version of the code that produced them.",
|
|
27
|
+
usage=USAGE,
|
|
13
28
|
)
|
|
14
29
|
versions_parser.add_argument(
|
|
15
30
|
"version",
|
|
16
31
|
nargs="?",
|
|
17
32
|
type=str,
|
|
18
|
-
help="A version hash or prefix
|
|
33
|
+
help="A version hash or prefix (omit to list every version), or `diff`.",
|
|
34
|
+
)
|
|
35
|
+
versions_parser.add_argument(
|
|
36
|
+
"more",
|
|
37
|
+
nargs="*",
|
|
38
|
+
default=[],
|
|
39
|
+
metavar="...",
|
|
40
|
+
help="`list` after a version; the two versions after `diff`.",
|
|
19
41
|
)
|
|
20
42
|
versions_parser.add_argument(
|
|
21
43
|
"--backfill",
|
|
@@ -48,14 +70,31 @@ def command(engine, storage_root, args):
|
|
|
48
70
|
print(" include your own modules.\n")
|
|
49
71
|
|
|
50
72
|
version = args.get("version")
|
|
51
|
-
|
|
52
|
-
|
|
73
|
+
more = list(args.get("more") or [])
|
|
74
|
+
try:
|
|
75
|
+
if version == "diff":
|
|
76
|
+
if len(more) != 2:
|
|
77
|
+
print("✖ Error: `sillon versions diff` takes two versions: <old> <new>.")
|
|
78
|
+
return None
|
|
79
|
+
result = diff_code_versions(engine, storage_root, more[0], more[1])
|
|
80
|
+
print_code_version_diff(result)
|
|
81
|
+
return result
|
|
82
|
+
|
|
83
|
+
if version and more:
|
|
84
|
+
if more != ["list"]:
|
|
85
|
+
print(f"✖ Error: unknown `{' '.join(more)}` — try `sillon versions {version} list`.")
|
|
86
|
+
return None
|
|
87
|
+
detail = get_code_version_runs(engine, version)
|
|
88
|
+
print_code_version_runs(detail)
|
|
89
|
+
return detail
|
|
90
|
+
|
|
91
|
+
if version:
|
|
53
92
|
detail = get_code_version_files(engine, version)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return
|
|
93
|
+
print_code_version_files(detail)
|
|
94
|
+
return detail
|
|
95
|
+
except LookupError as e:
|
|
96
|
+
print(f"✖ Error: {e}")
|
|
97
|
+
return None
|
|
59
98
|
|
|
60
99
|
groups = get_code_versions(engine)
|
|
61
100
|
print_code_versions(groups)
|
|
@@ -197,7 +197,12 @@ def _run_sources(project: ProjectHandle, snapshot: dict) -> list:
|
|
|
197
197
|
for name, hashes in (version.get("files") or {}).items():
|
|
198
198
|
digest = hashes.get("source_hash")
|
|
199
199
|
text = read_source(project.storage_root, digest) if digest else None
|
|
200
|
-
|
|
200
|
+
entry = digest is not None and digest == entry_hash
|
|
201
|
+
if text is None and entry:
|
|
202
|
+
# Logged before the source store kept it: the run's own copy is
|
|
203
|
+
# the same text, as the hash says.
|
|
204
|
+
text = main
|
|
205
|
+
files.append(SourceFile(name, text, entry))
|
|
201
206
|
if main and not any(f.entry for f in files):
|
|
202
207
|
files.append(SourceFile("main script", main, True))
|
|
203
208
|
return sorted(files, key=lambda f: (not f.entry, f.name.lower()))
|
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
import time
|
|
4
4
|
|
|
5
5
|
from PySide6.QtCore import Qt
|
|
6
|
-
from PySide6.QtGui import
|
|
6
|
+
from PySide6.QtGui import (
|
|
7
|
+
QBrush,
|
|
8
|
+
QFontDatabase,
|
|
9
|
+
QSyntaxHighlighter,
|
|
10
|
+
QTextCharFormat,
|
|
11
|
+
QTextCursor,
|
|
12
|
+
)
|
|
7
13
|
from PySide6.QtWidgets import (
|
|
8
14
|
QHeaderView,
|
|
9
15
|
QPlainTextEdit,
|
|
@@ -85,6 +91,23 @@ _RESULT_CHANGE = {
|
|
|
85
91
|
}
|
|
86
92
|
|
|
87
93
|
|
|
94
|
+
_CODE_CHANGE = {
|
|
95
|
+
"changed": "logic changed",
|
|
96
|
+
"constants": "constants differ",
|
|
97
|
+
"cosmetic": "cosmetic",
|
|
98
|
+
"added": "only in target",
|
|
99
|
+
"removed": "only in baseline",
|
|
100
|
+
"same": "same",
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def _code_change(info: dict) -> str:
|
|
105
|
+
change = _CODE_CHANGE.get(info["status"], info["status"])
|
|
106
|
+
if info.get("missing"):
|
|
107
|
+
change += " (source not recorded)"
|
|
108
|
+
return change
|
|
109
|
+
|
|
110
|
+
|
|
88
111
|
def _result_change(entry: dict) -> str:
|
|
89
112
|
status = entry["status"]
|
|
90
113
|
if status in _RESULT_CHANGE:
|
|
@@ -107,6 +130,8 @@ class DiffView(QWidget):
|
|
|
107
130
|
self.tree.setRootIsDecorated(False)
|
|
108
131
|
self.tree.header().setSectionResizeMode(QHeaderView.ResizeToContents)
|
|
109
132
|
self.tree.header().setStretchLastSection(True)
|
|
133
|
+
self.tree.currentItemChanged.connect(self._follow_code_row)
|
|
134
|
+
self._diff_lines = {} # file name -> first line of its hunks in source_diff
|
|
110
135
|
|
|
111
136
|
self.source_diff = QPlainTextEdit(readOnly=True)
|
|
112
137
|
self.source_diff.setLineWrapMode(QPlainTextEdit.NoWrap)
|
|
@@ -119,7 +144,7 @@ class DiffView(QWidget):
|
|
|
119
144
|
splitter = QSplitter(Qt.Vertical, objectName="inner")
|
|
120
145
|
splitter.addWidget(self.tree)
|
|
121
146
|
splitter.addWidget(self.source_diff)
|
|
122
|
-
splitter.setSizes([
|
|
147
|
+
splitter.setSizes([300, 250])
|
|
123
148
|
layout = QVBoxLayout(self)
|
|
124
149
|
layout.setContentsMargins(0, 0, 0, 0)
|
|
125
150
|
layout.addWidget(splitter)
|
|
@@ -167,8 +192,15 @@ class DiffView(QWidget):
|
|
|
167
192
|
else:
|
|
168
193
|
verdict = "logic differs"
|
|
169
194
|
section = self._section(f"Code — {verdict}")
|
|
195
|
+
parts, line, self._diff_lines = [], 0, {}
|
|
170
196
|
for name, info in code["files"].items():
|
|
171
|
-
self._row(section, name, "", "", info
|
|
197
|
+
row = self._row(section, name, "", "", _code_change(info))
|
|
198
|
+
row.setData(0, Qt.UserRole, name)
|
|
199
|
+
if info.get("diff"):
|
|
200
|
+
self._diff_lines[name] = line
|
|
201
|
+
parts.append(info["diff"])
|
|
202
|
+
line += info["diff"].count("\n")
|
|
203
|
+
row.setToolTip(0, f"{name}: select to show its change below")
|
|
172
204
|
|
|
173
205
|
context = {key: pair for key, pair in diff["context"].items() if pair}
|
|
174
206
|
section = self._section(f"Context — {len(context)} differ")
|
|
@@ -177,9 +209,24 @@ class DiffView(QWidget):
|
|
|
177
209
|
self._row(section, key, shown(old), shown(new), "changed")
|
|
178
210
|
|
|
179
211
|
self.tree.expandAll()
|
|
180
|
-
|
|
212
|
+
text = "".join(parts) or code.get("source_diff", "")
|
|
213
|
+
self.source_diff.setPlainText(text)
|
|
181
214
|
# No room spent on an empty pane; the Code section already says why.
|
|
182
|
-
self.source_diff.setVisible(bool(
|
|
215
|
+
self.source_diff.setVisible(bool(text))
|
|
216
|
+
|
|
217
|
+
def show_file_change(self, name: str) -> bool:
|
|
218
|
+
"""Scrolls the source diff to `name`'s first hunk; False if it has none."""
|
|
219
|
+
line = self._diff_lines.get(name)
|
|
220
|
+
if line is None:
|
|
221
|
+
return False
|
|
222
|
+
block = self.source_diff.document().findBlockByNumber(line)
|
|
223
|
+
self.source_diff.setTextCursor(QTextCursor(block))
|
|
224
|
+
self.source_diff.verticalScrollBar().setValue(line)
|
|
225
|
+
return True
|
|
226
|
+
|
|
227
|
+
def _follow_code_row(self, current, _previous) -> None:
|
|
228
|
+
if current is not None and current.data(0, Qt.UserRole):
|
|
229
|
+
self.show_file_change(current.data(0, Qt.UserRole))
|
|
183
230
|
|
|
184
231
|
def _section(self, title) -> QTreeWidgetItem:
|
|
185
232
|
item = QTreeWidgetItem([title])
|
|
@@ -19,6 +19,8 @@ from silloncore.engine import (
|
|
|
19
19
|
rename_run as engine_rename_run,
|
|
20
20
|
trace as engine_trace,
|
|
21
21
|
get_code_versions as engine_code_versions,
|
|
22
|
+
get_code_version_runs as engine_code_version_runs,
|
|
23
|
+
diff_code_versions as engine_diff_code_versions,
|
|
22
24
|
prune_runs as engine_prune,
|
|
23
25
|
get_project_context,
|
|
24
26
|
diff as engine_diff,
|
|
@@ -409,6 +411,70 @@ class Project:
|
|
|
409
411
|
"""
|
|
410
412
|
return engine_code_versions(self.engine)
|
|
411
413
|
|
|
414
|
+
def version_runs(self, version: str) -> "RunCollection":
|
|
415
|
+
"""The runs one code version produced, newest first.
|
|
416
|
+
|
|
417
|
+
The notebook counterpart of `sillon versions <version> list`.
|
|
418
|
+
|
|
419
|
+
Example:
|
|
420
|
+
```python
|
|
421
|
+
buggy = project.version_runs("c8d012")
|
|
422
|
+
print(len(buggy), "runs used the code with the bug")
|
|
423
|
+
for run in buggy:
|
|
424
|
+
print(run.name)
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
Args:
|
|
428
|
+
version (str): A version hash or an unambiguous prefix.
|
|
429
|
+
|
|
430
|
+
Raises:
|
|
431
|
+
LookupError: If no version matches, or a prefix matches several.
|
|
432
|
+
|
|
433
|
+
Returns:
|
|
434
|
+
RunCollection: The runs, loaded lazily like any query result.
|
|
435
|
+
"""
|
|
436
|
+
detail = engine_code_version_runs(self.engine, version)
|
|
437
|
+
return RunCollection(
|
|
438
|
+
[
|
|
439
|
+
Run(name=run["name"], engine=self.engine, storage_root=self.storage_root)
|
|
440
|
+
for run in detail["runs"]
|
|
441
|
+
]
|
|
442
|
+
)
|
|
443
|
+
|
|
444
|
+
def version_diff(self, old: str, new: str, show: bool = True) -> dict:
|
|
445
|
+
"""The source change between two code versions, file by file.
|
|
446
|
+
|
|
447
|
+
The notebook counterpart of `sillon versions diff <old> <new>`.
|
|
448
|
+
|
|
449
|
+
Example:
|
|
450
|
+
```python
|
|
451
|
+
versions = project.versions()
|
|
452
|
+
change = project.version_diff(versions[1]["logic_version"],
|
|
453
|
+
versions[0]["logic_version"])
|
|
454
|
+
print(change["files"]["model.py"]["diff"])
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
Args:
|
|
458
|
+
old (str): The baseline version (hash or unambiguous prefix).
|
|
459
|
+
new (str): The version compared with it.
|
|
460
|
+
show (bool): Print the summary and the coloured diff.
|
|
461
|
+
|
|
462
|
+
Raises:
|
|
463
|
+
LookupError: If either version cannot be found unambiguously.
|
|
464
|
+
|
|
465
|
+
Returns:
|
|
466
|
+
dict: `{"versions", "partial", "files", "constants_differ",
|
|
467
|
+
"source_diff"}`; each file is `{"status", "diff", "missing"}`,
|
|
468
|
+
status being added, removed, changed, constants, cosmetic or
|
|
469
|
+
same.
|
|
470
|
+
"""
|
|
471
|
+
result = engine_diff_code_versions(self.engine, self.storage_root, old, new)
|
|
472
|
+
if show:
|
|
473
|
+
from silloncore.display import print_code_version_diff
|
|
474
|
+
|
|
475
|
+
print_code_version_diff(result)
|
|
476
|
+
return result
|
|
477
|
+
|
|
412
478
|
def prune(self, run_names=None, before=None, keep_metadata: bool = True) -> dict:
|
|
413
479
|
"""Frees disk space by deleting the stored data of selected runs.
|
|
414
480
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sillon
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: Git for simulations — log, track, query and analyze simulation runs.
|
|
5
5
|
Author-email: Guillaume Tassotti <placeholder@email.com>, Baptiste Lerat <lerat.baptiste99@proton.ch>
|
|
6
6
|
License-Expression: Apache-2.0
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|