Skip to content

Commit d2f9fb2

Browse files
committed
Clarify design decision for 'name' as both catalog key and display label in AGENTS.md; update TimeSeriesDataUIManager to ensure 'name' column visibility in column width map.
1 parent df888f1 commit d2f9fb2

2 files changed

Lines changed: 28 additions & 31 deletions

File tree

AGENTS.md

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -94,39 +94,37 @@ catalog.rename("JER__tf", "JER_tidal_filtered") # chainable, raises KeyError /
9494

9595
`rename()` does **not** affect `_source_index` — the source (file path) is unchanged.
9696

97-
### `name` vs display label in mixed catalogs
97+
### Design decision: `name` is both the catalog key and the user-visible display
9898

99-
`name` serves two roles that can conflict:
99+
**`name` is the single source of truth** — it is the catalog lookup key, the
100+
expression token, and the display identity shown in the UI table. Do not add a
101+
separate `label` column as an alias for `name`.
100102

101-
| Role | Raw DSS example | Transform ref example |
102-
|------|-----------------|----------------------|
103-
| Catalog lookup key | `"study.dss::/A/JER/EC//15MIN/F/"` | `"JER__tf"` |
104-
| User-visible display | *ugly — should be hidden* | *clean — should be shown* |
103+
Rationale:
105104

106-
**General rule** (handled automatically by `get_table_column_width_map()`):
105+
- A `label` column that mirrors `name` for derived refs and is blank for raw refs
106+
adds complexity (two concepts for one value) with no functional gain.
107+
- Users can rename any ref — raw or math — via `catalog.rename(old, new)`, which
108+
atomically updates both the dict key and `ref.name`. After renaming, the new
109+
name works immediately in expressions and in the table.
110+
- Persistence of custom names can be solved independently (e.g. by including a
111+
`name` column in a downloaded catalog CSV; on reload, if a `name` column is
112+
present it overrides the auto-derived name instead of re-deriving it).
107113

108-
When math refs are present the table automatically gains a `name` column so users
109-
can see what their transform refs are called. For managers whose raw-ref names
110-
are human-readable (e.g. `"RSAC075_flow"`) this is sufficient.
114+
**What managers with ugly auto-derived names should do instead:**
111115

112-
**For managers with ugly raw-ref names** (e.g. `DSSDataUIManager` where the raw-ref
113-
key is `"filename::pathname"`), override `get_data_catalog()` to inject a `label`
114-
column:
116+
Give raw refs clean auto-names when building the catalog. For `DSSDataUIManager`
117+
the raw-ref key is currently `"filename::pathname"` — the right fix is to
118+
auto-derive names from the DSS path parts (B/C/F) so they are already
119+
human-readable, not to paper over ugly names with a `label` column.
115120

116-
```python
117-
def get_data_catalog(self):
118-
df = self._dvue_catalog.to_dataframe().reset_index()
119-
# blank for raw refs (identified by domain columns); catalog key for derived refs
120-
df["label"] = df.apply(
121-
lambda r: r["name"] if r.get("ref_type", "raw") != "raw" else "",
122-
axis=1,
123-
)
124-
return df
125-
```
121+
**Framework behaviour (handled automatically by `get_table_column_width_map()`):**
126122

127-
Add `"label"` to `_get_table_column_width_map()` so it appears first in the table.
128-
When a `label` column is present the framework suppresses the generic `name`
129-
injection, so the two columns never double-up.
123+
When math refs are present the table automatically gains a `name` column so users
124+
can see what their transform/math refs are called. The `name` column is only
125+
injected when not already declared in the subclass column map, so subclasses that
126+
explicitly include `"name"` in `_get_table_column_width_map()` retain full
127+
control over placement and width.
130128

131129
### `get_data_reference` — always use `row["name"]`
132130

dvue/tsdataui.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,10 @@ def get_table_column_width_map(self):
616616
if cat is not None and self._has_math_refs():
617617
df = cat.to_dataframe()
618618
# Show the catalog key ('name') as a visible column so users can
619-
# see what their transform/math refs are called. Skip it when the
620-
# subclass already provides a 'label' column as a cleaner display
621-
# substitute (e.g. DSSDataUIManager injects label="" for raw refs
622-
# and label=name for derived refs so the ugly raw DSS path is hidden).
623-
if "name" not in column_width_map and "label" not in column_width_map:
619+
# see what their transform/math refs are called. Subclasses that
620+
# explicitly include 'name' in _get_table_column_width_map() retain
621+
# full control over placement and width.
622+
if "name" not in column_width_map:
624623
column_width_map["name"] = "15%"
625624
for col in df.columns:
626625
if col not in column_width_map and col not in ("geometry", "source"):

0 commit comments

Comments
 (0)