Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/nullius/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -1676,6 +1676,21 @@ def run_folder(name: str, root: Optional[str] = None) -> str:
return path


def run_of(path: str, root: Optional[str] = None) -> Optional[str]:
"""The name of the run Nullius made whose folder, or its ``jobs`` folder,
*path* is once its links are resolved; None for any other path: the one
folder a workspace root may be deleted as is a run's own, in the runs root."""
real, runs = os.path.realpath(path), os.path.realpath(root or runs_root())
name, _, rest = os.path.relpath(real, runs).partition(os.sep)
if name in (os.curdir, os.pardir) or rest not in ("", "jobs"):
return None
try:
run_folder(name, runs)
except ValueError:
return None
return name


def size_of(path: str) -> int:
"""The bytes of every file under *path*, links not followed; a file gone
since the walk listed it (a run still writing replaces its own) counts 0."""
Expand Down
6 changes: 6 additions & 0 deletions app/nullius/judge/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ def job_dirs(ws_dir: str, job_ids) -> list:
return [d for lane in ROOTS for j in job_ids if os.path.isdir(d := os.path.join(_root(ws_dir, lane), _SAFE.sub("_", j)))]


def count(ws_dir: str) -> int:
"""The stored judgements of a workspace, every lane: one per trial and
lane, its versions inside. What deleting the workspace loses for good."""
return sum(n.endswith(".json") for lane in ROOTS for _, _, names in os.walk(_root(ws_dir, lane)) for n in names)


def all_records(ws_dir: str, job_id: Optional[str] = None, lane: str = "system-one"):
"""Every stored record, every version: yields (job_id, trial_name,
version, record). One job's when `job_id` is given."""
Expand Down
3 changes: 0 additions & 3 deletions app/static/runs/launches.css
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,10 @@ dialog.std-how.launch-delete { width: min(520px, calc(100vw - 32px)); }
.grid.sortable.inventory thead th:not([data-type])::after { content: none; }
.inventory td.inv-acts { position: relative; white-space: nowrap; } /* holds its hidden reason, inside the table's scroll */ /* Add, then Delete, side by side on every row */
.inventory .launch-add-btn:focus-visible { color: var(--text); }
.inventory .launch-delete-btn:hover, .inventory .launch-delete-btn:focus-visible { color: var(--bad); }
.inventory .icon-btn[aria-disabled="true"] { opacity: .4; background: none; border-color: transparent; cursor: default; } /* Delete it cannot: the slot kept, greyed, its reason reachable */
/* State and Launch stay put while the table scrolls sideways; State's header is its name for a screen reader only */
.inventory { --inv-state-w: 2.2rem; }
.inventory [data-col="state"] { width: var(--inv-state-w); min-width: var(--inv-state-w); padding-left: 0; padding-right: 0; text-align: center; }
.inventory [data-col="launch"] { --sticky-left: var(--inv-state-w); }
.inventory .sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* a run's state: its icon, coloured as the Runs page's state dots */
.inventory td[data-col="state"] .ic { vertical-align: middle; }
.inventory .st-finished, .inventory .st-running, .inventory .st-preparing { color: var(--resolved); }
Expand Down
25 changes: 3 additions & 22 deletions app/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1417,13 +1417,13 @@ a.chip { text-decoration: none; }
}
.rail-toggle:hover, .icon-btn:hover { color: var(--text); background: var(--surface); border-color: var(--border); }
.rail-toggle:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: none; }
.icon-btn.danger:not([aria-disabled="true"]):is(:hover, :focus-visible) { color: var(--bad); } /* it deletes */
.icon-btn[aria-disabled="true"] { opacity: .4; background: none; border-color: transparent; cursor: default; } /* it cannot here: the slot kept, greyed, its reason reachable */
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; } /* a name for a screen reader only */
.ic-expand { display: none; }
:root[data-rail="collapsed"] .ic-expand { display: block; }
:root[data-rail="collapsed"] .ic-collapse { display: none; }

.ws-delete { width: 34px; text-align: right; }
.ws-remove { border: 1px solid var(--border); background: var(--surface); color: var(--text-dim); border-radius: 6px; width: 28px; height: 28px; font-size: 16px; line-height: 1; cursor: pointer; }
.ws-remove:hover { color: var(--bad); border-color: var(--bad); }
.ws-switch { position: relative; }
.ws-btn {
width: 100%; display: flex; align-items: center; gap: .6rem; text-align: left;
Expand Down Expand Up @@ -1538,12 +1538,6 @@ a.chip { text-decoration: none; }
}

/* ---- workspaces ---- */
.ws-current td { background: var(--accent-soft); }
.ws-mark { width: 1.2rem; }
.ws-rename { display: flex; gap: .5rem; align-items: center; }
.ws-rename input[type=text] { width: 16rem; font-size: .9rem; padding: .3rem .5rem; }
.ws-roots { max-width: 40ch; overflow: hidden; text-overflow: ellipsis; }
.ws-roots .mono { font-size: .78rem; }

.nav-tree { display: flex; flex-direction: column; }
.nav-row { display: flex; align-items: center; gap: 2px; }
Expand All @@ -1557,7 +1551,6 @@ a.chip { text-decoration: none; }
.tree-caret .ic { width: 15px; height: 15px; transition: transform .12s; }
.nav-tree.folded .tree-caret .ic { transform: rotate(-90deg); }
.tree-kids { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 .2rem .9rem; padding-left: .55rem; border-left: 1px solid var(--border-soft); }
.tree-form { margin: 0; display: flex; }
.tree-item {
position: relative; display: flex; align-items: center; gap: .5rem; width: 100%; min-height: 30px; padding: 0 .5rem;
border-radius: 7px; color: var(--text-dim); font-size: .85rem; text-align: left; white-space: nowrap;
Expand All @@ -1567,18 +1560,6 @@ a.chip { text-decoration: none; }
.tree-item:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.tree-item.on { background: var(--accent-soft); color: var(--text); font-weight: 500; }
.tree-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; box-shadow: none; }
.tree-item.cur { color: var(--text); font-weight: 500; }
.tree-check { width: 14px; height: 14px; color: var(--ok); flex: none; }
.tree-item.add { color: var(--text-faint); }
.tree-item.add:hover { color: var(--text); }
.tree-runs { display: flex; flex-direction: column; gap: 1px; margin: 0 0 .15rem .5rem; }
.run-item { min-height: 26px; font-size: .78rem; color: var(--text-faint); padding-left: .2rem; }
.run-item .lbl.mono { font-size: .74rem; }
.run-item .tree-guide { flex: none; width: 10px; height: 1px; background: var(--border); margin-right: -.1rem; }
.run-item.on { color: var(--text); }
.run-item.on .tree-guide { background: var(--accent); }
.tree-n { flex: none; font-size: .68rem; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.run-item.faint { cursor: default; font-style: italic; }
:root[data-rail="collapsed"] .tree-caret, :root[data-rail="collapsed"] .tree-kids { display: none; }
@media (max-width: 900px) { :root[data-rail="collapsed"] .tree-caret, :root[data-rail="collapsed"] .tree-kids { display: flex; } }

Expand Down
24 changes: 15 additions & 9 deletions app/static/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,22 @@ window.NulliusTable = {
macro's, each opened by its caret, or the tools macro's. `allowed`:
column -> the Set of values ticked, or null when all are. A row passes
when, for each column, one of its values (data-f-<col>, one per line) is
ticked. `changed` runs after each change. */
ticked; a box unticked at load filters from the start. `changed` runs
after each change. */
filters(scope, changed) {
const allowed = {};
scope.querySelectorAll('[data-filter-menu]').forEach(menu => {
const col = menu.dataset.filterMenu;
const boxes = () => [...menu.querySelectorAll('input[data-value]')];
const btn = scope.querySelector(`.filter-btn[data-filter="${col}"]`);
const sync = () => {
const read = () => {
const on = boxes().filter(b => b.checked).map(b => b.dataset.value);
// All checked means "no filter": keeps the active marker honest.
allowed[col] = on.length === boxes().length ? null : new Set(on);
btn?.classList.toggle('on', Boolean(allowed[col]));
changed();
};
const sync = () => { read(); changed(); };
read();
menu.addEventListener('change', sync);
menu.addEventListener('click', e => {
if (e.target.closest('[data-all]')) { boxes().forEach(b => b.checked = true); sync(); }
Expand Down Expand Up @@ -153,19 +155,24 @@ window.NulliusTable = {
/* A table's Filter and Sort by menus (the tools macro), under `tools`, in
place of header carets. Filter counts the columns it narrows; Sort by
sets the sort, and follows a header click. `changed` runs after either.
A toolbar without Filter (the macro given no filters) only sorts.
Returns {passes, resort}, as filters and sortable do. */
toolbar(table, tools, changed) {
const [fbtn, fmenu, sbtn, smenu] = ['filter', 'sort'].flatMap(k =>
[tools.querySelector(`[data-tools-btn="${k}"]`), tools.querySelector(`[data-tools="${k}"]`)]);
const count = fbtn.querySelector('.tools-count');
const narrowed = () => {
const count = fbtn?.querySelector('.tools-count');
const mark = () => {
const n = Object.values(f.allowed).filter(Boolean).length;
count.textContent = n || '';
count.hidden = !n;
changed();
};
const f = this.filters(fmenu, narrowed);
fmenu.querySelector('[data-clear]').addEventListener('click', () => { f.clear(); narrowed(); });
const narrowed = () => { mark(); changed(); };
const f = fmenu ? this.filters(fmenu, narrowed) : {allowed: {}, passes: () => true};
if (fmenu) {
mark();
fmenu.querySelector('[data-clear]').addEventListener('click', () => { f.clear(); narrowed(); });
this.menu(fbtn, fmenu);
}
const heads = [...table.tHead.rows[0].cells];
const sync = () => {
const {col, dir} = resort.state(), on = col === null ? '' : heads[col].dataset.col;
Expand All @@ -180,7 +187,6 @@ window.NulliusTable = {
resort.set(idx, dir);
});
sync();
this.menu(fbtn, fmenu);
this.menu(sbtn, smenu);
return {passes: f.passes, resort};
},
Expand Down
19 changes: 19 additions & 0 deletions app/static/workspaces/workspaces.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* The Workspaces page: one row per workspace; its roots in a dialog (the Launches page's, runs/launches.css). */
.ws-head { justify-content: space-between; align-items: center; }
.ws-current td { background: var(--accent-soft); }
.ws-mark { width: 1.2rem; }
.ws-table th { position: relative; } /* holds a header named for a screen reader only, inside the scrolling box */
.ws-name { min-width: 12rem; }
.ws-show { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px .4rem; }
.ws-title { overflow-wrap: anywhere; } /* a name wraps, never cut */
.ws-rename { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.ws-rename input[type=text] { width: min(16rem, 100%); font-size: .9rem; padding: .3rem .5rem; }
.ws-roots-btn { font-variant-numeric: tabular-nums; }
.launch-delete .ws-root-list { list-style: none; padding: 0; margin: 12px 0 0; }
.ws-root-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border-soft); }
.ws-root-list li > .mono { flex: 1; min-width: 0; font-size: 13px; overflow-wrap: anywhere; } /* a path wraps, never cut */
.ws-root-acts { position: relative; display: inline-flex; flex: none; gap: 2px; } /* holds a hidden reason */
.launch-delete p.mono, .launch-delete p .mono { overflow-wrap: anywhere; }
dialog.std-how.launch-delete.wide { width: min(56rem, calc(100vw - 32px)); } /* the roots: room for a path */
.launch-delete .std-how-head h2 { min-width: 0; overflow-wrap: anywhere; }
.grid.tools.ws-table td { vertical-align: middle; } /* a count beside a button: one line */
14 changes: 10 additions & 4 deletions app/templates/_tables.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,23 @@
{% endmacro %}

{# A table's Filter and Sort by menus, in place of header carets (static/tables.js `toolbar`). `filters`: a list of
(col, label, choices), choices as filter_button's; `sorts`: a list of (col, label), the sortable headers. #}
{% macro tools(filters, sorts) %}
<div class="menu-wrap">
(col, label, choices), choices as filter_button's; `sorts`: a list of (col, label), the sortable headers;
`only`: column -> the one value ticked at load, the others unticked. No filters: no Filter button. #}
{% macro tools(filters, sorts, only={}) %}
{% if filters %}<div class="menu-wrap">
<button class="btn ghost sm" type="button" data-tools-btn="filter" aria-haspopup="true" aria-expanded="false"><svg class="ic" aria-hidden="true"><use href="#i-filter"/></svg>Filter<span class="tools-count" hidden></span></button>
<div class="menu tools-menu" data-tools="filter" hidden>
<button type="button" class="linkish tools-clear" data-clear>Clear filters</button>
{% for col, label, choices in filters %}
<fieldset data-filter-menu="{{ col }}">
<legend>{{ label }}</legend>
<span class="tools-all"><button type="button" class="linkish" data-all="{{ col }}">All</button><button type="button" class="linkish" data-none="{{ col }}">None</button></span>
{% for value, text in choices %}<label><input type="checkbox" data-value="{{ value }}" checked> {{ text }}</label>{% endfor %}
{% for value, text in choices %}<label><input type="checkbox" data-value="{{ value }}"{% if col not in only or only[col] == value %} checked{% endif %}> {{ text }}</label>{% endfor %}
</fieldset>
{% endfor %}
</div>
</div>
{% endif %}
<div class="menu-wrap">
<button class="btn ghost sm" type="button" data-tools-btn="sort" aria-haspopup="true" aria-expanded="false"><svg class="ic" aria-hidden="true"><use href="#i-sort"/></svg>Sort by</button>
<div class="menu tools-menu" data-tools="sort" hidden>
Expand Down Expand Up @@ -60,3 +62,7 @@
<button type="button" class="btn sm ghost" data-next aria-label="Next page">›</button>
</div>
{% endmacro %}

{#- An icon button that cannot act here: greyed, still focusable, `why` its description and, after `action`, its tooltip;
`id` names the description. The cell or line that holds it is positioned, so the hidden reason stays in it. #}
{% macro greyed(label, action, why, id, icon='trash') %}<button type="button" class="icon-btn danger" aria-disabled="true" aria-label="{{ label }}" aria-describedby="{{ id }}" title="{{ action }}: {{ why }}"><svg class="ic"><use href="#i-{{ icon }}"/></svg></button><span class="sr" id="{{ id }}">{{ why }}</span>{% endmacro %}
45 changes: 4 additions & 41 deletions app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
<symbol id="i-sort" viewBox="0 0 24 24"><path d="M8 19V5M4.5 8.5 8 5l3.5 3.5M16 5v14M12.5 15.5 16 19l3.5-3.5"/></symbol>
<symbol id="i-sliders" viewBox="0 0 24 24"><path d="M4 7h10M18 7h2M4 17h4M12 17h8"/><circle cx="16" cy="7" r="2"/><circle cx="10" cy="17" r="2"/></symbol>
<symbol id="i-alert" viewBox="0 0 24 24"><path d="M12 4 2.5 20h19zM12 10v4.5M12 17.5h.01"/></symbol>
<symbol id="i-pencil" viewBox="0 0 24 24"><path d="M4 20h4L19 9a2.83 2.83 0 0 0-4-4L4 16zM13.5 6.5l4 4"/></symbol>
<symbol id="i-folder" viewBox="0 0 24 24"><path d="M3 7a2 2 0 0 1 2-2h4l2 2.5h8a2 2 0 0 1 2 2V17a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></symbol>
<symbol id="i-unlink" viewBox="0 0 24 24"><path d="M18.8 12.3l1.7-1.7a5 5 0 0 0-7.1-7.1l-1.7 1.7M5.2 11.7l-1.7 1.7a5 5 0 0 0 7.1 7.1l1.7-1.7M8 2v3M2 8h3M16 22v-3M22 16h-3"/></symbol>
<symbol id="i-trash" viewBox="0 0 24 24"><path d="M4 7h16M9 7V4h6v3M6 7l1 13h10l1-13M10 11v6M14 11v6"/></symbol>
<symbol id="i-sun" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4.5"/><path d="M12 2v2.5M12 19.5V22M2 12h2.5M19.5 12H22M4.9 4.9l1.8 1.8M17.3 17.3l1.8 1.8M4.9 19.1l1.8-1.8M17.3 6.7l1.8-1.8"/></symbol>
<symbol id="i-moon" viewBox="0 0 24 24"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/></symbol>
Expand Down Expand Up @@ -205,47 +208,7 @@
</div>
<div class="nav-group">
<div class="nav-label">Manage</div>
{# A tree: every workspace as a folder, the open one expanded to its
runs. Clicking a closed one switches; the caret folds the tree and
the fold is remembered. #}
<div class="nav-tree folded" data-tree="nav-ws">
<div class="nav-row">
<a class="nav-item {{ 'on' if ep.startswith('workspace') }}" href="{{ url_for('workspaces_page') }}" data-label="Workspaces" aria-label="Workspaces"><svg class="ic"><use href="#i-ws"/></svg><span class="lbl">Workspaces</span></a>
<button class="tree-caret" type="button" aria-expanded="false"
aria-label="Fold the workspace list"><svg class="ic"><use href="#i-chev"/></svg></button>
</div>
<div class="tree-kids" hidden>
{% for ws in workspaces %}
{% set cur = workspace and ws.name == workspace.name %}
{% if cur %}
<a class="tree-item ws-item cur {{ 'on' if ep in ('index',) }}" href="{{ url_for('index') }}">
<span class="ws-avatar sm" style="--hue:{{ ws_hue(ws.name) }}">{{ ws.label[:2]|upper }}</span>
<span class="lbl">{{ ws.label }}</span><svg class="ic tree-check"><use href="#i-check"/></svg>
</a>
<div class="tree-runs">
{% for r in nav_runs %}
<a class="tree-item run-item {{ 'on' if (ep in ('job', 'trial', 'save_trace') and request.view_args.get('job_id') == r.job_id) }}"
href="{{ url_for('job', job_id=r.job_id) }}">
<span class="tree-guide"></span><span class="lbl mono">{{ r.job_id }}</span><span class="tree-n">{{ r.n_trials }}</span>
</a>
{% else %}
<span class="tree-item run-item faint"><span class="tree-guide"></span><span class="lbl">no runs read yet</span></span>
{% endfor %}
</div>
{% else %}
<form method="post" action="{{ url_for('workspace_open', name=ws.name) }}" class="tree-form"><input type="hidden" name="csrf" value="{{ csrf_token() }}">
<button class="tree-item ws-item" type="submit">
<span class="ws-avatar sm" style="--hue:{{ ws_hue(ws.name) }}">{{ ws.label[:2]|upper }}</span>
<span class="lbl">{{ ws.label }}</span>
</button>
</form>
{% endif %}
{% endfor %}
<a class="tree-item ws-item add" href="{{ url_for('import_page', new=1) }}">
<span class="ws-avatar sm ws-avatar-empty"><svg class="ic"><use href="#i-plus"/></svg></span><span class="lbl">New workspace</span>
</a>
</div>
</div>
<a class="nav-item {{ 'on' if ep.startswith('workspace') }}" href="{{ url_for('workspaces_page') }}" data-label="Workspaces" aria-label="Workspaces"><svg class="ic"><use href="#i-ws"/></svg><span class="lbl">Workspaces</span></a>
<a class="nav-item {{ 'on' if ep == 'launches_page' }}" href="{{ url_for('launches_page') }}" data-label="Launches" aria-label="Launches"><svg class="ic"><use href="#i-launches"/></svg><span class="lbl">Launches</span></a>
<a class="nav-item {{ 'on' if ep.startswith('settings') }}" href="{{ url_for('settings_page') }}" data-label="Settings" aria-label="Settings"><svg class="ic"><use href="#i-gear"/></svg><span class="lbl">Settings</span></a>
</div>
Expand Down
Loading
Loading