Pipelines: New pipeline is one branch and Enter

The button now opens a page that asks for the dev branch and nothing else,
like Create Test does. The engine, repository, default network, time control,
options, bounds and base branch come from the same presets Create Test uses,
and the default plan is STC, then LTC if it passes. Presets, the base branch,
a name and the engine are there for whoever wants them, under More options.

Enter creates the pipeline and starts it. If the first test cannot be made
(a branch that does not exist, Github down) the pipeline is not left behind,
and the page comes back with the branch still typed in. Save without running
is the other button.

The flow editor stays as it was, and is one click away from the list and from
the new page, for retries, branching on a failure, tunes and datagen.
This commit is contained in:
claude committed 2026-10-14 20:29:02 +02:00
1 parent 48027f1142
commit 8077809d0b
4 files changed
+261 -2

No files matched your search

+166 -1
View File
@@ -30,6 +30,8 @@
# of, and takes no input from the request at all except which object it is for.
# Every decision, allowed or refused, leaves an event behind.
import OpenBench.config
import OpenBench.pipeline_defaults as defaults
import OpenBench.pipeline_graph as graphs
import OpenBench.pipeline_layout as drawing
import OpenBench.pipelines
@@ -41,7 +43,7 @@ import json
from django.http import JsonResponse
from django.views.decorators.http import require_POST
from OpenBench.models import LogEvent, Pipeline, PipelineRun, Profile, StepRun, Test
from OpenBench.models import LogEvent, Network, Pipeline, PipelineRun, Profile, StepRun, Test
STATUS_LABELS = {
'QUEUED' : 'Waiting', 'LAUNCHING' : 'Starting', 'RUNNING' : 'Running',
@@ -624,3 +626,166 @@ def pipeline_test_fields(request, test_id):
fields['test_max_games'] = test.max_games
return JsonResponse({ 'payload' : { key : str(value) for key, value in fields.items() } })
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# QUICK START #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# What the New pipeline button opens. It asks for one thing, the dev branch, and
# fills in everything else the way that the Create Test page does ( the same
# presets, the same defaults, see pipeline_defaults.py ), so that a branch and an
# Enter are all that it takes, as they are for a single test. What comes out is a
# plain pipeline, which the editor can change like any other.
def _quick_engine(profile, wanted):
""" The engine to make tests for: the one asked for, else the default of this
person, else the first there is. '' when the server has none at all """
engines = OpenBench.config.OPENBENCH_CONFIG['engines']
for name in (wanted, profile.engine):
if name in engines:
return name
return next(iter(engines), '')
def _quick_choices(engine_config):
""" ( the presets to choose from, the one that goes first, the one that follows ) """
names = defaults.preset_names(engine_config)
first = 'STC' if 'STC' in names else (names[0] if names else '')
then = 'LTC' if 'LTC' in names and first != 'LTC' else ''
choices = [{ 'name' : name, 'time' : defaults.time_control(engine_config, name) } for name in names]
return choices, first, then
def _quick_page(request, engine, choices, form, error=None):
config = OpenBench.config.OPENBENCH_CONFIG
# What the presets say about the base branch, to show where the box is left blank
base = defaults.test_payload(engine, config['engines'][engine], form['first'], 'dev')[0].get('base_branch', '')
data = {
'engine' : engine,
'engines' : list(config['engines']),
'choices' : choices,
'form' : form,
'base' : base,
'more' : bool(form['base_branch'] or form['name'] or not base),
}
return OpenBench.views.render(request, 'pipeline_quick.html', data, error=error)
def pipeline_quick(request):
profile = viewer(request)
if profile is None:
return _turn_away(request, profile)
config = OpenBench.config.OPENBENCH_CONFIG
source = request.POST if request.method == 'POST' else request.GET
engine = _quick_engine(profile, source.get('engine'))
if not engine:
return OpenBench.views.redirect(request, '/pipelines/', error='No engine is set up on this server')
engine_config = config['engines'][engine]
choices, first, then = _quick_choices(engine_config)
names = [choice['name'] for choice in choices]
if not names:
return OpenBench.views.redirect(request, '/pipelines/new/', error='%s has no test presets, so its pipelines are made here' % (engine))
asked = {
'dev_branch' : (source.get('dev_branch' ) or '').strip(),
'base_branch' : (source.get('base_branch') or '').strip(),
'name' : (source.get('name' ) or '').strip(),
'first' : source.get('first', first),
'then' : source.get('then' , then ),
}
form = dict(asked,
first = asked['first'] if asked['first'] in names else first,
then = asked['then' ] if asked['then' ] in names else '')
if request.method != 'POST':
return _quick_page(request, engine, choices, form)
errors = []
branch = defaults.clean_branch(asked['dev_branch'])
if not asked['dev_branch']:
errors.append('Type the name of the branch to test')
elif branch is None:
errors.append('"%s" cannot be a branch, which has no spaces or quotes' % (asked['dev_branch'][:40]))
base = asked['base_branch']
if base and defaults.clean_branch(base) is None:
errors.append('"%s" cannot be a branch, which has no spaces or quotes' % (base[:40]))
if asked['first'] not in names:
errors.append('Pick the test to run first')
if asked['then'] and asked['then'] not in names:
errors.append('Pick the test to run after it, or none')
if errors:
return _quick_page(request, engine, choices, form, error='\n'.join(errors))
networks = list(Network.objects.all().values())
books = list(config['books'])
plan = [asked['first']] + ([asked['then']] if asked['then'] else [])
steps, lacking = [], []
for preset in plan:
payload, absent = defaults.test_payload(engine, engine_config, preset, branch, profile.repos, networks, books, base)
steps.append((preset, payload))
lacking += [(preset, key) for key in absent]
if any(key == 'base_branch' for _, key in lacking):
errors.append('Type the base branch, as the engine does not say which one to test against')
others = ['%s (%s)' % (key.replace('_', ' '), preset) for preset, key in lacking if key != 'base_branch']
if others:
errors.append('The presets of %s leave out: %s\nFill those in with the editor' % (engine, ', '.join(others)))
if errors:
return _quick_page(request, engine, choices, form, error='\n'.join(errors))
graph = defaults.quick_graph(steps)
issues = _check(graph)
if graphs.has_errors(issues): # Nothing for a person to fix: this page never builds anything that is wrong
problems = '\n'.join(i['message'] for i in issues if i['level'] == 'error')
return _quick_page(request, engine, choices, form, error='The pipeline could not be made:\n' + problems)
author = profile.user.username
title = asked['name'][:128] or defaults.quick_name(branch, [label for label, _ in steps])
pipeline = Pipeline.objects.create(name=title, author=author, graph=_tidy(graph))
pipeline_id = pipeline.id
_audit(author, 'PIPELINE #%d CREATED' % (pipeline_id))
if request.POST.get('action') == 'save':
return OpenBench.views.redirect(request, '/pipelines/%d/' % (pipeline_id), status='Pipeline saved')
run, issues = OpenBench.pipelines.start_pipeline(pipeline, starter=author)
first_step = StepRun.objects.filter(run=run).order_by('id').first() if run else None
if run is None or (run.status == 'ERROR' and first_step):
reason = first_step.message if first_step else '\n'.join(i['message'] for i in issues if i['level'] == 'error')
# Nothing was made, and a pipeline that never made anything is of no use to anybody
pipeline.delete()
_audit(author, 'PIPELINE #%d DISCARDED' % (pipeline_id))
return _quick_page(request, engine, choices, form, error='The first test could not be created:\n' + reason)
return OpenBench.views.redirect(request, '/pipelines/run/%d/' % (run.id), status='Pipeline started')
+1
View File
@@ -50,6 +50,7 @@ urlpatterns = [
django.urls.path(r'pipelines/<int:id>/delete/', OpenBench.pipeline_views.pipeline_delete),
django.urls.path(r'pipelines/<int:id>/edit/', OpenBench.pipeline_views.pipeline_edit),
django.urls.path(r'pipelines/new/', OpenBench.pipeline_views.pipeline_new),
django.urls.path(r'pipelines/quick/', OpenBench.pipeline_views.pipeline_quick),
django.urls.path(r'pipelines/check/', OpenBench.pipeline_views.pipeline_check),
django.urls.path(r'pipelines/preview/', OpenBench.pipeline_views.pipeline_preview),
django.urls.path(r'pipelines/test-fields/<int:test_id>/', OpenBench.pipeline_views.pipeline_test_fields),
+92
View File
@@ -0,0 +1,92 @@
{% extends "OpenBench/base.html" %}
{% block page_head %}
<div>
<a class="crumb" href="/pipelines/"><i class="fa-solid fa-chevron-left"></i> Pipelines</a>
<h1 class="page-title">New pipeline</h1>
<p class="page-sub">Type a branch and press Enter. Everything else is filled in like Create Test, and the first test starts right away</p>
</div>
{% endblock %}
{% block content %}
<style>
.quick-more { margin-top: 14px; }
.quick-more summary { cursor: pointer; margin-bottom: 12px; color: var(--color-font2, inherit); font-size: 13px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.quick-hint { margin-top: 1rem; }
</style>
<form method="post" action="/pipelines/quick/" autocomplete="off">
{% csrf_token %}
<div class="form">
<div class="col">
<h3> What to test </h3>
<div class="row">
<label for="dev_branch"> Dev Branch </label>
<input id="dev_branch" name="dev_branch" value="{{ form.dev_branch }}" placeholder="The branch to test" spellcheck="false" autofocus required>
</div>
<div class="row">
<label for="first"> First Test </label>
<select id="first" name="first">
{% for choice in choices %}
<option value="{{ choice.name }}"{% if choice.name == form.first %} selected{% endif %}>{{ choice.name }}{% if choice.time %} ({{ choice.time }}){% endif %}</option>
{% endfor %}
</select>
</div>
<div class="row">
<label for="then"> If It Passes </label>
<select id="then" name="then">
<option value=""{% if not form.then %} selected{% endif %}>Stop there</option>
{% for choice in choices %}
<option value="{{ choice.name }}"{% if choice.name == form.then %} selected{% endif %}>Then {{ choice.name }}{% if choice.time %} ({{ choice.time }}){% endif %}</option>
{% endfor %}
</select>
</div>
<details class="quick-more"{% if more %} open{% endif %}>
<summary> More options </summary>
{% if engines|length > 1 %}
<div class="row">
<label for="engine"> Engine </label>
<select id="engine" name="engine" onchange="location.search = '?engine=' + encodeURIComponent(this.value) + '&amp;dev_branch=' + encodeURIComponent(document.getElementById('dev_branch').value);">
{% for name in engines %}
<option value="{{ name }}"{% if name == engine %} selected{% endif %}>{{ name }}</option>
{% endfor %}
</select>
</div>
{% else %}
<input type="hidden" name="engine" value="{{ engine }}">
{% endif %}
<div class="row">
<label for="base_branch"> Base Branch </label>
<input id="base_branch" name="base_branch" value="{{ form.base_branch }}" placeholder="{% if base %}{{ base }}{% else %}The branch to compare against{% endif %}" spellcheck="false"{% if not base %} required{% endif %}>
</div>
<div class="row">
<label for="name"> Name </label>
<input id="name" name="name" value="{{ form.name }}" placeholder="The branch, and what runs" maxlength="128" spellcheck="false">
</div>
</details>
</div>
</div>
<div class="form-actions">
<div class="quick-actions">
<button type="submit" name="action" value="run" class="anchorbutton btn-blue">Run pipeline</button>
<button type="submit" name="action" value="save" class="anchorbutton btn-start">Save without running</button>
</div>
</div>
</form>
<p class="muted-small quick-hint">Need to retry, branch on a failure, or tune? <a href="/pipelines/new/">Draw the flow in the editor</a>.</p>
{% endblock %}
+2 -1
View File
@@ -7,7 +7,8 @@
</div>
<div class="page-actions">
<a class="anchorbutton btn-blue" href="/pipelines/new/">New pipeline</a>
<a class="anchorbutton btn-blue" href="/pipelines/quick/">New pipeline</a>
<a class="anchorbutton btn-start" href="/pipelines/new/">Flow editor</a>
</div>
{% endblock %}