plesty-server 0.5.2__tar.gz → 0.5.4__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.
Files changed (85) hide show
  1. {plesty_server-0.5.2 → plesty_server-0.5.4}/PKG-INFO +4 -4
  2. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/presenter/bench.py +7 -2
  3. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/services/__init__.py +2 -0
  4. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/services/experiments.py +178 -0
  5. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/services/nodes.py +13 -0
  6. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/services/run_report.py +23 -1
  7. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/view/dialogs.py +9 -4
  8. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/view/window.py +49 -9
  9. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/view/workers.py +7 -0
  10. {plesty_server-0.5.2 → plesty_server-0.5.4}/pyproject.toml +4 -4
  11. {plesty_server-0.5.2 → plesty_server-0.5.4}/LICENSE +0 -0
  12. {plesty_server-0.5.2 → plesty_server-0.5.4}/LICENSES/ISC.txt +0 -0
  13. {plesty_server-0.5.2 → plesty_server-0.5.4}/LICENSES/LGPL-3.0-or-later.txt +0 -0
  14. {plesty_server-0.5.2 → plesty_server-0.5.4}/README.md +0 -0
  15. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/__init__.py +0 -0
  16. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/__main__.py +0 -0
  17. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/console.qss +0 -0
  18. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/env.example +0 -0
  19. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/fleet.example.yaml +0 -0
  20. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/copy.svg +0 -0
  21. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/download.svg +0 -0
  22. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/eraser.svg +0 -0
  23. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/flask-conical.svg +0 -0
  24. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/folder-input.svg +0 -0
  25. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/folder-open.svg +0 -0
  26. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/gauge.svg +0 -0
  27. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/octagon-x.svg +0 -0
  28. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/package-x.svg +0 -0
  29. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/pause.svg +0 -0
  30. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/pencil.svg +0 -0
  31. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/play.svg +0 -0
  32. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/plus.svg +0 -0
  33. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/power-off.svg +0 -0
  34. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/power.svg +0 -0
  35. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/refresh-cw.svg +0 -0
  36. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/rotate-ccw.svg +0 -0
  37. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/rotate-cw.svg +0 -0
  38. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/sliders-horizontal.svg +0 -0
  39. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/square.svg +0 -0
  40. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/step-forward.svg +0 -0
  41. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/icons/trash-2.svg +0 -0
  42. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/plesty-mark.svg +0 -0
  43. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/report.css +0 -0
  44. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/report.html +0 -0
  45. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/update.ps1 +0 -0
  46. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/update.sh +0 -0
  47. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/assets/update_window.py +0 -0
  48. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/cli/__init__.py +0 -0
  49. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/cli/main.py +0 -0
  50. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/config.yaml +0 -0
  51. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/host.py +0 -0
  52. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/__init__.py +0 -0
  53. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/agent.py +0 -0
  54. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/catalogue.py +0 -0
  55. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/device.py +0 -0
  56. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/device_manager.py +0 -0
  57. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/envfile.py +0 -0
  58. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/errors.py +0 -0
  59. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/experiment.py +0 -0
  60. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/field_test.py +0 -0
  61. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/fleet.py +0 -0
  62. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/home.py +0 -0
  63. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/job.py +0 -0
  64. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/peer.py +0 -0
  65. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/ports.py +0 -0
  66. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/process.py +0 -0
  67. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/purge.py +0 -0
  68. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/run_registry.py +0 -0
  69. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/traffic.py +0 -0
  70. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/model/yaml_edit.py +0 -0
  71. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/presenter/__init__.py +0 -0
  72. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/reexec.py +0 -0
  73. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/services/agent.py +0 -0
  74. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/services/catalogue.py +0 -0
  75. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/services/control.py +0 -0
  76. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/services/gitbin.py +0 -0
  77. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/services/installer.py +0 -0
  78. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/services/jobs.py +0 -0
  79. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/services/launch.py +0 -0
  80. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/services/problem_report.py +0 -0
  81. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/services/supervisor.py +0 -0
  82. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/services/updates.py +0 -0
  83. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/view/__init__.py +0 -0
  84. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/view/app.py +0 -0
  85. {plesty_server-0.5.2 → plesty_server-0.5.4}/plesty/server/view/control.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: plesty-server
3
- Version: 0.5.2
3
+ Version: 0.5.4
4
4
  Summary: The PLESTY bench application: installs, runs and field-tests device servers.
5
5
  Project-URL: Homepage, https://gitlab.com/plesty/core/plesty-bench
6
6
  Project-URL: Documentation, https://plesty.gitlab.io/core/plesty-bench/
@@ -12,12 +12,12 @@ License-File: LICENSES/ISC.txt
12
12
  License-File: LICENSES/LGPL-3.0-or-later.txt
13
13
  Requires-Python: >=3.12
14
14
  Requires-Dist: click>=8.1
15
- Requires-Dist: plesty-bench==0.5.2
16
- Requires-Dist: plesty-lib[report]>=0.6.2
15
+ Requires-Dist: plesty-bench==0.5.4
16
+ Requires-Dist: plesty-lib[report]>=0.6.3
17
17
  Requires-Dist: pyyaml>=6.0
18
18
  Requires-Dist: pyzmq>=26
19
19
  Provides-Extra: gui
20
- Requires-Dist: plesty-lib[gui]>=0.6.2; extra == 'gui'
20
+ Requires-Dist: plesty-lib[gui]>=0.6.3; extra == 'gui'
21
21
  Requires-Dist: pyside6==6.11.2; extra == 'gui'
22
22
  Description-Content-Type: text/markdown
23
23
 
@@ -144,6 +144,7 @@ from plesty.server.services import (
144
144
  serve_in_thread,
145
145
  status_of,
146
146
  steps_of,
147
+ time_left,
147
148
  Supervisor,
148
149
  SupervisorError,
149
150
  )
@@ -1828,9 +1829,11 @@ class Bench:
1828
1829
  if run_dir is None:
1829
1830
  return _not_started()
1830
1831
  status = status_of(run_dir)
1832
+ steps = steps_of(run_dir)
1831
1833
  status.update(
1832
1834
  run=run_dir.name,
1833
- total=len(steps_of(run_dir)),
1835
+ total=len(steps),
1836
+ left_s=time_left(status, steps),
1834
1837
  step=progress_of(run_dir),
1835
1838
  asked=asked(run_dir),
1836
1839
  report=report_of(run_dir),
@@ -2547,9 +2550,11 @@ class Bench:
2547
2550
  if not (path / "journal.jsonl").is_file():
2548
2551
  raise ExperimentError(f"{path} is not a run directory: it has no journal.jsonl.")
2549
2552
  status = status_of(path)
2553
+ steps = steps_of(path)
2550
2554
  status.update(
2551
2555
  run=path.name,
2552
- total=len(steps_of(path)),
2556
+ total=len(steps),
2557
+ left_s=time_left(status, steps),
2553
2558
  step=progress_of(path),
2554
2559
  asked=asked(path),
2555
2560
  path=str(path),
@@ -76,6 +76,7 @@ from plesty.server.services.experiments import (
76
76
  runs_of,
77
77
  status_of,
78
78
  steps_of,
79
+ time_left,
79
80
  )
80
81
  from plesty.server.services.jobs import JobRunner
81
82
  from plesty.server.services.nodes import (
@@ -136,6 +137,7 @@ __all__ = [
136
137
  "RUN_LOGS_DIR",
137
138
  "status_of",
138
139
  "steps_of",
140
+ "time_left",
139
141
  "Agent",
140
142
  "Catalogue",
141
143
  "CatalogueError",
@@ -30,7 +30,9 @@ kill stays for a process that has stopped answering.
30
30
  from __future__ import annotations
31
31
 
32
32
  import json
33
+ import re
33
34
  import subprocess
35
+ from datetime import datetime, timezone
34
36
  from pathlib import Path
35
37
  from typing import Any, Mapping, Sequence
36
38
 
@@ -552,6 +554,76 @@ def kept_log(run_dir: str | Path) -> Path | None:
552
554
  return logs[-1] if logs else None
553
555
 
554
556
 
557
+ #: How a module's start-up states the one line worth showing: the problem the
558
+ #: preflight found, else the exception that ended the process.
559
+ _PREFLIGHT_PROBLEM = re.compile(r"^\s+- (\S.*)$")
560
+ _EXCEPTION_LINE = re.compile(r"^(?:[\w.]+\.)?\w*(?:Error|Exception|Interrupt)\b.*")
561
+
562
+
563
+ def start_failure(run_dir: str | Path) -> dict[str, str] | None:
564
+ """Why a run's start job ended before its journal began, or ``None`` if none did.
565
+
566
+ A created run keeps the log of every job that tried to start it
567
+ (:func:`keep_log`). With no journal, the job ended before the module's
568
+ first step — a preflight that refused, a module that crashed — and the run
569
+ would read as "created" as if Run had never been pressed: on 2026-11-04
570
+ six starts died that way and the console showed nothing.
571
+
572
+ Returns:
573
+ ``log``, the newest such log, and ``reason``: the first problem the
574
+ preflight named, else the last exception line, else the log's last line.
575
+ """
576
+ log = kept_log(run_dir)
577
+ if log is None:
578
+ return None
579
+ try:
580
+ lines = log.read_text(encoding="utf-8", errors="replace").splitlines()
581
+ except OSError:
582
+ return None
583
+ reason = ""
584
+ for index, line in enumerate(lines):
585
+ if "failed the preflight" in line and index + 1 < len(lines):
586
+ found = _PREFLIGHT_PROBLEM.match(lines[index + 1])
587
+ if found:
588
+ reason = found.group(1)
589
+ break
590
+ if not reason:
591
+ raised = [line for line in lines if _EXCEPTION_LINE.match(line)]
592
+ reason = raised[-1] if raised else next((s for s in reversed(lines) if s.strip()), "")
593
+ return {"log": str(log), "reason": reason.strip()}
594
+
595
+
596
+ #: The run's own log, written by plesty-lib 0.6.3 on from the start-up on.
597
+ RUN_LOG_FILE = "run.log"
598
+
599
+
600
+ def _journaled_start_failure(
601
+ run_dir: str | Path, status: Mapping[str, Any]
602
+ ) -> dict[str, str] | None:
603
+ """Why a run's start ended before its first step, as its journal says, or ``None``.
604
+
605
+ plesty-lib 0.6.3 ends such a journal with ``run_aborted`` (``run_canceled``
606
+ when interrupted) marked ``stage: startup``, with the problem per device
607
+ of a failed preflight, else the error.
608
+
609
+ Returns:
610
+ ``log``, the run's own log (else the newest job log it keeps), and
611
+ ``reason``, the first device problem, else the error's first line.
612
+ """
613
+ last = status.get("last_event") or {}
614
+ if last.get("stage") != "startup" or last.get("event") not in ("run_aborted", "run_canceled"):
615
+ return None
616
+ problems = last.get("problems")
617
+ if isinstance(problems, dict) and problems:
618
+ device, problem = next(iter(problems.items()))
619
+ reason = f"{device}: {problem}"
620
+ else:
621
+ reason = next((s for s in str(last.get("error") or "").splitlines() if s.strip()), "")
622
+ own = Path(run_dir) / RUN_LOG_FILE
623
+ log = own if own.is_file() else kept_log(run_dir)
624
+ return {"log": str(log or ""), "reason": reason.strip() or "see its log"}
625
+
626
+
555
627
  def latest(run_root: str | Path) -> Path | None:
556
628
  """Return the newest run of *run_root*, or ``None`` when there is none."""
557
629
  runs = runs_of(run_root)
@@ -620,9 +692,24 @@ def status_of(run_dir: str | Path) -> dict[str, Any]:
620
692
  """
621
693
  status = _replay_status(Path(run_dir) / "journal.jsonl")
622
694
  created = created_of(run_dir)
695
+ # plesty-lib 0.6.3 on journals a start that ended before the first step
696
+ # itself (lib#73). Before any step began, it is a created run whose start
697
+ # failed, as the job log used to tell; after one, an aborted run with why.
698
+ startup = _journaled_start_failure(run_dir, status)
699
+ if startup is not None:
700
+ status["start_failed"] = startup
701
+ if created and not status.pop("_began", False):
702
+ status["state"] = "created"
703
+ status["created"] = created
704
+ status.pop("_began", None)
623
705
  if created and status["state"] == "not_started":
624
706
  status["state"] = "created"
625
707
  status["created"] = created
708
+ # Still "created", so Run starts it again under its name; but a job ran
709
+ # it and ended before its journal began, and saying so is the point.
710
+ failure = start_failure(run_dir)
711
+ if failure is not None:
712
+ status["start_failed"] = failure
626
713
  # Who measured it and the latest word on why (#40): read with the rest of
627
714
  # the row, on the refresh that reads the journal anyway.
628
715
  status["operator"] = str(created.get("operator") or "")
@@ -683,6 +770,8 @@ def _replay_status(journal: Path) -> dict[str, Any]:
683
770
  started = next((e for e in events if e.get("event") == "run_started"), {})
684
771
  provenance = started.get("provenance")
685
772
  return {
773
+ # Read by status_of, which removes it: whether the run ever began.
774
+ "_began": bool(started),
686
775
  "state": state,
687
776
  "completed": sum(1 for e in events if e.get("event") == "step_completed"),
688
777
  "failed": sum(1 for e in events if e.get("event") == "step_failed"),
@@ -693,9 +782,98 @@ def _replay_status(journal: Path) -> dict[str, Any]:
693
782
  "ended": last.get("ts") if last.get("event") in terminal else None,
694
783
  "provenance": provenance if isinstance(provenance, dict) else {},
695
784
  "last_event": last,
785
+ "timing": _step_timing(events),
696
786
  }
697
787
 
698
788
 
789
+ def _when(stamp: Any) -> datetime | None:
790
+ """A journal timestamp as an aware datetime, or ``None`` when it is not one."""
791
+ try:
792
+ when = datetime.fromisoformat(str(stamp))
793
+ except (TypeError, ValueError):
794
+ return None
795
+ return when if when.tzinfo is not None else when.replace(tzinfo=timezone.utc)
796
+
797
+
798
+ def _step_timing(events: Sequence[Mapping[str, Any]]) -> dict[str, Any]:
799
+ """How long the finished steps took, per operation, and the step in flight (#63).
800
+
801
+ Read from the journal's ``step_started`` / ``step_completed`` stamps, in
802
+ the same pass that reads the run's state.
803
+
804
+ Returns:
805
+ ``ops``: operation → ``[seconds, count]`` over the finished steps;
806
+ ``done``: the ids of the finished steps; ``in_flight``: ``{"op",
807
+ "since"}`` of a step started and not yet ended, else ``None``.
808
+ """
809
+ ops: dict[str, list[float]] = {}
810
+ done: list[str] = []
811
+ open_steps: dict[str, tuple[str, Any]] = {}
812
+ for event in events:
813
+ name = event.get("event")
814
+ step = str(event.get("step_id") or "")
815
+ if name == "step_started" and step:
816
+ open_steps[step] = (str(event.get("op") or ""), event.get("ts"))
817
+ elif name == "step_completed" and step:
818
+ done.append(step)
819
+ op, since = open_steps.pop(step, ("", None))
820
+ begun, ended = _when(since), _when(event.get("ts"))
821
+ if begun is not None and ended is not None:
822
+ total = ops.setdefault(op, [0.0, 0])
823
+ total[0] += max(0.0, (ended - begun).total_seconds())
824
+ total[1] += 1
825
+ elif name in ("step_failed", "step_aborted") and step:
826
+ open_steps.pop(step, None)
827
+ elif name in ("run_canceled", "run_aborted", "run_completed", "run_started"):
828
+ open_steps.clear() # a step left open by a stop is not in flight
829
+ in_flight = None
830
+ if open_steps:
831
+ op, since = list(open_steps.values())[-1]
832
+ in_flight = {"op": op, "since": since}
833
+ return {"ops": ops, "done": done, "in_flight": in_flight}
834
+
835
+
836
+ def time_left(
837
+ status: Mapping[str, Any], steps: Sequence[Mapping[str, Any]], now: datetime | None = None
838
+ ) -> float | None:
839
+ """Estimate the seconds a run has left, from how long its finished steps took (#63).
840
+
841
+ Each step still to do counts its operation's mean duration so far, or the
842
+ run's overall mean for an operation none has finished yet: a map row and
843
+ a g2 measurement differ by minutes, so one mean for all would mislead. The
844
+ step in flight counts what its mean leaves of the time it has already run.
845
+
846
+ Args:
847
+ status: The run's status, as :func:`status_of` returns it.
848
+ steps: The plan's steps (:func:`steps_of`).
849
+ now: The present; the clock's by default.
850
+
851
+ Returns:
852
+ Seconds, or ``None`` while no step has finished or the plan is unknown.
853
+ """
854
+ timing = status.get("timing") or {}
855
+ ops: Mapping[str, Sequence[float]] = timing.get("ops") or {}
856
+ seconds = sum(float(total) for total, _count in ops.values())
857
+ count = sum(int(n) for _total, n in ops.values())
858
+ if not count or not steps:
859
+ return None
860
+ overall = seconds / count
861
+
862
+ def mean(op: str) -> float:
863
+ total, n = ops.get(op, (0.0, 0))
864
+ return float(total) / int(n) if n else overall
865
+
866
+ done = set(timing.get("done") or ())
867
+ left = sum(mean(str(step.get("op") or "")) for step in steps if step.get("id") not in done)
868
+ flight = timing.get("in_flight")
869
+ if isinstance(flight, Mapping):
870
+ since = _when(flight.get("since"))
871
+ if since is not None:
872
+ ran = ((now or datetime.now(timezone.utc)) - since).total_seconds()
873
+ left -= min(max(0.0, ran), mean(str(flight.get("op") or "")))
874
+ return max(0.0, left)
875
+
876
+
699
877
  def progress_of(run_dir: str | Path) -> dict[str, Any] | None:
700
878
  """Return what the step in flight last said about itself.
701
879
 
@@ -112,6 +112,19 @@ class NodeLink:
112
112
  client = self._client
113
113
  if client is None:
114
114
  client = self._client = self._connect(self.peer)
115
+ if timeout_ms > POLL_TIMEOUT_MS:
116
+ # A long timeout is for a slow command, not for a bench that is
117
+ # not there: one switched off or on another network held Run
118
+ # for two minutes before saying so. Ask it to describe itself
119
+ # first, which an agent answers at once.
120
+ try:
121
+ client.describe(POLL_TIMEOUT_MS)
122
+ except BenchClientError as exc:
123
+ self._trouble = str(exc)
124
+ raise NodeError(
125
+ f"{self.name}: not answering at {self.peer.address} ({exc}) — is its "
126
+ "console running, and is this computer on its network?"
127
+ ) from exc
115
128
  try:
116
129
  result = client.exec(argv, timeout_ms=timeout_ms)
117
130
  except BenchClientError as exc:
@@ -123,6 +123,28 @@ def _read_json(path: Path) -> dict[str, Any]:
123
123
  return parsed if isinstance(parsed, dict) else {}
124
124
 
125
125
 
126
+ def _created_config(run: Path, created: Mapping[str, Any]) -> dict[str, Any]:
127
+ """The configuration of a run that has no plan yet: its own copy, else the file it names.
128
+
129
+ ``created.json`` names the module's configuration *file* (``config/default.yaml``),
130
+ not its values, and a run copies that file in as ``config.yaml`` when it is
131
+ created. A run that never started (its preflight refused) has only these
132
+ two, and the report showed neither: it took the file's name for the values.
133
+ """
134
+ import yaml
135
+
136
+ try:
137
+ values = yaml.safe_load((run / "config.yaml").read_text(encoding="utf-8"))
138
+ except (OSError, yaml.YAMLError):
139
+ values = None
140
+ if isinstance(values, dict):
141
+ return values
142
+ named = created.get("config")
143
+ if isinstance(named, Mapping):
144
+ return dict(named)
145
+ return {"file": named} if named else {}
146
+
147
+
126
148
  def _listing(directory: Path, pattern: str) -> list[Path]:
127
149
  """The files *pattern* matches, without macOS AppleDouble companions.
128
150
 
@@ -608,7 +630,7 @@ def report(run_dir: str | Path, experiment: str = "") -> str:
608
630
  page, fragments = _template()
609
631
  summary = _events(journal)
610
632
  provenance = summary["provenance"]
611
- config = plan.get("config") or created.get("config") or {}
633
+ config = plan.get("config") or _created_config(run, created)
612
634
  groups = _records(run)
613
635
  committed = sum(len(rows) for _, _, rows in groups)
614
636
  reports = _reports(run)
@@ -4539,10 +4539,15 @@ class InstalledModulesDialog(QDialog):
4539
4539
 
4540
4540
 
4541
4541
  def _default_instance(package: str) -> str:
4542
- stem = package.lower()
4543
- for prefix in ("plesty-", "plesty_"):
4544
- if stem.startswith(prefix):
4545
- stem = stem[len(prefix) :]
4542
+ """The name a module is declared under by default: its own, without ``plesty-``.
4543
+
4544
+ Only the prefix is matched without regard to case. The rest keeps the case
4545
+ it was written in: the name is looked up as written, so a lowercased
4546
+ ``perovskite-g2-search-sm`` was not the ``-SM`` the dialog showed (#62).
4547
+ """
4548
+ stem = package.strip()
4549
+ if stem[:7].lower() in ("plesty-", "plesty_"):
4550
+ stem = stem[7:]
4546
4551
  return stem.replace("_", "-")
4547
4552
 
4548
4553
 
@@ -27,7 +27,7 @@ import functools
27
27
  import json
28
28
  import sys
29
29
  from collections.abc import Callable, Mapping, Sequence
30
- from datetime import datetime
30
+ from datetime import datetime, timedelta
31
31
  from importlib import resources
32
32
  from pathlib import Path
33
33
  from typing import Any
@@ -948,12 +948,15 @@ class MainWindow(QMainWindow):
948
948
  for index, row in enumerate(rows):
949
949
  status = row["status"]
950
950
  state = str(status.get("state", "not_started"))
951
+ # A start that died before the run's journal began: still a
952
+ # created run, which Run starts again, but never one waiting quietly.
953
+ failed = status.get("start_failed") or {}
951
954
  cells = (
952
955
  str(status.get("run") or "—"),
953
956
  row["name"],
954
957
  str(row.get("source") or "—"),
955
- _experiment_state(state),
956
- _progress_text(status),
958
+ "start failed" if failed else _experiment_state(state),
959
+ str(failed.get("reason") or "") if failed else _progress_text(status),
957
960
  _clock(status.get("started")),
958
961
  _clock(status.get("ended")),
959
962
  str(status.get("operator") or "—"),
@@ -962,7 +965,8 @@ class MainWindow(QMainWindow):
962
965
  for column, text in enumerate(cells):
963
966
  item = QTableWidgetItem(text)
964
967
  if column == EXP_STATE_COLUMN:
965
- item.setForeground(_tone_brush(self, _state_tone(state)))
968
+ tone = "failed" if failed else _state_tone(state)
969
+ item.setForeground(_tone_brush(self, tone))
966
970
  if column in (EXP_SOURCE_COLUMN, EXP_NOTE_COLUMN):
967
971
  item.setToolTip(text) # the cell elides it
968
972
  self.exp_table.setItem(index, column, item)
@@ -1149,7 +1153,7 @@ class MainWindow(QMainWindow):
1149
1153
  # something that belongs to a different run — an older job that
1150
1154
  # happens to name this one, the newest records of the experiment.
1151
1155
  if not run or str(status.get("state", "")) == "created":
1152
- self._show_not_started(name, str(run or ""))
1156
+ self._show_not_started(name, str(run or ""), status.get("start_failed"))
1153
1157
  return
1154
1158
  tab = self.exp_tabs.tabText(self.exp_tabs.currentIndex())
1155
1159
  if tab == "Log":
@@ -1161,19 +1165,35 @@ class MainWindow(QMainWindow):
1161
1165
  else:
1162
1166
  self._show_visualization(name, status)
1163
1167
 
1164
- def _show_not_started(self, name: str, run: str) -> None:
1168
+ def _show_not_started(
1169
+ self, name: str, run: str, failed: Mapping[str, Any] | None = None
1170
+ ) -> None:
1165
1171
  """Empty every pane, for a run that has produced nothing yet.
1166
1172
 
1167
1173
  A created run has a name, a configuration and a place to write, and
1168
1174
  nothing else — no log, no records, no report, no views. Saying that in
1169
1175
  each pane is the honest answer; showing the previous run's is not.
1170
1176
 
1177
+ One whose start failed has one thing more: the log of the job that
1178
+ tried, which says why. The Log pane shows it; the others say the start
1179
+ failed.
1180
+
1171
1181
  Args:
1172
- name: The experiment.
1173
- run: The run's id, or ``""`` when the experiment has never run.
1182
+ name: The experiment.
1183
+ run: The run's id, or ``""`` when the experiment has never run.
1184
+ failed: The run's ``start_failed`` status, when a start ended before
1185
+ its journal began.
1174
1186
  """
1175
1187
  waiting = f"{run} has not started yet — Run starts it." if run else f"{name} has no runs."
1176
- self.exp_log.setPlainText(waiting)
1188
+ if failed:
1189
+ waiting = f"{run} did not start: {failed.get('reason') or 'see its log'}"
1190
+ try:
1191
+ log = Path(str(failed["log"])).read_text(encoding="utf-8", errors="replace")
1192
+ except (KeyError, OSError):
1193
+ log = ""
1194
+ self.exp_log.setPlainText(f"{waiting}\n\n{log}" if log else waiting)
1195
+ else:
1196
+ self.exp_log.setPlainText(waiting)
1177
1197
  self.exp_report.setPlainText(waiting)
1178
1198
  self.exp_data.clear()
1179
1199
  self.exp_data.addTopLevelItem(QTreeWidgetItem((waiting, "")))
@@ -4129,6 +4149,23 @@ def _state_tone(state: str) -> str:
4129
4149
  return "stopped"
4130
4150
 
4131
4151
 
4152
+ def _time_left_text(seconds: float, now: datetime | None = None) -> str:
4153
+ """``~14 h 20 min left, ends ~07:05``: how long a run has left, and when it ends (#63).
4154
+
4155
+ ``~``, not ``≈``: the line reaches streams a Windows code page encodes.
4156
+
4157
+ The end is in this bench's local time, with the day named when it is not
4158
+ today — a run of a day and more ends on another one.
4159
+ """
4160
+ minutes = max(1, round(seconds / 60))
4161
+ hours, minutes = divmod(minutes, 60)
4162
+ span = f"{hours} h {minutes} min" if hours else f"{minutes} min"
4163
+ start = now or datetime.now()
4164
+ end = start + timedelta(seconds=seconds)
4165
+ when = end.strftime("%H:%M") if end.date() == start.date() else end.strftime("%a %H:%M")
4166
+ return f"~{span} left, ends ~{when}"
4167
+
4168
+
4132
4169
  def _progress_text(status: Mapping[str, Any]) -> str:
4133
4170
  """One line saying how far a run has got, and what it is doing now.
4134
4171
 
@@ -4143,6 +4180,9 @@ def _progress_text(status: Mapping[str, Any]) -> str:
4143
4180
  failed = int(status.get("failed") or 0)
4144
4181
  if failed:
4145
4182
  line += f", {failed} failed"
4183
+ left = status.get("left_s")
4184
+ if status.get("state") == "running" and isinstance(left, (int, float)) and completed < total:
4185
+ line += f" · {_time_left_text(float(left))}"
4146
4186
  step = status.get("step")
4147
4187
  if isinstance(step, Mapping) and step.get("detail"):
4148
4188
  line += f" · {step['detail']}"
@@ -76,6 +76,13 @@ class Worker(QObject):
76
76
  def _release() -> None:
77
77
  if signals in self._live:
78
78
  self._live.remove(signals)
79
+ # The slots connected below hold *signals* in their closures, and
80
+ # the connection that holds them is Qt's, out of the collector's
81
+ # sight: dropped from _live, the object was still never freed. One
82
+ # per task, a few every second, grew the console by 85 MB an hour
83
+ # until Windows ran out of memory and took device servers with it
84
+ # (#64). Deleting the QObject drops its connections, and the cycle.
85
+ signals.deleteLater()
79
86
 
80
87
  if on_done is not None:
81
88
  signals.done.connect(on_done)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "plesty-server"
3
- version = "0.5.2"
3
+ version = "0.5.4"
4
4
  license = "LGPL-3.0-or-later"
5
5
  license-files = ["LICENSE", "LICENSES/*"]
6
6
  description = "The PLESTY bench application: installs, runs and field-tests device servers."
@@ -9,8 +9,8 @@ maintainers = [{ name = "Plesty Development Team", email = "plesty.dev@example.c
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
11
11
  dependencies = [
12
- "plesty-bench==0.5.2",
13
- "plesty-lib[report]>=0.6.2",
12
+ "plesty-bench==0.5.4",
13
+ "plesty-lib[report]>=0.6.3",
14
14
  "pyyaml>=6.0",
15
15
  "pyzmq>=26",
16
16
  "click>=8.1",
@@ -18,7 +18,7 @@ dependencies = [
18
18
 
19
19
  [project.optional-dependencies]
20
20
  gui = [
21
- "plesty-lib[gui]>=0.6.2",
21
+ "plesty-lib[gui]>=0.6.3",
22
22
  "pyside6==6.11.2",
23
23
  ]
24
24
 
File without changes
File without changes