sillon 2.1.2__tar.gz → 2.2.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.1.2/sillon.egg-info → sillon-2.2.0}/PKG-INFO +14 -3
- {sillon-2.1.2 → sillon-2.2.0}/README.md +4 -1
- {sillon-2.1.2 → sillon-2.2.0}/packages/common/src/silloncommon/__init__.py +1 -1
- {sillon-2.1.2 → sillon-2.2.0}/packages/core/src/silloncore/bundle.py +4 -2
- {sillon-2.1.2 → sillon-2.2.0}/packages/core/src/silloncore/project_paths.py +28 -9
- sillon-2.2.0/packages/interface/cli/src/silloncli/commands/gui.py +141 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/main.py +2 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/__init__.py +12 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/__main__.py +7 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/app.py +42 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/models/__init__.py +0 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/models/run_model.py +140 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/preferences.py +124 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/project.py +350 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/query.py +173 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/theme.py +450 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/views/__init__.py +0 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/views/data_tab.py +77 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/views/data_view.py +204 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/views/details_view.py +76 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/views/errors.py +15 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/views/export_dialog.py +60 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/views/figure_view.py +267 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/views/main_window.py +686 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/views/output_view.py +228 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/views/query_bar.py +183 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/views/run_list.py +229 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/views/settings_dialog.py +139 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/views/source_view.py +227 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/views/title_bar.py +71 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/views/vibrancy.py +106 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/views/widgets.py +41 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/workers/__init__.py +0 -0
- sillon-2.2.0/packages/interface/gui/src/sillongui/workers/task.py +76 -0
- {sillon-2.1.2 → sillon-2.2.0}/pyproject.toml +4 -1
- {sillon-2.1.2 → sillon-2.2.0/sillon.egg-info}/PKG-INFO +14 -3
- {sillon-2.1.2 → sillon-2.2.0}/sillon.egg-info/SOURCES.txt +28 -0
- {sillon-2.1.2 → sillon-2.2.0}/sillon.egg-info/entry_points.txt +1 -0
- {sillon-2.1.2 → sillon-2.2.0}/sillon.egg-info/requires.txt +10 -1
- {sillon-2.1.2 → sillon-2.2.0}/sillon.egg-info/top_level.txt +1 -0
- {sillon-2.1.2 → sillon-2.2.0}/LICENSE +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/common/src/silloncommon/access_log.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/common/src/silloncommon/codeversion.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/common/src/silloncommon/commands.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/common/src/silloncommon/database.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/common/src/silloncommon/framing.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/common/src/silloncommon/hashing.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/common/src/silloncommon/hdf5_staging.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/common/src/silloncommon/project_config.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/common/src/silloncommon/registry.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/common/src/silloncommon/rpcHandler.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/common/src/silloncommon/socket_path.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/common/src/silloncommon/source_store.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/common/src/silloncommon/timestamps.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/common/src/silloncommon/transport.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/common/src/silloncommon/user_paths.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/core/src/silloncore/__init__.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/core/src/silloncore/check.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/core/src/silloncore/diff.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/core/src/silloncore/display.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/core/src/silloncore/engine.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/core/src/silloncore/envhandler.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/core/src/silloncore/glob.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/core/src/silloncore/projects.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/core/src/silloncore/server/__init__.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/core/src/silloncore/server/main.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/core/src/silloncore/server/server.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/core/src/silloncore/server/visitor.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/core/src/silloncore/simulation.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/core/src/silloncore/transfer.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/core/src/silloncore/versioncontrol.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/__init__.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/__init__.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/add.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/check.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/delete.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/diff.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/export.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/fetch.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/import_cmd.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/init.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/like.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/lineage.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/list.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/projects.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/prune.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/query.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/rename.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/report.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/show.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/trace.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/commands/versions.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/cli/src/silloncli/context.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/sillonlab/src/sillonlab/__init__.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/sillonlab/src/sillonlab/display.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/sillonlab/src/sillonlab/project.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/sillonlab/src/sillonlab/projects.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/interface/sillonlab/src/sillonlab/run.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/pyapi/src/sillonpy/__init__.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/pyapi/src/sillonpy/api.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/pyapi/src/sillonpy/daemon.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/pyapi/src/sillonpy/metadata.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/pyapi/src/sillonpy/serverCom.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/packages/pyapi/src/sillonpy/tracker.py +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/setup.cfg +0 -0
- {sillon-2.1.2 → sillon-2.2.0}/sillon.egg-info/dependency_links.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sillon
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.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
|
|
@@ -28,9 +28,17 @@ Requires-Dist: numpy
|
|
|
28
28
|
Requires-Dist: tqdm
|
|
29
29
|
Provides-Extra: analysis
|
|
30
30
|
Requires-Dist: pandas; extra == "analysis"
|
|
31
|
+
Provides-Extra: gui
|
|
32
|
+
Requires-Dist: PySide6>=6.10; extra == "gui"
|
|
33
|
+
Requires-Dist: silx; extra == "gui"
|
|
34
|
+
Requires-Dist: matplotlib; extra == "gui"
|
|
35
|
+
Requires-Dist: qtawesome; extra == "gui"
|
|
36
|
+
Requires-Dist: PyOpenGL; extra == "gui"
|
|
37
|
+
Requires-Dist: pygments; extra == "gui"
|
|
31
38
|
Provides-Extra: dev
|
|
32
|
-
Requires-Dist: sillon[analysis]; extra == "dev"
|
|
39
|
+
Requires-Dist: sillon[analysis,gui]; extra == "dev"
|
|
33
40
|
Requires-Dist: pytest; extra == "dev"
|
|
41
|
+
Requires-Dist: pytest-qt; extra == "dev"
|
|
34
42
|
Requires-Dist: psutil; extra == "dev"
|
|
35
43
|
Requires-Dist: build; extra == "dev"
|
|
36
44
|
Requires-Dist: twine; extra == "dev"
|
|
@@ -172,6 +180,7 @@ start, and heavy arrays offloaded without you thinking about it.
|
|
|
172
180
|
| [Core concepts](docs/getting-started/concepts.md) | the mental model — read once |
|
|
173
181
|
| [Logging runs](docs/guide/logging.md) | the whole logging API |
|
|
174
182
|
| [Querying and analysis](docs/guide/analysis.md) | working with many runs |
|
|
183
|
+
| [The desktop browser](docs/guide/gui.md) | `sillon gui`: runs, data and figures in a window |
|
|
175
184
|
| [Provenance and lineage](docs/guide/provenance.md) | code versions, automatic lineage, figures, hashes |
|
|
176
185
|
| [Moving runs between machines](docs/guide/transfer.md) | bundles, merging projects, the shared drive |
|
|
177
186
|
| [Working with projects](docs/guide/projects.md) | finding, naming, moving them |
|
|
@@ -195,9 +204,11 @@ See [Architecture](docs/dev/architecture.md).
|
|
|
195
204
|
## Status and roadmap
|
|
196
205
|
|
|
197
206
|
The logging API, the daemon, the CLI and the analysis library are in daily use.
|
|
207
|
+
The desktop browser (`pip install "sillon[gui]"`, then `sillon gui`) is new in
|
|
208
|
+
2.2; its Lineage tab is not built yet.
|
|
198
209
|
|
|
199
210
|
Not implemented yet, despite appearing in older notes: `sillon run`
|
|
200
|
-
(reproduction), `sillon watch`, `sillon estimate`,
|
|
211
|
+
(reproduction), `sillon watch`, `sillon estimate`, Slurm integration, and
|
|
201
212
|
non-Python clients. If a command is not in the [CLI reference](docs/reference/cli.md),
|
|
202
213
|
it does not exist.
|
|
203
214
|
|
|
@@ -131,6 +131,7 @@ start, and heavy arrays offloaded without you thinking about it.
|
|
|
131
131
|
| [Core concepts](docs/getting-started/concepts.md) | the mental model — read once |
|
|
132
132
|
| [Logging runs](docs/guide/logging.md) | the whole logging API |
|
|
133
133
|
| [Querying and analysis](docs/guide/analysis.md) | working with many runs |
|
|
134
|
+
| [The desktop browser](docs/guide/gui.md) | `sillon gui`: runs, data and figures in a window |
|
|
134
135
|
| [Provenance and lineage](docs/guide/provenance.md) | code versions, automatic lineage, figures, hashes |
|
|
135
136
|
| [Moving runs between machines](docs/guide/transfer.md) | bundles, merging projects, the shared drive |
|
|
136
137
|
| [Working with projects](docs/guide/projects.md) | finding, naming, moving them |
|
|
@@ -154,9 +155,11 @@ See [Architecture](docs/dev/architecture.md).
|
|
|
154
155
|
## Status and roadmap
|
|
155
156
|
|
|
156
157
|
The logging API, the daemon, the CLI and the analysis library are in daily use.
|
|
158
|
+
The desktop browser (`pip install "sillon[gui]"`, then `sillon gui`) is new in
|
|
159
|
+
2.2; its Lineage tab is not built yet.
|
|
157
160
|
|
|
158
161
|
Not implemented yet, despite appearing in older notes: `sillon run`
|
|
159
|
-
(reproduction), `sillon watch`, `sillon estimate`,
|
|
162
|
+
(reproduction), `sillon watch`, `sillon estimate`, Slurm integration, and
|
|
160
163
|
non-Python clients. If a command is not in the [CLI reference](docs/reference/cli.md),
|
|
161
164
|
it does not exist.
|
|
162
165
|
|
|
@@ -218,9 +218,11 @@ def _resolve_dest(dest, project_path, hostname: str) -> Path:
|
|
|
218
218
|
"""Where to write, accepting either a file or a directory."""
|
|
219
219
|
if dest is None:
|
|
220
220
|
return Path.cwd() / default_bundle_name(project_path, hostname)
|
|
221
|
+
# Read the trailing separator off the caller's text: `Path` drops it, and
|
|
222
|
+
# with it the only sign that `newdir/` (not there yet) is meant as a folder.
|
|
223
|
+
trailing_separator = isinstance(dest, str) and dest.endswith(("/", "\\"))
|
|
221
224
|
dest = Path(dest).expanduser()
|
|
222
|
-
|
|
223
|
-
if looks_like_dir:
|
|
225
|
+
if trailing_separator or dest.is_dir():
|
|
224
226
|
return dest / default_bundle_name(project_path, hostname)
|
|
225
227
|
return dest
|
|
226
228
|
|
|
@@ -17,11 +17,12 @@ from silloncommon.database import get_engine, migrate_schema, sqlite_url
|
|
|
17
17
|
resolve_storage_root = project_config.resolve_storage_root
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
def
|
|
21
|
-
"""
|
|
20
|
+
def resolve_db_path(project_path) -> Path:
|
|
21
|
+
"""Where a project's SQLite database is, wherever it was created.
|
|
22
22
|
|
|
23
23
|
Handles both the default layout (`.sillon/database.sql`) and layouts
|
|
24
|
-
produced with a custom storage root.
|
|
24
|
+
produced with a custom storage root. Split from `resolve_engine` so a
|
|
25
|
+
read-only reader (the GUI) opens exactly the file the CLI would.
|
|
25
26
|
|
|
26
27
|
Args:
|
|
27
28
|
project_path (str | Path): The project root (folder containing `.sillon`).
|
|
@@ -30,13 +31,12 @@ def resolve_engine(project_path):
|
|
|
30
31
|
FileNotFoundError: If no database can be located for the project.
|
|
31
32
|
|
|
32
33
|
Returns:
|
|
33
|
-
|
|
34
|
+
Path: The database file.
|
|
34
35
|
"""
|
|
35
36
|
project_path = Path(project_path).expanduser().resolve()
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return get_engine(project_path)
|
|
37
|
+
default = project_path / ".sillon" / "database.sql"
|
|
38
|
+
if default.exists():
|
|
39
|
+
return default
|
|
40
40
|
|
|
41
41
|
storage_root = resolve_storage_root(project_path)
|
|
42
42
|
for candidate in (
|
|
@@ -44,11 +44,30 @@ def resolve_engine(project_path):
|
|
|
44
44
|
storage_root / ".sillon" / "database.sql",
|
|
45
45
|
):
|
|
46
46
|
if candidate.exists():
|
|
47
|
-
return
|
|
47
|
+
return candidate
|
|
48
48
|
|
|
49
49
|
raise FileNotFoundError(f"No sillon database found for project {project_path}")
|
|
50
50
|
|
|
51
51
|
|
|
52
|
+
def resolve_engine(project_path):
|
|
53
|
+
"""Connects to a project's SQLite database, wherever it was created.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
project_path (str | Path): The project root (folder containing `.sillon`).
|
|
57
|
+
|
|
58
|
+
Raises:
|
|
59
|
+
FileNotFoundError: If no database can be located for the project.
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
Engine: A SQLAlchemy engine connected to the project database.
|
|
63
|
+
"""
|
|
64
|
+
project_path = Path(project_path).expanduser().resolve()
|
|
65
|
+
db_path = resolve_db_path(project_path)
|
|
66
|
+
if db_path == project_path / ".sillon" / "database.sql":
|
|
67
|
+
return get_engine(project_path)
|
|
68
|
+
return migrate_schema(create_engine(sqlite_url(db_path)))
|
|
69
|
+
|
|
70
|
+
|
|
52
71
|
def resolve_project_name(project_path) -> str:
|
|
53
72
|
"""The project's own name, as recorded in its config.
|
|
54
73
|
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"""`sillon gui`: opens the desktop browser on this project, detached.
|
|
2
|
+
|
|
3
|
+
The GUI runs as its own process, in its own session, with no terminal: the
|
|
4
|
+
command returns at once, and closing the terminal leaves the window open.
|
|
5
|
+
What the GUI prints (its log, any crash) goes to a log file instead, which the
|
|
6
|
+
command names. `sillon-gui` is the same program attached to the terminal, for
|
|
7
|
+
debugging.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import contextlib
|
|
11
|
+
import importlib.util
|
|
12
|
+
import os
|
|
13
|
+
import subprocess
|
|
14
|
+
import sys
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
from silloncore.display import console
|
|
18
|
+
|
|
19
|
+
# The log is kept to about this size: past it, it moves to `gui.log.1`.
|
|
20
|
+
MAX_LOG_BYTES = 1024 * 1024
|
|
21
|
+
|
|
22
|
+
# A GUI that cannot start (a broken install) fails within this, while a good
|
|
23
|
+
# start takes longer: wait this long, no more, before saying it is open.
|
|
24
|
+
EARLY_EXIT_SECONDS = 0.25
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def add_parser(command_subparser):
|
|
28
|
+
gui_parser = command_subparser.add_parser(
|
|
29
|
+
"gui",
|
|
30
|
+
help="Open the desktop browser on this project (returns at once; "
|
|
31
|
+
"closing the terminal leaves it open).",
|
|
32
|
+
)
|
|
33
|
+
gui_parser.add_argument(
|
|
34
|
+
"path",
|
|
35
|
+
nargs="?",
|
|
36
|
+
default=None,
|
|
37
|
+
help="A path inside the project to open (default: the current directory).",
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def log_path() -> Path:
|
|
42
|
+
"""Where the detached GUI writes its log, by platform convention."""
|
|
43
|
+
if sys.platform == "darwin":
|
|
44
|
+
return Path.home() / "Library" / "Logs" / "sillon" / "gui.log"
|
|
45
|
+
if os.name == "nt":
|
|
46
|
+
base = Path(os.environ.get("LOCALAPPDATA") or Path.home() / "AppData" / "Local")
|
|
47
|
+
return base / "sillon" / "gui.log"
|
|
48
|
+
state = os.environ.get("XDG_STATE_HOME") or Path.home() / ".local" / "state"
|
|
49
|
+
return Path(state) / "sillon" / "gui.log"
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def gui_installed() -> bool:
|
|
53
|
+
return all(importlib.util.find_spec(name) for name in ("sillongui", "PySide6", "silx"))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def no_display_reason() -> str | None:
|
|
57
|
+
"""Why a window cannot open here, if that is known before trying.
|
|
58
|
+
|
|
59
|
+
On Linux and the BSDs a window needs an X11 or Wayland display: over a
|
|
60
|
+
plain SSH session there is none, and Qt would abort after its imports,
|
|
61
|
+
too late for the early-exit check to see.
|
|
62
|
+
"""
|
|
63
|
+
if sys.platform in ("darwin", "win32") or os.environ.get("QT_QPA_PLATFORM"):
|
|
64
|
+
return None
|
|
65
|
+
if os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY"):
|
|
66
|
+
return None
|
|
67
|
+
return "there is no display here (no DISPLAY or WAYLAND_DISPLAY)"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def interpreter() -> str:
|
|
71
|
+
"""The Python to run the GUI with: on Windows `pythonw.exe`, which opens
|
|
72
|
+
no console window, where it sits beside `python.exe`."""
|
|
73
|
+
if os.name == "nt":
|
|
74
|
+
windowed = Path(sys.executable).with_name("pythonw.exe")
|
|
75
|
+
if windowed.exists():
|
|
76
|
+
return str(windowed)
|
|
77
|
+
return sys.executable
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def launch(path: Path, log: Path) -> subprocess.Popen:
|
|
81
|
+
"""Starts `python -m sillongui path`, detached, its output into `log`."""
|
|
82
|
+
log.parent.mkdir(parents=True, exist_ok=True)
|
|
83
|
+
if log.exists() and log.stat().st_size > MAX_LOG_BYTES:
|
|
84
|
+
# On Windows another window may still write to it: rotate next time.
|
|
85
|
+
with contextlib.suppress(OSError):
|
|
86
|
+
log.replace(log.with_name(log.name + ".1"))
|
|
87
|
+
|
|
88
|
+
options = {}
|
|
89
|
+
if os.name == "nt":
|
|
90
|
+
options["creationflags"] = (
|
|
91
|
+
subprocess.DETACHED_PROCESS | subprocess.CREATE_NEW_PROCESS_GROUP
|
|
92
|
+
)
|
|
93
|
+
else:
|
|
94
|
+
options["start_new_session"] = True # no SIGHUP when the terminal closes
|
|
95
|
+
with open(log, "ab") as out:
|
|
96
|
+
out.write(f"\n--- sillon gui {path}\n".encode())
|
|
97
|
+
out.flush()
|
|
98
|
+
return subprocess.Popen(
|
|
99
|
+
[interpreter(), "-m", "sillongui", str(path)],
|
|
100
|
+
stdin=subprocess.DEVNULL,
|
|
101
|
+
stdout=out,
|
|
102
|
+
stderr=subprocess.STDOUT,
|
|
103
|
+
cwd=str(path),
|
|
104
|
+
close_fds=True,
|
|
105
|
+
**options,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def command(engine, storage_root, args):
|
|
110
|
+
"""CLI GUI Command Handler"""
|
|
111
|
+
if not gui_installed():
|
|
112
|
+
console.print(
|
|
113
|
+
"[bold red]✖[/bold red] The GUI is not installed. "
|
|
114
|
+
"Install it with: [cyan]pip install 'sillon[gui]'[/cyan]"
|
|
115
|
+
)
|
|
116
|
+
return {"status": "error", "message": "sillongui is not installed"}
|
|
117
|
+
|
|
118
|
+
reason = no_display_reason()
|
|
119
|
+
if reason:
|
|
120
|
+
console.print(
|
|
121
|
+
f"[bold red]✖[/bold red] Cannot open a window: {reason}. "
|
|
122
|
+
"Run it on your own machine, or connect with `ssh -X`."
|
|
123
|
+
)
|
|
124
|
+
return {"status": "error", "message": reason}
|
|
125
|
+
|
|
126
|
+
path = Path(args.get("path") or Path.cwd()).expanduser().resolve()
|
|
127
|
+
log = log_path()
|
|
128
|
+
process = launch(path, log)
|
|
129
|
+
try:
|
|
130
|
+
code = process.wait(timeout=EARLY_EXIT_SECONDS)
|
|
131
|
+
except subprocess.TimeoutExpired:
|
|
132
|
+
console.print(f"[bold green]✔[/bold green] Opening sillon for [cyan]{path}[/cyan]")
|
|
133
|
+
console.print(f"[dim] log: {log}[/dim]")
|
|
134
|
+
return {"status": "success", "pid": process.pid, "log": str(log)}
|
|
135
|
+
|
|
136
|
+
# Gone already: say why, from the log, rather than leave the user waiting.
|
|
137
|
+
tail = log.read_text(errors="replace").strip().splitlines()[-8:]
|
|
138
|
+
console.print(f"[bold red]✖[/bold red] The GUI exited at once (code {code}):")
|
|
139
|
+
for line in tail:
|
|
140
|
+
console.print(f" {line}", markup=False, highlight=False)
|
|
141
|
+
return {"status": "error", "code": code, "log": str(log)}
|
|
@@ -24,6 +24,7 @@ import silloncli.commands.export as export
|
|
|
24
24
|
import silloncli.commands.import_cmd as import_cmd
|
|
25
25
|
import silloncli.commands.init as init
|
|
26
26
|
import silloncli.commands.check as check
|
|
27
|
+
import silloncli.commands.gui as gui
|
|
27
28
|
|
|
28
29
|
from silloncommon import __version__, registry
|
|
29
30
|
from silloncommon.project_config import find_project_root
|
|
@@ -53,6 +54,7 @@ COMMAND_LIST = {
|
|
|
53
54
|
"import": import_cmd,
|
|
54
55
|
"init": init,
|
|
55
56
|
"check": check,
|
|
57
|
+
"gui": gui,
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""sillongui: a read-only desktop browser for sillon projects."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
# The daemon appends to a run's HDF5 glob while the run is live, and again
|
|
6
|
+
# whenever an analysis is logged. A reader holding HDF5's default file lock
|
|
7
|
+
# makes those writes fail, and the GUI must never get in the daemon's way.
|
|
8
|
+
# Set process-wide, so silloncore's readers (which open with the default) and
|
|
9
|
+
# the Data tab agree: HDF5 refuses two opens of one file with different
|
|
10
|
+
# locking flags. It only takes effect if set before h5py loads the library,
|
|
11
|
+
# which importing this package first (as `sillon-gui` does) guarantees.
|
|
12
|
+
os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""`sillon-gui [path]`: open the project containing `path` (default: cwd)."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import logging
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
from PySide6.QtWidgets import QApplication, QMessageBox
|
|
8
|
+
|
|
9
|
+
from sillongui import preferences, theme
|
|
10
|
+
from sillongui.project import open_project
|
|
11
|
+
from sillongui.views.main_window import MainWindow
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main(argv=None) -> int:
|
|
17
|
+
parser = argparse.ArgumentParser(prog="sillon-gui", description="Browse a sillon project.")
|
|
18
|
+
parser.add_argument("path", nargs="?", help="A path inside the project (default: cwd).")
|
|
19
|
+
args = parser.parse_args(argv)
|
|
20
|
+
|
|
21
|
+
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(name)s %(levelname)s %(message)s")
|
|
22
|
+
app = QApplication(sys.argv[:1])
|
|
23
|
+
app.setApplicationName("sillon")
|
|
24
|
+
theme.apply(app, preferences.current())
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
project = open_project(args.path)
|
|
28
|
+
except Exception as exc:
|
|
29
|
+
logger.exception("Could not open project")
|
|
30
|
+
QMessageBox.critical(None, "sillon", f"Could not open the project:\n\n{exc}")
|
|
31
|
+
return 1
|
|
32
|
+
|
|
33
|
+
logger.info("Project %s, database %s (read-only)", project.root, project.db_path)
|
|
34
|
+
window = MainWindow(project)
|
|
35
|
+
window.show()
|
|
36
|
+
window.raise_() # in front, not behind the terminal it was started from
|
|
37
|
+
window.activateWindow()
|
|
38
|
+
return app.exec()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
if __name__ == "__main__":
|
|
42
|
+
sys.exit(main())
|
|
File without changes
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"""The run list, as a Qt item model."""
|
|
2
|
+
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
5
|
+
from PySide6.QtCore import Qt
|
|
6
|
+
from PySide6.QtGui import QBrush, QStandardItem, QStandardItemModel
|
|
7
|
+
|
|
8
|
+
from sillongui import theme
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"COLUMNS", "UUID_ROLE", "SORT_ROLE", "build_run_model", "format_date", "format_runtime",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
# (header, key in a `get_project_context` run card)
|
|
15
|
+
COLUMNS = [
|
|
16
|
+
("Name", "name"),
|
|
17
|
+
("Status", "status"),
|
|
18
|
+
("Date", "timestamp"),
|
|
19
|
+
("Runtime", "runtime"),
|
|
20
|
+
("Params", "param_count"),
|
|
21
|
+
("Assets", "asset_count"),
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
# The run's uuid, stored on its Name item: names are unique today, but the
|
|
25
|
+
# uuid is what every engine function accepts unambiguously.
|
|
26
|
+
UUID_ROLE = Qt.UserRole + 1
|
|
27
|
+
|
|
28
|
+
# What a column sorts by: the raw value, while DisplayRole holds what reads well.
|
|
29
|
+
SORT_ROLE = Qt.UserRole + 2
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def format_runtime(runtime) -> str:
|
|
33
|
+
"""Seconds as `48 ms`, `32.5 s`, `4 min 12 s`, `2 h 05 min`; anything else as stored."""
|
|
34
|
+
try:
|
|
35
|
+
seconds = float(runtime)
|
|
36
|
+
except (TypeError, ValueError):
|
|
37
|
+
return str(runtime)
|
|
38
|
+
if seconds < 1:
|
|
39
|
+
return f"{seconds * 1000:.0f} ms"
|
|
40
|
+
if seconds < 60:
|
|
41
|
+
return f"{seconds:.1f} s"
|
|
42
|
+
if seconds < 3600:
|
|
43
|
+
return f"{int(seconds // 60)} min {int(seconds % 60)} s"
|
|
44
|
+
return f"{int(seconds // 3600)} h {int(seconds % 3600 // 60):02d} min"
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _sort_key(value):
|
|
48
|
+
try:
|
|
49
|
+
return float(value) # runtimes are stored as text
|
|
50
|
+
except (TypeError, ValueError):
|
|
51
|
+
return str(value)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def _item(value, text=None) -> QStandardItem:
|
|
55
|
+
item = QStandardItem(str(value) if text is None else text)
|
|
56
|
+
item.setData(_sort_key(value), SORT_ROLE)
|
|
57
|
+
item.setEditable(False)
|
|
58
|
+
return item
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def format_date(stamp, relative: bool = False, now: datetime | None = None) -> str:
|
|
62
|
+
"""`2026-10-01-15:11:17` as `2026-10-01 15:11`: the seconds are noise in a list.
|
|
63
|
+
|
|
64
|
+
`relative` says how long ago instead (`just now`, `5 min ago`, `3 h ago`,
|
|
65
|
+
`yesterday`, `4 days ago`), for the last week; older runs keep their date.
|
|
66
|
+
"""
|
|
67
|
+
text = str(stamp or "")
|
|
68
|
+
if len(text) < 16 or text[10] != "-":
|
|
69
|
+
return text
|
|
70
|
+
if relative:
|
|
71
|
+
try:
|
|
72
|
+
when = datetime.strptime(text[:19], "%Y-%m-%d-%H:%M:%S")
|
|
73
|
+
except ValueError:
|
|
74
|
+
when = None
|
|
75
|
+
if when is not None:
|
|
76
|
+
ago = _ago(when, now or datetime.now())
|
|
77
|
+
if ago:
|
|
78
|
+
return ago
|
|
79
|
+
return f"{text[:10]} {text[11:16]}"
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _ago(when: datetime, now: datetime) -> str:
|
|
83
|
+
seconds = (now - when).total_seconds()
|
|
84
|
+
if seconds < 0:
|
|
85
|
+
return "" # a clock elsewhere is ahead: the date says it best
|
|
86
|
+
if seconds < 60:
|
|
87
|
+
return "just now"
|
|
88
|
+
if seconds < 3600:
|
|
89
|
+
return f"{int(seconds // 60)} min ago"
|
|
90
|
+
if seconds < 86400 and when.date() == now.date():
|
|
91
|
+
return f"{int(seconds // 3600)} h ago"
|
|
92
|
+
days = (now.date() - when.date()).days
|
|
93
|
+
if days == 1:
|
|
94
|
+
return "yesterday"
|
|
95
|
+
if days < 7:
|
|
96
|
+
return f"{days} days ago"
|
|
97
|
+
return ""
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _style_row(row, status) -> None:
|
|
101
|
+
"""Calm by default: the eye goes to the name and to what failed.
|
|
102
|
+
|
|
103
|
+
The status is a dot in its colour; its text stays quiet unless the run
|
|
104
|
+
went wrong. Dates, runtimes and counts are secondary, so dim.
|
|
105
|
+
"""
|
|
106
|
+
color = theme.status_color(status)
|
|
107
|
+
row[1].setIcon(theme.dot(color))
|
|
108
|
+
row[1].setText(str(status or "").capitalize())
|
|
109
|
+
failed = str(status) in theme.FAILED_STATUSES
|
|
110
|
+
row[1].setForeground(QBrush(color if failed else theme.color("dim")))
|
|
111
|
+
for item in row[2:]: # Date, Runtime, Params, Assets
|
|
112
|
+
item.setForeground(QBrush(theme.color("dim")))
|
|
113
|
+
for item in row[4:]:
|
|
114
|
+
item.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)
|
|
115
|
+
row[2].setToolTip(str(row[2].data(SORT_ROLE)))
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def build_run_model(runs: list[dict], parent=None, relative_dates=False) -> QStandardItemModel:
|
|
119
|
+
"""One row per run card, in the order given."""
|
|
120
|
+
now = datetime.now()
|
|
121
|
+
formats = {
|
|
122
|
+
"runtime": format_runtime,
|
|
123
|
+
"timestamp": lambda stamp: format_date(stamp, relative_dates, now),
|
|
124
|
+
}
|
|
125
|
+
model = QStandardItemModel(0, len(COLUMNS), parent)
|
|
126
|
+
model.setHorizontalHeaderLabels([header for header, _ in COLUMNS])
|
|
127
|
+
for column in (4, 5): # counts: right-aligned, headers with them
|
|
128
|
+
model.setHeaderData(
|
|
129
|
+
column, Qt.Horizontal, Qt.AlignRight | Qt.AlignVCenter, Qt.TextAlignmentRole
|
|
130
|
+
)
|
|
131
|
+
for run in runs:
|
|
132
|
+
row = [
|
|
133
|
+
_item(run.get(key, ""), formats[key](run.get(key)) if key in formats else None)
|
|
134
|
+
for _, key in COLUMNS
|
|
135
|
+
]
|
|
136
|
+
row[0].setData(run["uuid"], UUID_ROLE)
|
|
137
|
+
row[0].setToolTip(run["uuid"])
|
|
138
|
+
_style_row(row, run.get("status"))
|
|
139
|
+
model.appendRow(row)
|
|
140
|
+
return model
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"""The GUI's own settings: how it looks, and the window layout it reopens with.
|
|
2
|
+
|
|
3
|
+
They live in an INI file of the GUI's (`QSettings`, "sillon/sillon-gui"), never
|
|
4
|
+
in a project: nothing here touches a project or its database. `current()` is
|
|
5
|
+
the one copy in use; `update(...)` changes it, saves it, re-themes the app and
|
|
6
|
+
announces it on `hub().changed` for the windows to follow.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import logging
|
|
10
|
+
import sys
|
|
11
|
+
from dataclasses import asdict, dataclass, fields, replace
|
|
12
|
+
|
|
13
|
+
from PySide6.QtCore import QObject, QSettings, Signal
|
|
14
|
+
from PySide6.QtWidgets import QApplication
|
|
15
|
+
|
|
16
|
+
from sillongui import theme
|
|
17
|
+
|
|
18
|
+
__all__ = ["Preferences", "current", "update", "reset", "hub", "store", "BLUR_AVAILABLE"]
|
|
19
|
+
|
|
20
|
+
logger = logging.getLogger(__name__)
|
|
21
|
+
|
|
22
|
+
# The blur is macOS's (NSVisualEffectView); elsewhere the window stays opaque.
|
|
23
|
+
BLUR_AVAILABLE = sys.platform == "darwin"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(frozen=True)
|
|
27
|
+
class Preferences:
|
|
28
|
+
zoom: int = 100 # text size, percent of the system's (`theme.ZOOMS`)
|
|
29
|
+
density: str = "comfortable" # or "compact" (`theme.DENSITIES`)
|
|
30
|
+
translucent: bool = True # blur behind the window, where the system has it
|
|
31
|
+
opacity: int = 80 # percent, when translucent
|
|
32
|
+
relative_dates: bool = False # "3 h ago" in the run list
|
|
33
|
+
restore_layout: bool = True # reopen with the last window size, panes and tab
|
|
34
|
+
|
|
35
|
+
@property
|
|
36
|
+
def effective_opacity(self) -> float:
|
|
37
|
+
"""The window background's opacity as drawn: 1 unless the blur is on."""
|
|
38
|
+
if self.translucent and BLUR_AVAILABLE and _blur_platform():
|
|
39
|
+
return max(0.4, min(1.0, self.opacity / 100))
|
|
40
|
+
return 1.0
|
|
41
|
+
|
|
42
|
+
def normalized(self) -> "Preferences":
|
|
43
|
+
zoom = min(theme.ZOOMS, key=lambda step: abs(step - self.zoom))
|
|
44
|
+
density = self.density if self.density in theme.DENSITIES else "comfortable"
|
|
45
|
+
return replace(self, zoom=zoom, density=density, opacity=max(40, min(100, self.opacity)))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def _blur_platform() -> bool:
|
|
49
|
+
app = QApplication.instance()
|
|
50
|
+
return app is not None and app.platformName() == "cocoa"
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class _Hub(QObject):
|
|
54
|
+
changed = Signal(object) # the new Preferences
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
_hub = None
|
|
58
|
+
_current = None
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def hub() -> _Hub:
|
|
62
|
+
global _hub
|
|
63
|
+
if _hub is None:
|
|
64
|
+
_hub = _Hub()
|
|
65
|
+
return _hub
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def store() -> QSettings:
|
|
69
|
+
"""The GUI's settings file (an INI file, so tests can move it)."""
|
|
70
|
+
return QSettings(QSettings.IniFormat, QSettings.UserScope, "sillon", "sillon-gui")
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def current() -> Preferences:
|
|
74
|
+
global _current
|
|
75
|
+
if _current is None:
|
|
76
|
+
_current = _load()
|
|
77
|
+
return _current
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def update(**changes) -> Preferences:
|
|
81
|
+
"""Changes some preferences: saved, applied to the app, announced."""
|
|
82
|
+
global _current
|
|
83
|
+
new = replace(current(), **changes).normalized()
|
|
84
|
+
if new == _current:
|
|
85
|
+
return new
|
|
86
|
+
_current = new
|
|
87
|
+
_save(new)
|
|
88
|
+
app = QApplication.instance()
|
|
89
|
+
if app is not None:
|
|
90
|
+
theme.apply(app, new)
|
|
91
|
+
hub().changed.emit(new)
|
|
92
|
+
return new
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def reset() -> Preferences:
|
|
96
|
+
"""Back to the defaults (the window layout is kept)."""
|
|
97
|
+
return update(**asdict(Preferences()))
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def _load() -> Preferences:
|
|
101
|
+
settings = store()
|
|
102
|
+
defaults = Preferences()
|
|
103
|
+
values = {}
|
|
104
|
+
for spec in fields(Preferences):
|
|
105
|
+
raw = settings.value(f"display/{spec.name}", getattr(defaults, spec.name))
|
|
106
|
+
try:
|
|
107
|
+
values[spec.name] = _coerce(raw, type(getattr(defaults, spec.name)))
|
|
108
|
+
except (TypeError, ValueError):
|
|
109
|
+
logger.exception("Ignoring the unreadable setting display/%s=%r", spec.name, raw)
|
|
110
|
+
return Preferences(**values).normalized()
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def _save(preferences: Preferences) -> None:
|
|
114
|
+
settings = store()
|
|
115
|
+
for name, value in asdict(preferences).items():
|
|
116
|
+
settings.setValue(f"display/{name}", value)
|
|
117
|
+
settings.sync()
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _coerce(raw, kind):
|
|
121
|
+
# INI files give back text: "true", "80".
|
|
122
|
+
if kind is bool:
|
|
123
|
+
return raw if isinstance(raw, bool) else str(raw).lower() in ("true", "1", "yes")
|
|
124
|
+
return kind(raw)
|