logqbit 0.7.2__tar.gz → 0.7.3__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.
- {logqbit-0.7.2 → logqbit-0.7.3}/PKG-INFO +3 -4
- {logqbit-0.7.2 → logqbit-0.7.3}/README.md +2 -3
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/catalog.py +134 -79
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/detail/files.py +49 -2
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/detail/view.py +6 -4
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/plot/manager.py +3 -1
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/window/view.py +4 -4
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/logfolder.py +4 -1
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/core/test_log_catalog.py +144 -22
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/gui/browser/test_catalog.py +9 -4
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/gui/browser/test_detail.py +1 -1
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/gui/browser/test_list.py +4 -1
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/gui/browser/test_plot.py +6 -2
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/gui/browser/test_window.py +12 -11
- {logqbit-0.7.2 → logqbit-0.7.3}/.gitignore +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/LICENSE +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/pyproject.toml +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/__init__.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/assets/browser.svg +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/assets/live_plotter.svg +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/cli/__init__.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/cli/__main__.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/cli/demo.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/cli/main.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/cli/shortcuts.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/cli/svg2ico.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/dataframe.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/file_version.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/__init__.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/__init__.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/__main__.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/about.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/detail/__init__.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/detail/data.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/detail/yaml.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/plot/__init__.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/plot/cursor.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/plot/fitting.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/plot/grouping.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/plot/mesh.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/startup.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/window/__init__.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/window/merge.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/window/model.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/browser/window/preferences.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/gui/live_plotter.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/metadata.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/registry.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/src/logqbit/templates/move_from_labrad.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/core/test_browser_launcher.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/core/test_cli.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/core/test_dataframe.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/core/test_logfolder.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/core/test_metadata.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/core/test_public_api.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/core/test_registry.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/for_all_pythons.ps1 +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/gui/browser/conftest.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/gui/browser/test_data.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/gui/browser/test_preferences.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/gui/browser/test_startup.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/gui/browser/test_yaml.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/gui/conftest.py +0 -0
- {logqbit-0.7.2 → logqbit-0.7.3}/tests/gui/test_live_plotter.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: logqbit
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.3
|
|
4
4
|
Summary: A lightweight, directory-based toolkit for logging and organizing lab experiment data.
|
|
5
5
|
Project-URL: Homepage, https://github.com/Qiujv/logqbit
|
|
6
6
|
Author-email: Qiujv <qiujv@outlook.com>
|
|
@@ -46,8 +46,6 @@ pip install logqbit
|
|
|
46
46
|
pip install "logqbit[gui]"
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
更详细的安装说明见:https://qiujv.github.io/logqbit/install/
|
|
50
|
-
|
|
51
49
|
## 用例
|
|
52
50
|
|
|
53
51
|
### 用例 1:记录一组实验数据
|
|
@@ -88,6 +86,7 @@ logqbit browser-demo
|
|
|
88
86
|
更多内容:
|
|
89
87
|
|
|
90
88
|
- 文档首页:https://qiujv.github.io/logqbit/
|
|
91
|
-
-
|
|
89
|
+
- 核心 API:https://qiujv.github.io/logqbit/core/
|
|
92
90
|
- 数据浏览器:https://qiujv.github.io/logqbit/browser/
|
|
93
91
|
- 命令行工具:https://qiujv.github.io/logqbit/cli/
|
|
92
|
+
- PyPI:https://pypi.org/project/logqbit/
|
|
@@ -23,8 +23,6 @@ pip install logqbit
|
|
|
23
23
|
pip install "logqbit[gui]"
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
更详细的安装说明见:https://qiujv.github.io/logqbit/install/
|
|
27
|
-
|
|
28
26
|
## 用例
|
|
29
27
|
|
|
30
28
|
### 用例 1:记录一组实验数据
|
|
@@ -65,6 +63,7 @@ logqbit browser-demo
|
|
|
65
63
|
更多内容:
|
|
66
64
|
|
|
67
65
|
- 文档首页:https://qiujv.github.io/logqbit/
|
|
68
|
-
-
|
|
66
|
+
- 核心 API:https://qiujv.github.io/logqbit/core/
|
|
69
67
|
- 数据浏览器:https://qiujv.github.io/logqbit/browser/
|
|
70
68
|
- 命令行工具:https://qiujv.github.io/logqbit/cli/
|
|
69
|
+
- PyPI:https://pypi.org/project/logqbit/
|
|
@@ -12,13 +12,15 @@ from collections.abc import Callable, Iterable, Sequence
|
|
|
12
12
|
from dataclasses import dataclass
|
|
13
13
|
from functools import cached_property
|
|
14
14
|
from pathlib import Path
|
|
15
|
+
from typing import Self
|
|
15
16
|
|
|
16
17
|
import pandas as pd
|
|
17
18
|
import pyarrow
|
|
18
|
-
import pyarrow.
|
|
19
|
+
import pyarrow.dataset
|
|
19
20
|
|
|
20
21
|
from .file_version import FileVersion
|
|
21
22
|
from .metadata import LogMetadata
|
|
23
|
+
from .registry import Registry
|
|
22
24
|
|
|
23
25
|
__all__ = [
|
|
24
26
|
"LogCatalog",
|
|
@@ -36,14 +38,16 @@ __all__ = [
|
|
|
36
38
|
|
|
37
39
|
logger = logging.getLogger(__name__)
|
|
38
40
|
|
|
39
|
-
_IMAGE_EXTENSIONS = {".png", ".jpg", ".jpeg", ".webp", ".bmp", ".gif"}
|
|
40
|
-
_KNOWN_LOG_FILENAMES = {"const.yaml", "data.feather", "metadata.json"}
|
|
41
41
|
_FLOAT_LOG_ID_PATTERN = re.compile(r"[+-]?[0-9]+(?:\.[0-9]+)?")
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
_RETRY_VERSION = FileVersion(mtime_ns=-1, size=-1, inode=-1)
|
|
45
45
|
|
|
46
46
|
|
|
47
|
+
class _DataChangedDuringInspection(RuntimeError):
|
|
48
|
+
pass
|
|
49
|
+
|
|
50
|
+
|
|
47
51
|
@dataclass(frozen=True)
|
|
48
52
|
class PlotColumns:
|
|
49
53
|
"""Plot roles resolved against the columns available in one record."""
|
|
@@ -102,19 +106,34 @@ def _ordered_unique(items: Sequence[str]) -> tuple[str, ...]:
|
|
|
102
106
|
|
|
103
107
|
|
|
104
108
|
@dataclass(frozen=True)
|
|
109
|
+
class _DataSummary:
|
|
110
|
+
data_version: FileVersion | None
|
|
111
|
+
row_count: int
|
|
112
|
+
columns: tuple[str, ...]
|
|
113
|
+
|
|
114
|
+
|
|
105
115
|
class LogRecord:
|
|
106
|
-
"""
|
|
116
|
+
"""Handle to one existing log record.
|
|
107
117
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
118
|
+
The standard record files are exposed through lazy accessors without
|
|
119
|
+
creating a dataframe writer or missing files. Catalog summary data is
|
|
120
|
+
inspected on demand and refreshed in place.
|
|
121
|
+
"""
|
|
112
122
|
|
|
113
|
-
def
|
|
114
|
-
path = Path(
|
|
123
|
+
def __init__(self, path: str | Path) -> None:
|
|
124
|
+
path = Path(path)
|
|
115
125
|
if not path.is_dir():
|
|
116
126
|
raise FileNotFoundError(f"Log directory at '{path}' does not exist.")
|
|
117
|
-
|
|
127
|
+
self._path = path
|
|
128
|
+
self._data_summary: _DataSummary | None = None
|
|
129
|
+
|
|
130
|
+
def __repr__(self) -> str:
|
|
131
|
+
return f"{type(self).__name__}(path={self.path!r})"
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
def path(self) -> Path:
|
|
135
|
+
"""Directory containing this record's files."""
|
|
136
|
+
return self._path
|
|
118
137
|
|
|
119
138
|
@property
|
|
120
139
|
def log_id(self) -> int | float | str:
|
|
@@ -142,103 +161,134 @@ class LogRecord:
|
|
|
142
161
|
default_on_error=True,
|
|
143
162
|
)
|
|
144
163
|
|
|
145
|
-
|
|
164
|
+
@cached_property
|
|
165
|
+
def reg(self) -> Registry:
|
|
166
|
+
"""Return the existing ``const.yaml`` registry without creating it."""
|
|
167
|
+
return Registry(self.const_path, create=False)
|
|
168
|
+
|
|
169
|
+
@property
|
|
170
|
+
def const(self) -> Registry:
|
|
171
|
+
"""Alias for :attr:`reg`."""
|
|
172
|
+
return self.reg
|
|
173
|
+
|
|
174
|
+
# Common metadata shortcuts delegate to LogMetadata's synchronized fields.
|
|
146
175
|
@property
|
|
147
176
|
def title(self) -> str:
|
|
148
|
-
return
|
|
177
|
+
return self.meta.title
|
|
149
178
|
|
|
150
179
|
@property
|
|
151
180
|
def star(self) -> int:
|
|
152
|
-
return
|
|
181
|
+
return self.meta.star
|
|
153
182
|
|
|
154
183
|
@property
|
|
155
184
|
def trash(self) -> bool:
|
|
156
|
-
return
|
|
185
|
+
return self.meta.trash
|
|
186
|
+
|
|
187
|
+
@property
|
|
188
|
+
def row_count(self) -> int:
|
|
189
|
+
"""Number of rows in the current on-disk dataframe."""
|
|
190
|
+
return self._require_data_summary().row_count
|
|
191
|
+
|
|
192
|
+
@property
|
|
193
|
+
def columns(self) -> tuple[str, ...]:
|
|
194
|
+
"""Column names in the current on-disk dataframe."""
|
|
195
|
+
return self._require_data_summary().columns
|
|
196
|
+
|
|
197
|
+
@property
|
|
198
|
+
def data_version(self) -> FileVersion | None:
|
|
199
|
+
"""Filesystem identity of the inspected ``data.feather`` generation."""
|
|
200
|
+
return self._require_data_summary().data_version
|
|
157
201
|
|
|
158
202
|
@property
|
|
159
203
|
def resolved_plot_columns(self) -> PlotColumns:
|
|
160
204
|
"""Return the effective plot roles for the current data columns."""
|
|
161
205
|
return resolve_plot_columns(
|
|
162
206
|
self.columns,
|
|
163
|
-
self.meta.
|
|
164
|
-
self.meta.
|
|
165
|
-
self.meta.
|
|
207
|
+
self.meta.plot_axes,
|
|
208
|
+
self.meta.plot_fields,
|
|
209
|
+
self.meta.plot_groupby,
|
|
166
210
|
)
|
|
167
211
|
|
|
168
212
|
@property
|
|
169
213
|
def create_time(self) -> str:
|
|
170
|
-
return
|
|
214
|
+
return self.meta.create_time
|
|
171
215
|
|
|
172
216
|
@property
|
|
173
217
|
def create_machine(self) -> str:
|
|
174
|
-
return
|
|
218
|
+
return self.meta.create_machine
|
|
175
219
|
|
|
176
220
|
def read_dataframe(self) -> pd.DataFrame | None:
|
|
177
|
-
"""Read the current Feather file
|
|
221
|
+
"""Read the current Feather file, bypassing the cached :attr:`df`."""
|
|
178
222
|
if not self.data_path.exists():
|
|
179
223
|
return None
|
|
180
224
|
try:
|
|
181
|
-
|
|
225
|
+
# Close the disk handle before Arrow parsing to reduce Windows
|
|
226
|
+
# replace races while still reading one consistent generation.
|
|
227
|
+
data = pyarrow.BufferReader(self.data_path.read_bytes())
|
|
228
|
+
return pd.read_feather(data)
|
|
182
229
|
except Exception as exc: # pragma: no cover - defensive
|
|
183
230
|
logger.error("Failed to read feather file %s: %s", self.data_path, exc)
|
|
184
231
|
return None
|
|
185
232
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
233
|
+
@cached_property
|
|
234
|
+
def df(self) -> pd.DataFrame | None:
|
|
235
|
+
"""Return a lazily cached in-memory snapshot of ``data.feather``.
|
|
236
|
+
|
|
237
|
+
Mutating the returned dataframe changes only this cached object. Call
|
|
238
|
+
:meth:`read_dataframe` to read the current file without using it.
|
|
239
|
+
"""
|
|
240
|
+
version_before = FileVersion.from_path(self.data_path)
|
|
241
|
+
dataframe = self.read_dataframe()
|
|
242
|
+
version_after = FileVersion.from_path(self.data_path)
|
|
243
|
+
if dataframe is not None:
|
|
244
|
+
if version_before == version_after:
|
|
245
|
+
self._data_summary = _DataSummary(
|
|
246
|
+
data_version=version_after,
|
|
247
|
+
row_count=len(dataframe),
|
|
248
|
+
columns=tuple(str(column) for column in dataframe.columns),
|
|
249
|
+
)
|
|
250
|
+
else:
|
|
251
|
+
self._data_summary = None
|
|
252
|
+
elif version_after is None:
|
|
253
|
+
self._data_summary = _DataSummary(None, 0, ())
|
|
254
|
+
return dataframe
|
|
255
|
+
|
|
256
|
+
def refresh(self) -> Self:
|
|
257
|
+
"""Refresh cached file-backed state in place and return this record."""
|
|
258
|
+
metadata = self.__dict__.get("meta")
|
|
259
|
+
if metadata is not None:
|
|
260
|
+
metadata.reload()
|
|
261
|
+
self._refresh_data_summary()
|
|
262
|
+
return self
|
|
263
|
+
|
|
264
|
+
def _require_data_summary(self) -> _DataSummary:
|
|
265
|
+
if self._data_summary is None:
|
|
266
|
+
self._refresh_data_summary()
|
|
267
|
+
assert self._data_summary is not None
|
|
268
|
+
return self._data_summary
|
|
269
|
+
|
|
270
|
+
def _refresh_data_summary(self) -> bool:
|
|
189
271
|
data_version = FileVersion.from_path(self.data_path)
|
|
190
|
-
|
|
191
|
-
|
|
272
|
+
previous = self._data_summary
|
|
273
|
+
if previous is not None and previous.data_version == data_version:
|
|
274
|
+
return False
|
|
192
275
|
|
|
193
276
|
try:
|
|
194
277
|
row_count, columns = _inspect_data(self.data_path, data_version)
|
|
278
|
+
except _DataChangedDuringInspection:
|
|
279
|
+
if previous is not None:
|
|
280
|
+
return False
|
|
281
|
+
row_count, columns = 0, ()
|
|
282
|
+
data_version = _RETRY_VERSION
|
|
195
283
|
except Exception as exc: # pragma: no cover - defensive
|
|
196
284
|
logger.warning("Failed to inspect feather file %s: %s", self.data_path, exc)
|
|
197
285
|
row_count, columns = 0, ()
|
|
198
286
|
data_version = _RETRY_VERSION
|
|
199
|
-
return LogRecord(
|
|
200
|
-
path=self.path,
|
|
201
|
-
row_count=row_count,
|
|
202
|
-
columns=columns,
|
|
203
|
-
data_version=data_version,
|
|
204
|
-
)
|
|
205
|
-
|
|
206
|
-
def read_yaml_text(self) -> str:
|
|
207
|
-
if not self.const_path.exists():
|
|
208
|
-
return "const.yaml not found."
|
|
209
|
-
try:
|
|
210
|
-
text = self.const_path.read_text(encoding="utf-8", errors="ignore")
|
|
211
|
-
except Exception as exc: # pragma: no cover - defensive
|
|
212
|
-
logger.error("Failed to read yaml file %s: %s", self.const_path, exc)
|
|
213
|
-
return f"Failed to read const.yaml: {exc}"
|
|
214
|
-
return text if text.strip() else "(const.yaml is empty)"
|
|
215
|
-
|
|
216
|
-
def list_image_files(self) -> list[Path]:
|
|
217
|
-
return self._list_files(lambda path: path.suffix.lower() in _IMAGE_EXTENSIONS)
|
|
218
|
-
|
|
219
|
-
def list_other_files(self) -> list[Path]:
|
|
220
|
-
return self._list_files(
|
|
221
|
-
lambda path: (
|
|
222
|
-
path.name not in _KNOWN_LOG_FILENAMES
|
|
223
|
-
and path.suffix.lower() not in _IMAGE_EXTENSIONS
|
|
224
|
-
)
|
|
225
|
-
)
|
|
226
|
-
|
|
227
|
-
def _list_files(self, predicate: Callable[[Path], bool]) -> list[Path]:
|
|
228
|
-
try:
|
|
229
|
-
files = [
|
|
230
|
-
child
|
|
231
|
-
for child in self.path.iterdir()
|
|
232
|
-
if child.is_file() and predicate(child)
|
|
233
|
-
]
|
|
234
|
-
except OSError:
|
|
235
|
-
return []
|
|
236
|
-
return sorted(files)
|
|
237
287
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
288
|
+
self._data_summary = _DataSummary(data_version, row_count, columns)
|
|
289
|
+
if previous is not None:
|
|
290
|
+
self.__dict__.pop("df", None)
|
|
291
|
+
return True
|
|
242
292
|
|
|
243
293
|
|
|
244
294
|
def _inspect_data(
|
|
@@ -247,12 +297,16 @@ def _inspect_data(
|
|
|
247
297
|
) -> tuple[int, tuple[str, ...]]:
|
|
248
298
|
if version is None:
|
|
249
299
|
return 0, ()
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
300
|
+
# PyArrow 21/macOS warm-cache benchmark, 61-122 MiB Feather files:
|
|
301
|
+
# Dataset took 3.6-7.8 ms, versus 5.7-13.2 ms for direct IPC and
|
|
302
|
+
# 7.2-16.5 ms for a full BufferReader. On the 122 MiB case, observed file
|
|
303
|
+
# handle windows were 8.9, 11.2, and 9.4 ms respectively.
|
|
304
|
+
dataset = pyarrow.dataset.dataset(data_path, format="feather")
|
|
305
|
+
columns = tuple(str(name) for name in dataset.schema.names)
|
|
306
|
+
row_count = dataset.count_rows()
|
|
307
|
+
# Dataset may reopen the path between schema and row-count reads.
|
|
308
|
+
if FileVersion.from_path(data_path) != version:
|
|
309
|
+
raise _DataChangedDuringInspection
|
|
256
310
|
return row_count, columns
|
|
257
311
|
|
|
258
312
|
|
|
@@ -286,10 +340,11 @@ class LogCatalog:
|
|
|
286
340
|
del self._records[removed_path]
|
|
287
341
|
|
|
288
342
|
for path in paths:
|
|
289
|
-
|
|
290
|
-
if
|
|
291
|
-
|
|
292
|
-
|
|
343
|
+
record = self._records.get(path)
|
|
344
|
+
if record is None:
|
|
345
|
+
record = LogRecord(path)
|
|
346
|
+
self._records[path] = record
|
|
347
|
+
record.refresh()
|
|
293
348
|
|
|
294
349
|
return sorted(
|
|
295
350
|
self._records.values(),
|
|
@@ -5,9 +5,8 @@ from __future__ import annotations
|
|
|
5
5
|
import logging
|
|
6
6
|
import subprocess
|
|
7
7
|
import sys
|
|
8
|
-
from pathlib import Path
|
|
9
|
-
|
|
10
8
|
from collections.abc import Callable
|
|
9
|
+
from pathlib import Path
|
|
11
10
|
|
|
12
11
|
import pyqtgraph as pg
|
|
13
12
|
from PySide6.QtCore import QMimeData, QPoint, Qt, QUrl, Signal
|
|
@@ -28,6 +27,54 @@ from PySide6.QtWidgets import (
|
|
|
28
27
|
from send2trash import send2trash
|
|
29
28
|
|
|
30
29
|
logger = logging.getLogger(__name__)
|
|
30
|
+
_IMAGE_EXTENSIONS = {".png", ".jpg", ".jpeg", ".webp", ".bmp", ".gif"}
|
|
31
|
+
_KNOWN_RECORD_FILENAMES = {"const.yaml", "data.feather", "metadata.json"}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def read_yaml_text(path: Path) -> str:
|
|
35
|
+
"""Return display text for a record's ``const.yaml`` file."""
|
|
36
|
+
if not path.exists():
|
|
37
|
+
return "const.yaml not found."
|
|
38
|
+
try:
|
|
39
|
+
text = path.read_text(encoding="utf-8", errors="ignore")
|
|
40
|
+
except Exception as exc: # pragma: no cover - defensive
|
|
41
|
+
logger.error("Failed to read yaml file %s: %s", path, exc)
|
|
42
|
+
return f"Failed to read const.yaml: {exc}"
|
|
43
|
+
return text if text.strip() else "(const.yaml is empty)"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def list_image_files(record_path: Path) -> list[Path]:
|
|
47
|
+
"""List image files rendered as record detail tabs."""
|
|
48
|
+
return _list_record_files(
|
|
49
|
+
record_path,
|
|
50
|
+
lambda path: path.suffix.lower() in _IMAGE_EXTENSIONS,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def list_other_files(record_path: Path) -> list[Path]:
|
|
55
|
+
"""List non-standard files that are not rendered as image tabs."""
|
|
56
|
+
return _list_record_files(
|
|
57
|
+
record_path,
|
|
58
|
+
lambda path: (
|
|
59
|
+
path.name not in _KNOWN_RECORD_FILENAMES
|
|
60
|
+
and path.suffix.lower() not in _IMAGE_EXTENSIONS
|
|
61
|
+
),
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _list_record_files(
|
|
66
|
+
record_path: Path,
|
|
67
|
+
predicate: Callable[[Path], bool],
|
|
68
|
+
) -> list[Path]:
|
|
69
|
+
try:
|
|
70
|
+
files = [
|
|
71
|
+
child
|
|
72
|
+
for child in record_path.iterdir()
|
|
73
|
+
if child.is_file() and predicate(child)
|
|
74
|
+
]
|
|
75
|
+
except OSError:
|
|
76
|
+
return []
|
|
77
|
+
return sorted(files)
|
|
31
78
|
|
|
32
79
|
|
|
33
80
|
def open_in_file_manager(
|
|
@@ -38,7 +38,9 @@ from PySide6.QtWidgets import (
|
|
|
38
38
|
from logqbit.gui.browser.detail.data import DataViewManager
|
|
39
39
|
from logqbit.gui.browser.detail.files import (
|
|
40
40
|
ImageTab,
|
|
41
|
+
list_image_files,
|
|
41
42
|
open_in_file_manager,
|
|
43
|
+
read_yaml_text,
|
|
42
44
|
)
|
|
43
45
|
from logqbit.gui.browser.detail.yaml import YamlView
|
|
44
46
|
from logqbit.gui.browser.plot.manager import PlotManager
|
|
@@ -111,7 +113,7 @@ def record_watch_paths(record: LogRecord) -> list[str]:
|
|
|
111
113
|
record.const_path,
|
|
112
114
|
record.data_path,
|
|
113
115
|
record.meta_path,
|
|
114
|
-
*record.
|
|
116
|
+
*list_image_files(record.path),
|
|
115
117
|
):
|
|
116
118
|
if extra and extra.exists():
|
|
117
119
|
paths.append(str(extra))
|
|
@@ -179,15 +181,15 @@ class RecordDetailView(QWidget):
|
|
|
179
181
|
dataframe = self._data_cache.dataframe
|
|
180
182
|
self._record = record
|
|
181
183
|
self.detail_id_label.setText(f"#{record.log_id}")
|
|
182
|
-
self.detail_label.setText(
|
|
183
|
-
self.yaml_view.set_yaml_text(record.
|
|
184
|
+
self.detail_label.setText(record.path.as_posix())
|
|
185
|
+
self.yaml_view.set_yaml_text(read_yaml_text(record.const_path))
|
|
184
186
|
if metadata_changed or data_changed:
|
|
185
187
|
self.data_view_manager.show_data_table(
|
|
186
188
|
record,
|
|
187
189
|
dataframe,
|
|
188
190
|
preview_only=True,
|
|
189
191
|
)
|
|
190
|
-
self._update_image_tabs(record.
|
|
192
|
+
self._update_image_tabs(list_image_files(record.path))
|
|
191
193
|
self.files_button.setEnabled(True)
|
|
192
194
|
defer_plot = self.tab_widget.currentIndex() != TAB_PLOT
|
|
193
195
|
if metadata_changed:
|
|
@@ -495,10 +495,12 @@ class PlotManager:
|
|
|
495
495
|
available_width = max(1.0, plot_item.vb.width())
|
|
496
496
|
title_label.item.setTextWidth(available_width)
|
|
497
497
|
title = html.escape(record.title)
|
|
498
|
-
path = html.escape(
|
|
498
|
+
path = html.escape(record.path.as_posix()).replace("/", "/<wbr>")
|
|
499
|
+
axis_font = plot_item.getAxis("bottom").label.document().defaultFont()
|
|
499
500
|
plot_item.setTitle(
|
|
500
501
|
f"{title} — {path}",
|
|
501
502
|
color="k",
|
|
503
|
+
size=f"{axis_font.pointSizeF():g}pt",
|
|
502
504
|
)
|
|
503
505
|
title_height = title_label.item.boundingRect().height()
|
|
504
506
|
title_label.setMaximumHeight(title_height)
|
|
@@ -245,7 +245,7 @@ class LogBrowserWindow(QMainWindow):
|
|
|
245
245
|
|
|
246
246
|
def _create_top_bar(self) -> QHBoxLayout:
|
|
247
247
|
top_bar = QHBoxLayout()
|
|
248
|
-
self.directory_label = QLabel(
|
|
248
|
+
self.directory_label = QLabel(self._base_dir.as_posix())
|
|
249
249
|
self.directory_label.setTextInteractionFlags(Qt.TextSelectableByMouse)
|
|
250
250
|
self.directory_label.setContextMenuPolicy(Qt.CustomContextMenu)
|
|
251
251
|
self.directory_label.customContextMenuRequested.connect(
|
|
@@ -430,12 +430,12 @@ class LogBrowserWindow(QMainWindow):
|
|
|
430
430
|
path = Path(directory)
|
|
431
431
|
if path != self._base_dir:
|
|
432
432
|
self._base_dir = path
|
|
433
|
-
self.directory_label.setText(
|
|
433
|
+
self.directory_label.setText(self._base_dir.as_posix())
|
|
434
434
|
self._update_window_title()
|
|
435
435
|
self._sync_directory_watcher()
|
|
436
436
|
self.refresh_logs()
|
|
437
437
|
else:
|
|
438
|
-
self.directory_label.setText(
|
|
438
|
+
self.directory_label.setText(self._base_dir.as_posix())
|
|
439
439
|
self.settings_manager.update_recent_directories(path)
|
|
440
440
|
self._rebuild_directory_menu()
|
|
441
441
|
|
|
@@ -621,7 +621,7 @@ class _BrowserActions:
|
|
|
621
621
|
show_starred_action.setCheckable(True)
|
|
622
622
|
show_starred_action.setChecked(self.window._show_starred_only)
|
|
623
623
|
menu.addSeparator()
|
|
624
|
-
make_note_action = menu.addAction("Make Note...")
|
|
624
|
+
make_note_action = menu.addAction("Make 🏷️Note...")
|
|
625
625
|
rename_action = menu.addAction("Rename Title... (F2)")
|
|
626
626
|
change_id_action = menu.addAction("Change ID...")
|
|
627
627
|
toggle_star_action = menu.addAction("Toggle ⭐Star (S)")
|
|
@@ -144,7 +144,10 @@ class LogFolder:
|
|
|
144
144
|
dims={k: len(a) for k, a in run_axs.items()},
|
|
145
145
|
)
|
|
146
146
|
if len(self.meta.plot_axes) == 0:
|
|
147
|
-
|
|
147
|
+
if strip_underscores:
|
|
148
|
+
self.meta.plot_axes = [k.strip("_") for k in run_axs.keys()]
|
|
149
|
+
else:
|
|
150
|
+
self.meta.plot_axes = list(run_axs.keys())
|
|
148
151
|
|
|
149
152
|
step_table = list(itertools.product(*run_axs.values()))
|
|
150
153
|
|
|
@@ -34,10 +34,10 @@ def test_refresh_reuses_unchanged_records(
|
|
|
34
34
|
catalog = LogCatalog()
|
|
35
35
|
first_record = catalog.refresh(sample_logfolder)[0]
|
|
36
36
|
|
|
37
|
-
def
|
|
37
|
+
def fail_dataset(*args, **kwargs):
|
|
38
38
|
raise AssertionError("unchanged Feather should not be inspected")
|
|
39
39
|
|
|
40
|
-
monkeypatch.setattr(catalog_module.pyarrow.
|
|
40
|
+
monkeypatch.setattr(catalog_module.pyarrow.dataset, "dataset", fail_dataset)
|
|
41
41
|
|
|
42
42
|
second_record = catalog.refresh(sample_logfolder)[0]
|
|
43
43
|
|
|
@@ -153,14 +153,14 @@ def test_record_parses_ascii_integer_and_decimal_ids(
|
|
|
153
153
|
assert LogRecord(record_path).log_id == expected
|
|
154
154
|
|
|
155
155
|
|
|
156
|
-
def
|
|
156
|
+
def test_refresh_updates_changed_record_in_place(sample_logfolder: Path) -> None:
|
|
157
157
|
catalog = LogCatalog()
|
|
158
158
|
record = catalog.refresh(sample_logfolder)[0]
|
|
159
159
|
|
|
160
160
|
pd.DataFrame({"x": range(10), "y": range(10)}).to_feather(record.data_path)
|
|
161
161
|
refreshed = catalog.refresh(sample_logfolder)[0]
|
|
162
162
|
|
|
163
|
-
assert refreshed is
|
|
163
|
+
assert refreshed is record
|
|
164
164
|
assert refreshed.row_count == 10
|
|
165
165
|
assert refreshed.columns == ("x", "y")
|
|
166
166
|
|
|
@@ -170,12 +170,12 @@ def test_refresh_retries_data_inspection_after_failure(
|
|
|
170
170
|
monkeypatch: pytest.MonkeyPatch,
|
|
171
171
|
) -> None:
|
|
172
172
|
catalog = LogCatalog()
|
|
173
|
-
|
|
173
|
+
original_dataset = catalog_module.pyarrow.dataset.dataset
|
|
174
174
|
|
|
175
|
-
def
|
|
175
|
+
def fail_dataset(*args, **kwargs):
|
|
176
176
|
raise OSError("temporary read failure")
|
|
177
177
|
|
|
178
|
-
monkeypatch.setattr(catalog_module.pyarrow.
|
|
178
|
+
monkeypatch.setattr(catalog_module.pyarrow.dataset, "dataset", fail_dataset)
|
|
179
179
|
failed = catalog.refresh(sample_logfolder)[0]
|
|
180
180
|
|
|
181
181
|
assert failed.row_count == 0
|
|
@@ -183,13 +183,13 @@ def test_refresh_retries_data_inspection_after_failure(
|
|
|
183
183
|
assert failed.data_version is not None
|
|
184
184
|
|
|
185
185
|
monkeypatch.setattr(
|
|
186
|
-
catalog_module.pyarrow.
|
|
187
|
-
"
|
|
188
|
-
|
|
186
|
+
catalog_module.pyarrow.dataset,
|
|
187
|
+
"dataset",
|
|
188
|
+
original_dataset,
|
|
189
189
|
)
|
|
190
190
|
recovered = catalog.refresh(sample_logfolder)[0]
|
|
191
191
|
|
|
192
|
-
assert recovered is
|
|
192
|
+
assert recovered is failed
|
|
193
193
|
assert recovered.row_count == 3
|
|
194
194
|
assert recovered.columns == ("x", "y", "z")
|
|
195
195
|
|
|
@@ -232,6 +232,90 @@ def test_record_reads_dataframe_without_catalog_cache(
|
|
|
232
232
|
pd.testing.assert_frame_equal(first, second)
|
|
233
233
|
|
|
234
234
|
|
|
235
|
+
def test_record_df_caches_dataframe_snapshot(
|
|
236
|
+
sample_logfolder: Path,
|
|
237
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
238
|
+
) -> None:
|
|
239
|
+
record = LogRecord(sample_logfolder / "0")
|
|
240
|
+
original_read_feather = catalog_module.pd.read_feather
|
|
241
|
+
read_count = 0
|
|
242
|
+
|
|
243
|
+
def read_feather(*args, **kwargs):
|
|
244
|
+
nonlocal read_count
|
|
245
|
+
read_count += 1
|
|
246
|
+
return original_read_feather(*args, **kwargs)
|
|
247
|
+
|
|
248
|
+
monkeypatch.setattr(catalog_module.pd, "read_feather", read_feather)
|
|
249
|
+
|
|
250
|
+
first = record.df
|
|
251
|
+
second = record.df
|
|
252
|
+
|
|
253
|
+
assert first is not None
|
|
254
|
+
assert second is first
|
|
255
|
+
assert read_count == 1
|
|
256
|
+
assert record.row_count == len(first)
|
|
257
|
+
assert record.columns == tuple(first.columns)
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def test_record_df_cache_can_be_replaced_and_deleted(sample_logfolder: Path) -> None:
|
|
261
|
+
record = LogRecord(sample_logfolder / "0")
|
|
262
|
+
cached = record.df
|
|
263
|
+
assert cached is not None
|
|
264
|
+
|
|
265
|
+
replacement = record.read_dataframe()
|
|
266
|
+
assert replacement is not None
|
|
267
|
+
record.df = replacement
|
|
268
|
+
assert record.df is replacement
|
|
269
|
+
|
|
270
|
+
del record.df
|
|
271
|
+
reloaded = record.df
|
|
272
|
+
assert reloaded is not None
|
|
273
|
+
assert reloaded is not replacement
|
|
274
|
+
pd.testing.assert_frame_equal(reloaded, replacement)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
def test_record_refresh_invalidates_df_when_data_changes(
|
|
278
|
+
sample_logfolder: Path,
|
|
279
|
+
) -> None:
|
|
280
|
+
record = LogRecord(sample_logfolder / "0")
|
|
281
|
+
cached = record.df
|
|
282
|
+
assert cached is not None
|
|
283
|
+
|
|
284
|
+
expected = pd.DataFrame({"x": [10, 20], "signal": [1.0, 2.0]})
|
|
285
|
+
expected.to_feather(record.data_path)
|
|
286
|
+
|
|
287
|
+
assert record.refresh() is record
|
|
288
|
+
assert record.df is not cached
|
|
289
|
+
pd.testing.assert_frame_equal(record.df, expected)
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
def test_record_accessors_do_not_create_missing_files(tmp_path: Path) -> None:
|
|
293
|
+
record_path = tmp_path / "note"
|
|
294
|
+
record_path.mkdir()
|
|
295
|
+
record = LogRecord(record_path)
|
|
296
|
+
|
|
297
|
+
assert record.df is None
|
|
298
|
+
assert record.row_count == 0
|
|
299
|
+
assert record.columns == ()
|
|
300
|
+
with pytest.raises(FileNotFoundError, match="Metadata file"):
|
|
301
|
+
record.meta
|
|
302
|
+
with pytest.raises(FileNotFoundError, match="Registry file"):
|
|
303
|
+
record.const
|
|
304
|
+
assert not record.meta_path.exists()
|
|
305
|
+
assert not record.data_path.exists()
|
|
306
|
+
assert not record.const_path.exists()
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
def test_record_const_aliases_existing_registry(tmp_path: Path) -> None:
|
|
310
|
+
record_path = tmp_path / "record"
|
|
311
|
+
record_path.mkdir()
|
|
312
|
+
(record_path / "const.yaml").write_text("temperature: 20\n", encoding="utf-8")
|
|
313
|
+
record = LogRecord(record_path)
|
|
314
|
+
|
|
315
|
+
assert record.const is record.reg
|
|
316
|
+
assert record.const["temperature"] == 20
|
|
317
|
+
|
|
318
|
+
|
|
235
319
|
def test_record_reads_dataframe_from_memory_buffer(
|
|
236
320
|
sample_logfolder: Path,
|
|
237
321
|
monkeypatch: pytest.MonkeyPatch,
|
|
@@ -251,24 +335,62 @@ def test_record_reads_dataframe_from_memory_buffer(
|
|
|
251
335
|
assert isinstance(sources[0], catalog_module.pyarrow.BufferReader)
|
|
252
336
|
|
|
253
337
|
|
|
254
|
-
def
|
|
338
|
+
def test_catalog_inspects_data_with_dataset(
|
|
255
339
|
sample_logfolder: Path,
|
|
256
340
|
monkeypatch: pytest.MonkeyPatch,
|
|
257
341
|
) -> None:
|
|
258
|
-
|
|
259
|
-
|
|
342
|
+
original_dataset = catalog_module.pyarrow.dataset.dataset
|
|
343
|
+
calls = []
|
|
260
344
|
|
|
261
|
-
def
|
|
262
|
-
|
|
263
|
-
return
|
|
345
|
+
def dataset(source, *args, **kwargs):
|
|
346
|
+
calls.append((source, kwargs))
|
|
347
|
+
return original_dataset(source, *args, **kwargs)
|
|
264
348
|
|
|
265
|
-
monkeypatch.setattr(catalog_module.pyarrow.
|
|
349
|
+
monkeypatch.setattr(catalog_module.pyarrow.dataset, "dataset", dataset)
|
|
266
350
|
|
|
267
351
|
records = LogCatalog(sample_logfolder).refresh()
|
|
268
352
|
|
|
269
353
|
assert len(records) == 1
|
|
270
|
-
assert
|
|
271
|
-
|
|
354
|
+
assert calls == [(records[0].data_path, {"format": "feather"})]
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
def test_catalog_retries_when_data_changes_during_inspection(
|
|
358
|
+
sample_logfolder: Path,
|
|
359
|
+
monkeypatch: pytest.MonkeyPatch,
|
|
360
|
+
) -> None:
|
|
361
|
+
catalog = LogCatalog(sample_logfolder)
|
|
362
|
+
record = catalog.refresh()[0]
|
|
363
|
+
original_dataset = catalog_module.pyarrow.dataset.dataset
|
|
364
|
+
pd.DataFrame({"x": range(4)}).to_feather(record.data_path)
|
|
365
|
+
|
|
366
|
+
class ChangingDataset:
|
|
367
|
+
def __init__(self, source):
|
|
368
|
+
self._source = source
|
|
369
|
+
self.schema = source.schema
|
|
370
|
+
|
|
371
|
+
def count_rows(self):
|
|
372
|
+
row_count = self._source.count_rows()
|
|
373
|
+
pd.DataFrame({"x": range(5)}).to_feather(record.data_path)
|
|
374
|
+
return row_count
|
|
375
|
+
|
|
376
|
+
monkeypatch.setattr(
|
|
377
|
+
catalog_module.pyarrow.dataset,
|
|
378
|
+
"dataset",
|
|
379
|
+
lambda *args, **kwargs: ChangingDataset(
|
|
380
|
+
original_dataset(*args, **kwargs)
|
|
381
|
+
),
|
|
382
|
+
)
|
|
383
|
+
|
|
384
|
+
assert catalog.refresh()[0] is record
|
|
385
|
+
assert record.row_count == 3
|
|
386
|
+
|
|
387
|
+
monkeypatch.setattr(
|
|
388
|
+
catalog_module.pyarrow.dataset,
|
|
389
|
+
"dataset",
|
|
390
|
+
original_dataset,
|
|
391
|
+
)
|
|
392
|
+
assert catalog.refresh()[0] is record
|
|
393
|
+
assert record.row_count == 5
|
|
272
394
|
|
|
273
395
|
|
|
274
396
|
def test_record_reads_current_in_memory_metadata(
|
|
@@ -310,10 +432,10 @@ def test_metadata_refresh_resolves_plot_columns_without_inspecting_data(
|
|
|
310
432
|
plot_fields=["x"],
|
|
311
433
|
)
|
|
312
434
|
|
|
313
|
-
def
|
|
435
|
+
def fail_dataset(*args, **kwargs):
|
|
314
436
|
raise AssertionError("metadata-only refresh should not inspect Feather")
|
|
315
437
|
|
|
316
|
-
monkeypatch.setattr(catalog_module.pyarrow.
|
|
438
|
+
monkeypatch.setattr(catalog_module.pyarrow.dataset, "dataset", fail_dataset)
|
|
317
439
|
|
|
318
440
|
refreshed = catalog.refresh()[0]
|
|
319
441
|
|
|
@@ -5,6 +5,11 @@ from pathlib import Path
|
|
|
5
5
|
import pandas as pd
|
|
6
6
|
|
|
7
7
|
from logqbit.catalog import LogCatalog, LogRecord, export_records
|
|
8
|
+
from logqbit.gui.browser.detail.files import (
|
|
9
|
+
list_image_files,
|
|
10
|
+
list_other_files,
|
|
11
|
+
read_yaml_text,
|
|
12
|
+
)
|
|
8
13
|
from logqbit.gui.browser.detail.view import record_watch_paths
|
|
9
14
|
from logqbit.logfolder import LogFolder
|
|
10
15
|
|
|
@@ -58,7 +63,7 @@ class TestLogRecord:
|
|
|
58
63
|
records = scan_catalog(sample_logfolder)
|
|
59
64
|
record = records[0]
|
|
60
65
|
|
|
61
|
-
yaml_text = record.
|
|
66
|
+
yaml_text = read_yaml_text(record.const_path)
|
|
62
67
|
|
|
63
68
|
assert isinstance(yaml_text, str)
|
|
64
69
|
assert len(yaml_text) > 0
|
|
@@ -71,7 +76,7 @@ class TestLogRecord:
|
|
|
71
76
|
records = scan_catalog(tmp_path)
|
|
72
77
|
record = records[0]
|
|
73
78
|
|
|
74
|
-
yaml_text = record.
|
|
79
|
+
yaml_text = read_yaml_text(record.const_path)
|
|
75
80
|
assert "const.yaml not found" in yaml_text
|
|
76
81
|
|
|
77
82
|
def test_list_image_files(self, tmp_path: Path) -> None:
|
|
@@ -86,7 +91,7 @@ class TestLogRecord:
|
|
|
86
91
|
records = scan_catalog(tmp_path)
|
|
87
92
|
record = records[0]
|
|
88
93
|
|
|
89
|
-
images = record.
|
|
94
|
+
images = list_image_files(record.path)
|
|
90
95
|
|
|
91
96
|
assert len(images) == 2
|
|
92
97
|
assert all(img.suffix.lower() in {".png", ".jpg"} for img in images)
|
|
@@ -103,7 +108,7 @@ class TestLogRecord:
|
|
|
103
108
|
extra_binary.write_bytes(b"123")
|
|
104
109
|
ignored_image.touch()
|
|
105
110
|
|
|
106
|
-
other_files = record.
|
|
111
|
+
other_files = list_other_files(record.path)
|
|
107
112
|
|
|
108
113
|
assert [path.name for path in other_files] == ["notes.txt", "snapshot.bin"]
|
|
109
114
|
|
|
@@ -250,7 +250,7 @@ class TestRecordDetailWidgets:
|
|
|
250
250
|
assert not (
|
|
251
251
|
view.detail_id_label.textInteractionFlags() & Qt.TextSelectableByMouse
|
|
252
252
|
)
|
|
253
|
-
assert view.detail_label.text() ==
|
|
253
|
+
assert view.detail_label.text() == record.path.as_posix()
|
|
254
254
|
assert view.detail_label.textInteractionFlags() & Qt.TextSelectableByMouse
|
|
255
255
|
assert view.detail_label.contextMenuPolicy() == Qt.NoContextMenu
|
|
256
256
|
assert view.detail_label.wordWrap()
|
|
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
|
|
5
|
+
import pandas as pd
|
|
5
6
|
from PySide6.QtCore import Qt
|
|
6
7
|
|
|
7
8
|
from logqbit.catalog import LogCatalog, LogRecord
|
|
@@ -85,7 +86,9 @@ class TestLogListTableModel:
|
|
|
85
86
|
|
|
86
87
|
def test_data_display_rows(self, sample_records: list[LogRecord]) -> None:
|
|
87
88
|
"""Test displaying row count."""
|
|
88
|
-
record =
|
|
89
|
+
record = sample_records[0]
|
|
90
|
+
pd.DataFrame({"x": range(1_234)}).to_feather(record.data_path)
|
|
91
|
+
record.refresh()
|
|
89
92
|
model = LogListTableModel()
|
|
90
93
|
model.set_records([record])
|
|
91
94
|
|
|
@@ -466,6 +466,7 @@ class TestPlotManagerFitAndColorBar:
|
|
|
466
466
|
observed["copy"] = copy
|
|
467
467
|
observed["title"] = self.plot_item.titleLabel.text
|
|
468
468
|
observed["visible"] = self.plot_item.titleLabel.isVisible()
|
|
469
|
+
observed["size"] = self.plot_item.titleLabel.opts["size"]
|
|
469
470
|
observed["width"] = self._parameters["width"]
|
|
470
471
|
|
|
471
472
|
monkeypatch.setattr(
|
|
@@ -476,8 +477,11 @@ class TestPlotManagerFitAndColorBar:
|
|
|
476
477
|
|
|
477
478
|
assert observed == {
|
|
478
479
|
"copy": True,
|
|
479
|
-
"title": f"Example title — {
|
|
480
|
+
"title": f"Example title — {record_path.as_posix().replace('/', '/<wbr>')}",
|
|
480
481
|
"visible": True,
|
|
482
|
+
"size": (
|
|
483
|
+
f"{plot_item.getAxis('bottom').label.document().defaultFont().pointSizeF():g}pt"
|
|
484
|
+
),
|
|
481
485
|
"width": 800,
|
|
482
486
|
}
|
|
483
487
|
assert not plot_item.titleLabel.isVisible()
|
|
@@ -523,7 +527,7 @@ class TestPlotManagerFitAndColorBar:
|
|
|
523
527
|
|
|
524
528
|
assert observed == {
|
|
525
529
|
"to_bytes": True,
|
|
526
|
-
"title": f"Example title — {
|
|
530
|
+
"title": f"Example title — {tmp_path.as_posix().replace('/', '/<wbr>')}",
|
|
527
531
|
"width": 800,
|
|
528
532
|
"path": str(tmp_path / "plot.png"),
|
|
529
533
|
"format": "PNG",
|
|
@@ -264,12 +264,12 @@ class TestBrowserWindow:
|
|
|
264
264
|
lambda records, target=None: shown.append((records, target)),
|
|
265
265
|
)
|
|
266
266
|
try:
|
|
267
|
-
aggregate =
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
)
|
|
267
|
+
aggregate = sample_records[0]
|
|
268
|
+
dataframe = aggregate.read_dataframe()
|
|
269
|
+
assert dataframe is not None
|
|
270
|
+
dataframe[LOGFOLDER_SID_COLUMN] = "aggregate"
|
|
271
|
+
dataframe.to_feather(aggregate.data_path)
|
|
272
|
+
aggregate.refresh()
|
|
273
273
|
window._actions.append_into_existing_record([sample_records[1], aggregate])
|
|
274
274
|
|
|
275
275
|
assert len(shown) == 1
|
|
@@ -569,13 +569,13 @@ class TestBrowserWindow:
|
|
|
569
569
|
|
|
570
570
|
inspect_count = 0
|
|
571
571
|
read_count = 0
|
|
572
|
-
|
|
572
|
+
original_dataset = catalog_module.pyarrow.dataset.dataset
|
|
573
573
|
original_read_feather = catalog_module.pd.read_feather
|
|
574
574
|
|
|
575
|
-
def
|
|
575
|
+
def count_dataset(*args, **kwargs):
|
|
576
576
|
nonlocal inspect_count
|
|
577
577
|
inspect_count += 1
|
|
578
|
-
return
|
|
578
|
+
return original_dataset(*args, **kwargs)
|
|
579
579
|
|
|
580
580
|
def count_read_feather(*args, **kwargs):
|
|
581
581
|
nonlocal read_count
|
|
@@ -583,7 +583,7 @@ class TestBrowserWindow:
|
|
|
583
583
|
return original_read_feather(*args, **kwargs)
|
|
584
584
|
|
|
585
585
|
monkeypatch.setattr(
|
|
586
|
-
catalog_module.pyarrow.
|
|
586
|
+
catalog_module.pyarrow.dataset, "dataset", count_dataset
|
|
587
587
|
)
|
|
588
588
|
monkeypatch.setattr(catalog_module.pd, "read_feather", count_read_feather)
|
|
589
589
|
|
|
@@ -591,8 +591,9 @@ class TestBrowserWindow:
|
|
|
591
591
|
|
|
592
592
|
assert inspect_count == 1
|
|
593
593
|
assert read_count == 1
|
|
594
|
-
assert record.row_count ==
|
|
594
|
+
assert record.row_count == 10
|
|
595
595
|
assert window._selected_record is not None
|
|
596
|
+
assert window._selected_record is record
|
|
596
597
|
assert window._selected_record.row_count == 10
|
|
597
598
|
finally:
|
|
598
599
|
window.close()
|
|
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
|