diff --git a/app/static/catalogue/catalogue.css b/app/static/catalogue/catalogue.css index 75459c86..fb7a61b7 100644 --- a/app/static/catalogue/catalogue.css +++ b/app/static/catalogue/catalogue.css @@ -41,6 +41,8 @@ .bench-card-name { min-width: 0; } .bench-card-name > .icon-btn { vertical-align: middle; } .bench-mark { flex: none; width: 22px; height: 22px; color: var(--accent); } +/* a table row's name (_cards.html rows): its icon, then its link */ +.row-name { display: inline-flex; align-items: center; gap: 8px; } .bench-card-domain { margin-top: -6px; font-size: 14px; line-height: 1.5; color: var(--text-dim); } /* the stats in columns of one width, a column each, each its label then its value; on a card too narrow for one line (a phone), two balanced rows: 4 as 2+2, 5 as 3+2, 6 as 3+3 */ diff --git a/app/templates/_cards.html b/app/templates/_cards.html index ec616128..3114aede 100644 --- a/app/templates/_cards.html +++ b/app/templates/_cards.html @@ -14,7 +14,7 @@ A field's `class` goes on each of its values; `card_label` names a stat when its column header does not, and a value's `label` names it for that item; `style` 'code' sets the text as code; `icon` puts #i- before a note. `icon` values are image URLs: when one item has one, the others show initials; when none has, no icon. -#} -{% from '_tables.html' import controls, empty_note %} +{% from '_tables.html' import controls, empty_note, table, cell %} {#- Each value of `fields` in `item`, as a dict, to the call block with its field. #} {% macro each(item, fields) %}{% for f in fields %}{% set v = item.get(f.key) %} @@ -25,14 +25,44 @@ {# A collection of cards (NulliusTable.cards): its controls row, its cards, the note when none passes. `id` names it; `search`, `choices`, `only`, `layout` and each field's `filter` as the table's controls; `sort` the Sort by menu, over - the fields that are not blank; `noun` what the live region counts. + the fields that are not blank, or a list of their keys; `noun` what the live region counts. The call block, when given, writes the cards instead (grid for each group, such as the Benchmarks' shelves); a - section in it marked data-group hides when none of its cards shows, and its data-group-n counts them. #} -{% macro cards(id, cols, items, search='', choices={}, only={}, empty='No items match.', noun='items', sort=false, layout=none) %} -{{ controls(id, cols, search, choices=choices, only=only, sort=sort, layout=layout) }} + section in it marked data-group hides when none of its cards shows, and its data-group-n counts them. + `layout` 'table' shows the same items as a table instead (rows), `default` the page's view without ?view=. #} +{% macro cards(id, cols, items, search='', choices={}, only={}, empty='No items match.', noun='items', sort=false, layout=none, default='table') %} +{%- if layout == 'table' %}{{ rows(id, cols, items, search, choices, only, empty, noun, sort, default) }}{% else %} +{{ controls(id, cols, search, choices=choices, only=only, sort=sort, layout=layout, default=default) }}
{% if caller is defined %}{{ caller() }}{% else %}{{ grid(cols, items, choices=choices, sort=sort) }}{% endif %}
{{ empty_note(id, empty) }} +{%- endif %} +{% endmacro %} + +{#- An item's icon: `src` an image URL or a sprite symbol, else the initials of `name`. #} +{% macro mark(icon, src, name) %} + {%- if not src %} + {%- elif '#' in src %} + {%- else %}{% endif %}{% endmacro %} + +{#- A row's attributes, written once per item by rows. #} +{% macro attrs(r) %}{{ r.attrs }}{% endmacro %} + +{# The items of a cards collection as a table (the table toolkit's, with its Columns menu): a column per field the + table takes that some item fills (a filtered or 'num' one always), in the order of `cols`; the title pinned, its + icon before it and a link to `href`, the others as on the card. A field `off` starts hidden. #} +{% macro rows(id, cols, items, search, choices, only, empty, noun, sort, default) %} +{%- set icon = (cols|selectattr('card', 'equalto', 'icon')|list + [none])[0] %} +{%- set icons = icon and items|selectattr(icon.key)|list|length > 0 %} +{%- set shown = [] %}{% for c in cols if c.table is not sameas false and (c.key in choices or c.type == 'num' or items|selectattr(c.key)|list) %}{% set _ = shown.append(dict(c, sticky=c.card == 'title')) %}{% endfor %} +{%- set rs = [] %}{% for item in items %}{% set a %}{% if item.get('id') %} id="{{ item.id }}"{% endif %} data-search="{{ item.get('search', '') }}" + {%- for f in cols if f.key in choices %} data-f-{{ f.key }}="{% call(f, v) each(item, [f]) %}{{ v.get('value', v.text) }} {% endcall %}"{% endfor %}{% endset %} + {%- set _ = rs.append({'item': item, 'attrs': a}) %}{% endfor %} +{% call(r, c) table(id, shown, rs, attrs, search=search, columns=true, choices=choices, only=only, empty=empty, noun=noun, sort=sort, layout='table', default=default) %} + {%- set v = r.item.get(c.key) %}{% set by %}{% call(f, x) each(r.item, [c]) %}{{ x.get('value', x.text) }} {% endcall %}{% endset %} + {%- call cell(c, sort=by|trim) %}{% if c.card == 'title' %}{% set name = v.text if v is mapping else v %}{% if icons %}{{ mark(icon, r.item.get(icon.key), name) }}{% endif %}{{ name }} + {%- elif c.style == 'code' %}{{ v }} + {%- else %}{% call(f, x) each(r.item, [c]) %}{{ pill(f, x) }} {% endcall %}{% endif %}{% endcall %} +{%- endcall %} {% endmacro %} {# The cards of `items`. `every`: the collection the icon rule reads, when `items` is a part of it; `choices`: the @@ -49,13 +79,10 @@ {%- for item in items %}
+ {%- for f in fields if sort and not f.blank and (sort is sameas true or f.key in sort) %} data-s-{{ f.key }}="{% call(f, v) each(item, [f]) %}{{ v.get('value', v.text) }}{% endcall %}"{% endfor %}> {%- set title = by.title[0] %}{% set v = item.get(title.key) %}{% set v = v if v is mapping else {'text': v} %}{% set name = v.text %} {%- set cls = [title.class, v.class]|select|join(' ') %} -
{% if icons %}{% set src = item.get(icon.key) %} - {%- if not src %} - {%- elif '#' in src %} - {%- else %}{% endif %}{% endif -%} +
{% if icons %}{{ mark(icon, item.get(icon.key), name) }}{% endif -%} {%- set link %}{{ name }}{% endset %} {%- if v.after %}{{ link }} {{ v.after }}{% else %}{{ link }}{% endif %} {%- set corner %}{% call(f, v) each(item, by.check) %}{% endcall %} diff --git a/app/templates/_tables.html b/app/templates/_tables.html index 7fbea968..5ead8bab 100644 --- a/app/templates/_tables.html +++ b/app/templates/_tables.html @@ -31,13 +31,13 @@ {# A whole table (static/tables.js `wire`): its controls row, its headers from `cols`, a row of `rows` each, and its pages. `id` names it, and keys what a viewer chooses; `class` adds to its classes; `tr`: a macro writing a row's attributes. The call block writes a cell: it is called with a row and a column, in the order of `cols`, and - writes that cell with the cell macro. Opt-ins: `search`, `columns`, `choices`, `only`, `views`, `actions`, `layout` - as controls'; `empty` and `noun` as pager's; `sticky_head`: its header row pinned while it scrolls down, and `tr`'s + writes that cell with the cell macro. Opt-ins: `search`, `columns`, `choices`, `only`, `views`, `actions`, `sort`, + `layout`, `default` as controls'; `empty` and `noun` as pager's; `sticky_head`: its header row pinned while it scrolls down, and `tr`'s rows with data-sticky under it (tables.js `sticky`), the controls row with them up to the table's end. #} -{% macro table(id, cols, rows, tr, class='', search='', columns=false, choices={}, only={}, empty='No rows match.', noun='rows', views=none, actions=none, layout=none, sticky_head=false) %} +{% macro table(id, cols, rows, tr, class='', search='', columns=false, choices={}, only={}, empty='No rows match.', noun='rows', views=none, actions=none, layout=none, sticky_head=false, sort=true, default='table') %} {%- if sticky_head %}
{% endif %} {%- set cols = cols|rejectattr('table', 'sameas', false)|list %} -{{ controls(id, cols, search, columns, choices, only, views, actions, layout=layout) }} +{{ controls(id, cols, search, columns, choices, only, views, actions, sort=sort, layout=layout, default=default) }} {%- for c in cols if c.width == 'expand' %} {%- endfor %} @@ -67,14 +67,16 @@ {# A table's controls row (static/tables.js `toolbar`) over the columns `cols`; each feature on only when asked. `search`: the search box's name and placeholder, over each row's data-search text; `columns`: the Columns menu; `choices`: column -> its (value, label) pairs to filter by; `only`: column -> the one value chosen - at load; then the Sort by menu, unless `sort` is false. `views` and `actions`: macros writing a page's own + at load; then the Sort by menu, unless `sort` is false; a list of keys + offers those columns only. `views` and `actions`: macros writing a page's own buttons, each any number of them, run by the page: views (how the table looks) before Columns, actions (on the rows or the selection) after Sort by. `layout` 'table' or 'cards', the one shown: a toggle of links to the - page's other one (?view=cards), its other query kept, at the end. The search goes left, the buttons right. A column's + page's other one, its other query kept, at the end; `default` the view a page shows without ?view=, the other + one's link carrying ?view=. The search goes left, the buttons right. A column's `filter` says where its choices go, one form or a list of them: 'button' (the default), in the Filter menu; 'dropdown', a menu of its own; 'pills', a row of toggles under the controls. A column's `filter_icon`, a sprite id without its `i-`, leads its dropdown's button and its pills. `id`: the table's. #} -{% macro controls(id, cols, search='', columns=false, choices={}, only={}, views=none, actions=none, sort=true, layout=none) %} +{% macro controls(id, cols, search='', columns=false, choices={}, only={}, views=none, actions=none, sort=true, layout=none, default='table') %} {%- set by = {'button': [], 'dropdown': [], 'pills': []} %}{% for c in cols if c.key in choices %}{% for f in ([c.filter] if c.filter is string else c.filter or ['button']) %}{% set _ = by[f].append(c) %}{% endfor %}{% endfor %}
{% if search %}{% endif %} @@ -100,7 +102,7 @@
Column - {% for c in cols if not (c.blank or c.check) %}{% endfor %} + {% for c in cols if not (c.blank or c.check) and (sort is sameas true or c.key in sort) %}{% endfor %}
Order @@ -111,7 +113,7 @@
{% endif %} {{ slot('actions', actions) }} {% if layout %}{% set q = dict(request.view_args, **request.args.to_dict(flat=false)) %}{% endif %} diff --git a/app/templates/agents/kits.html b/app/templates/agents/kits.html index 1ec9413a..68a1a96b 100644 --- a/app/templates/agents/kits.html +++ b/app/templates/agents/kits.html @@ -42,10 +42,10 @@

Checks

{{ page_head('Kits', sub=items|length ~ ' conformance kits') }} {#- A card's fields (web/agents.py `_kit_card`); the family's pills filter them. #} - {% set cols = [dict(key='family', label='Family', card='tag', class='std-tag', filter='pills'), dict(key='version', label='Version', card='meta'), - dict(key='title', label='Name', card='title'), dict(key='port', label='Port', card='text', style='code'), - dict(key='checks', label='Checks', card='stat')] %} - {{ cards('kits', cols, items, search='Name, port, check', choices={'family': [('agent', 'Agents'), ('capability', 'Capabilities')]}, empty='No kits match.', noun='kits') }} + {% set cols = [dict(key='title', label='Name', card='title'), dict(key='family', label='Family', card='tag', class='std-tag', filter='pills'), + dict(key='port', label='Port', card='text', style='code'), dict(key='checks', label='Checks', card='stat', type='num'), + dict(key='version', label='Version', card='meta')] %} + {{ cards('kits', cols, items, search='Name, port, check', choices={'family': [('agent', 'Agents'), ('capability', 'Capabilities')]}, sort=['title', 'port', 'checks'], empty='No kits match.', noun='kits', layout='table' if request.args.get('view') == 'table' else 'cards', default='cards') }}
{% endif %} {% endblock %} diff --git a/app/templates/agents/standard.html b/app/templates/agents/standard.html index 42c5b91e..3e72259f 100644 --- a/app/templates/agents/standard.html +++ b/app/templates/agents/standard.html @@ -34,13 +34,14 @@ {% if problems %}
Not offered: a definition with problems
    {% for p in problems %}
  • {{ p }}
  • {% endfor %}
{% endif %} {% if not items %}

No {{ kind }} yet.

{% endif %} - {#- A card's fields (web/agents.py `_card`). #} - {% set cols = [dict(key='kind', label='Kind', card='tag', class='cat-tag'), dict(key='protocol', label='Protocol', card='tag', class='std-tag'), - dict(key='example', label='Example', card='tag', class='std-tag'), dict(key='version', label='Version', card='meta'), - dict(key='icon', label='Logo', card='icon', table=false, class='std-mark small'), dict(key='title', label='Name', card='title'), - dict(key='summary', label='Summary', card='text', class='std-clamp'), dict(key='ports', label='Ports proven', card='stat'), - dict(key='runs', label='Benchmarks it runs', card='stat'), dict(key='installs', label='Installs', card='stat', class='word')] %} - {% if items %}{{ cards(plural|lower, cols, items, search='Name, protocol, summary', empty='No ' ~ kind ~ ' matches.', noun=plural|lower) }}{% endif %} + {#- A card's fields (web/agents.py `_card`); an agent's protocol and the ports it proves as dropdowns. #} + {% set cols = [dict(key='icon', label='Logo', card='icon', table=false, class='std-mark small'), dict(key='title', label='Name', card='title'), + dict(key='kind', label='Kind', card='tag', class='cat-tag'), dict(key='protocol', label='Protocol', card='tag', class='std-tag'), + dict(key='proves', label='Proves', class='std-tag', off=true), dict(key='example', label='Example', card='tag', class='std-tag', off=true), + dict(key='summary', label='Summary', card='text', class='std-clamp', width='expand', off=true), dict(key='ports', label='Ports proven', card='stat', type='num'), + dict(key='runs', label='Benchmarks it runs', card='stat', type='num'), dict(key='installs', label='Installs', card='stat', class='word'), + dict(key='version', label='Version', card='meta')] %} + {% if items %}{{ cards(plural|lower, cols, items, search='Name, protocol, summary', choices=choices, sort=['title', 'ports', 'runs'], empty='No ' ~ kind ~ ' matches.', noun=plural|lower, layout='table' if request.args.get('view') == 'table' else 'cards', default='cards') }}{% endif %}
{% endblock %} {% block scripts %}{% endblock %} diff --git a/app/templates/catalogue/benchmarks.html b/app/templates/catalogue/benchmarks.html index b5f7085f..d081ea0c 100644 --- a/app/templates/catalogue/benchmarks.html +++ b/app/templates/catalogue/benchmarks.html @@ -28,20 +28,23 @@ {% endcall %} {#- A card's fields (web/catalogue.py `_card`); the filters are the category's pills, and the origin and what runs it as dropdowns. #} - {% set cols = [dict(key='category', label='Category', card='tag', class='cat-tag', filter='pills'), dict(key='origin', label='Origin', card='tag', class='origin-tag', filter='dropdown', filter_icon='origin'), - dict(key='icon', label='Mark', card='icon', table=false, class='bench-mark'), dict(key='title', label='Name', card='title'), - dict(key='domain', label='Domain', card='text'), dict(key='runs', label='Runs with', card='badge', class='run-tag', filter='dropdown', filter_icon='runner'), - dict(key='needs', label='Needs', card='note', icon='wrench'), dict(key='tasks', label='Tasks', card='stat'), - dict(key='datasets', label='Datasets', card='stat'), dict(key='scoring', label='Scored by', card='stat', class='word'), + {% set cols = [dict(key='icon', label='Mark', card='icon', table=false, class='bench-mark'), dict(key='title', label='Name', card='title'), + dict(key='category', label='Category', card='tag', class='cat-tag', filter='pills'), dict(key='origin', label='Origin', card='tag', class='origin-tag', filter='dropdown', filter_icon='origin'), + dict(key='domain', label='Domain', card='text', off=true), dict(key='runs', label='Runs with', card='badge', class='run-tag', filter='dropdown', filter_icon='runner'), + dict(key='tasks', label='Tasks', card='stat', type='num'), dict(key='datasets', label='Datasets', card='stat', type='num'), + dict(key='scoring', label='Scored by', card='stat', class='word'), dict(key='needs', label='Needs', card='note', icon='wrench', off=true), dict(key='blocker', label='Blocker', card='alert')] %} - {#- Two shelves: the official benchmarks, then the community benchmarks. A card opens the benchmark's own page. #} - {% call cards('benchmarks', cols, items, search='Name, category, dataset', choices=choices, empty='No benchmark matches.', noun='benchmarks') %} - {% for state, heading in [('official', 'Official'), ('community', 'Community')] %} + {#- Two shelves: the official benchmarks, then the community benchmarks; the table is one table in that order, its + Origin the shelf. A card or a name opens the benchmark's own page. #} + {% set sort = ['title', 'tasks', 'datasets'] %}{% set shelves = [('official', 'Official'), ('community', 'Community')] %} + {% set rows = [] %}{% for state, _ in shelves %}{% set _ = rows.extend(items|selectattr('shelf', 'equalto', state)) %}{% endfor %} + {% call cards('benchmarks', cols, rows, search='Name, category, dataset', choices=choices, sort=sort, empty='No benchmark matches.', noun='benchmarks', layout='table' if request.args.get('view') == 'table' else 'cards', default='cards') %} + {% for state, heading in shelves %} {% set shelf = items|selectattr('shelf', 'equalto', state)|list %} {% if shelf %}

{{ heading }} {{ shelf|length }}

- {{ grid(cols, shelf, every=items, choices=choices) }} + {{ grid(cols, shelf, every=items, choices=choices, sort=sort) }}
{% endif %} {% endfor %} diff --git a/app/ui_tests/test_agents.py b/app/ui_tests/test_agents.py index 7dd77445..75d06cce 100644 --- a/app/ui_tests/test_agents.py +++ b/app/ui_tests/test_agents.py @@ -137,6 +137,7 @@ def test_kits_catalogue_and_proof_links(self): self.assertIn('', page) self.assertIn('
Checks
3
', page) self.assertNotIn('bench-card-title">Ports proven
2/7
", card) # task and workspace, of the seven agent ports self.assertIn("
Benchmarks it runs
1/1
", card) - self.assertNotIn("agent.task/v1", card[:card.index("
")]) # the detail is on its page + self.assertNotIn("agent.task/v1", card[card.index(">"):card.index("")]) # the detail is on its page self.assertEqual(self.get("/agents/nope").status_code, 404) + def test_agents_sort_and_filter_by_protocol_and_the_ports_they_prove(self): + html = self.get("/agents").get_data(as_text=True) + menu = html[html.index('data-tools="sort"'):] + self.assertEqual(re.findall(r'data-sort-col value="(\w*)"', menu), ["", "title", "ports", "runs"]) + self.assertIn('data-tools-btn="filter"', html) # both in the one Filter menu, no dropdown of their own + self.assertNotIn('data-dropdown', html) + self.assertIn('
\n Protocol', html) + self.assertIn(' ACP', html) + self.assertIn('
\n Proves', html) + self.assertIn(' One task', html) + card = html[html.index('id="fake"'):] + self.assertIn('data-f-proves="agent.task/v1 agent.workspace/v1 "', card[:card.index(">")]) + self.assertIn('data-s-ports="2/7"', card[:card.index(">")]) + caps = self.get("/capabilities").get_data(as_text=True) + self.assertIn('data-tools="sort"', caps) + self.assertNotIn("data-filter-menu", caps) # one protocol: nothing to filter + + def test_agents_capabilities_and_kits_are_cards_by_default_and_a_table_on_request(self): + for url in ("/agents", "/capabilities", "/kits"): + html = self.get(url).get_data(as_text=True) + self.assertIn(f'href="{url}?view=table" aria-label="Table" title="Table" aria-current="false"', html) + self.assertIn(f'href="{url}" aria-label="Cards" title="Cards" aria-current="true"', html) + self.assertNotIn("data-table", html) + html = self.get(url + "?view=table&q=1").get_data(as_text=True) + self.assertIn(f'href="{url}?view=table&q=1" aria-label="Table" title="Table" aria-current="true"', html) + self.assertIn(f'href="{url}?q=1" aria-label="Cards" title="Cards" aria-current="false"', html) + self.assertNotIn("data-cards", html) + self.assertIn('data-col="title" data-type="text" class="sticky-col sticky-edge">Name', html) + html = self.get("/agents?view=table").get_data(as_text=True) + row = html[html.index('")] + self.assertIn('data-f-proves="agent.task/v1 agent.workspace/v1 "', row) + self.assertIn('', row) + self.assertIn('2/7', row) + self.assertIn(' Summary', html) + self.assertNotIn('data-col="kind"', html) # no agent has a kind: no column + kits = self.get("/kits?view=table").get_data(as_text=True) + self.assertEqual(re.findall(r' Nullius', html) # its value, by its label + def test_the_list_sorts_by_name_tasks_and_datasets_on_each_shelf(self): + html = self.get("/benchmarks") + menu = html[html.index('data-tools="sort"'):] + self.assertEqual(re.findall(r'data-sort-col value="(\w*)"', menu), ["", "title", "tasks", "datasets"]) + self.assertIn('value="tasks" data-type="num"> Tasks', menu) + self.assertIn('data-s-title="SWE-bench Verified" data-s-tasks="500" data-s-datasets="1"', self.card("swe-bench-verified")) + self.assertIn('data-group-n>', html[html.index('data-shelf="official"'):html.index("data-s-title")]) # within its shelf + def test_the_list_filters_by_origin(self): html = self.get("/benchmarks") self.assertIn('
', html) @@ -94,6 +102,26 @@ def test_the_list_filters_by_origin(self): self.assertIn('data-f-origin="official "', self.card("gaia")) self.assertNotIn('data-value="Experiment"', html) + def test_the_list_is_cards_by_default_and_a_table_on_request(self): + self.assertIn('href="/benchmarks?view=table" aria-label="Table" title="Table" aria-current="false"', self.html) + self.assertIn('href="/benchmarks" aria-label="Cards" title="Cards" aria-current="true"', self.html) + self.assertNotIn("data-table", self.html) + html = self.get("/benchmarks?view=table&q=1") + self.assertIn('href="/benchmarks?view=table&q=1" aria-label="Table" title="Table" aria-current="true"', html) + self.assertIn('href="/benchmarks?q=1" aria-label="Cards" title="Cards" aria-current="false"', html) # the default has no view + self.assertNotIn("data-cards", html); self.assertNotIn('class="bench-card"', html) + heads = re.findall(r']*data-f-origin="official "[^>]*>(?:(?!).)*href="/benchmarks/swe-bench-verified".*?', html, re.S).group(0) + self.assertIn('data-f-runs="standard harbor "', row) + self.assertIn('', row) + self.assertIn('data-pills="category"', html); self.assertIn('data-filter-menu="origin"', html) + self.assertEqual(re.findall(r'data-sort-col value="(\w*)"', html[html.index('data-tools="sort"'):]), ["", "title", "tasks", "datasets"]) + self.assertIn(' Needs', html) # secondary: off until chosen + origins = re.findall(r'data-f-origin="(\w+) "', html) + self.assertEqual(origins, sorted(origins, key=list(catalog.ORIGINS).index)) # the shelves' order + def test_the_list_filters_by_category_pills_and_two_dropdowns(self): tools = self.html.split('id="benchmarks-tools"', 1)[1].split('id="benchmarks"', 1)[0] self.assertIn('
', tools) @@ -109,7 +137,6 @@ def test_the_list_filters_by_category_pills_and_two_dropdowns(self): def test_the_list_searches_by_name_category_and_dataset(self): self.assertIn('No benchmark matches.

', self.html) diff --git a/app/ui_tests/test_run_routes.py b/app/ui_tests/test_run_routes.py index c179c3a6..75fc5903 100644 --- a/app/ui_tests/test_run_routes.py +++ b/app/ui_tests/test_run_routes.py @@ -533,12 +533,10 @@ def test_the_page_is_a_table_or_cards_and_renders_only_the_one_chosen(self): self.assertIn(f'', card) self.assertIn(f'', card) - def test_the_view_toggle_keeps_the_other_query_and_shows_only_where_asked(self): + def test_the_view_toggle_keeps_the_other_query(self): html = self.page("/workspaces?view=cards&q=1") self.assertIn('href="/workspaces?q=1" aria-label="Table"', html) self.assertIn('href="/workspaces?view=cards&q=1" aria-label="Cards"', html) - for url in ("/benchmarks", "/kits", "/agents"): - self.assertNotIn('aria-label="Table" title="Table"', self.page(url), url) def test_a_restart_with_the_same_paths_reopens_the_workspace_its_runs_went_into(self): runs = self.tmp / "runs" diff --git a/app/web/agents.py b/app/web/agents.py index 608e595f..a3a4f1f0 100644 --- a/app/web/agents.py +++ b/app/web/agents.py @@ -91,7 +91,16 @@ def _page(kind: str): found = _entries(kind) return render_template("agents/standard.html", kind=kind, how=howto.steps(kind), prompts=howto.prompts(), catalogue_dir=paths.catalogue_dir(), example_dir=example, problems=found["problems"], - items=[_card(kind, e) for e in found["entries"]]) + items=[_card(kind, e) for e in found["entries"]], choices=_choices(kind, found["entries"])) + + +def _choices(kind: str, entries: list) -> dict: + """An agent list's filters: how Nullius talks to it, and the ports it proves; none for capabilities.""" + if kind != "agent": + return {} + proven = {p["port"] for e in entries for p in e["ports"] if p["state"] == "proven"} + return {"protocol": [(x, x[:1].upper() + x[1:]) for x in dict.fromkeys(e["protocol"] for e in entries)], + "proves": [(p, spec.get("label") or p) for p, spec in ports.PORTS.items() if p in proven]} def _card(kind: str, e: dict) -> dict: @@ -105,6 +114,7 @@ def _card(kind: str, e: dict) -> dict: "version": ("v" + str(version) if version else "") + (f" · {n} versions" if n > 1 else ""), "icon": agent_mark_url(d["key"]) if kind == "agent" else None, "title": d["label"], "summary": d.get("summary"), + "proves": [{"text": p["label"], "value": p["port"]} for p in e["ports"] if p["state"] == "proven"], "ports": "{}/{}".format(sum(p["state"] == "proven" for p in e["ports"]), len(e["ports"])), "runs": "{}/{}".format(sum(not f["why"] for f in e["fits"]), len(e["fits"])), "installs": "yes" if e["install"] else "no"} diff --git a/app/web/catalogue.py b/app/web/catalogue.py index ad00a25b..af5aee98 100644 --- a/app/web/catalogue.py +++ b/app/web/catalogue.py @@ -54,7 +54,7 @@ def _card(cat, b, needs, sheet) -> dict: for way, (label, name) in RUNS_WITH.items() if way in b.harness], "needs": needs and {"text": "needs " + ", ".join(needs), "title": f"Some of its options need {', '.join(needs)} installed on the machine it runs on: see its page"}, - "tasks": {"text": tasks, "label": unit.capitalize()}, + "tasks": {"text": tasks, "label": unit.capitalize(), "value": tasks.replace(",", "").split("–")[-1]}, "datasets": {"text": len(ds), "label": "Datasets" if len(ds) != 1 else "Dataset"}, "scoring": b.scoring, "blocker": b.blocker[:1].upper() + b.blocker[1:]}