Backend protocol: name the interface between Client and Backend
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 40/100
- Tipo de issue
- Refactorización
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- python
- Área
- backend, backend-api-design
Línea de trabajo
Start by reading ess/apps/client.py, ess/apps/backend.py, and the lifetime and accumulator docs named in the issue to map the current interface and its guarantees. The proposal names ess/apps/protocol.py as the destination for BackendProtocol, Entry, Selection, FileSource, and Store; the concrete completion criteria are to type Client against the protocol, move local() beside Backend, and preserve public imports. Resolve the stated wait and watch_files design decisions, then move the rules into protocol docstrings and trim their duplicate documentation.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Make the interface that Client calls on Backend an explicit typing.Protocol, and make it the one home of the rules that clients rely on. It is also the shape of the API that an HTTP server would expose for a hosted backend (#27).
Today
Client calls 27 methods of Backend. All of them take IDs and a client: str, and return records, statuses, or values. Client adds no semantics of its own. It does three things:
- Reshaping: it accepts one, a list, or a dict, and returns the same shape.
- Wrapping: it turns IDs into
Record,Stage, andAccumulatorobjects. - Shortcuts:
compute(submit, then wait),latest, andprovenance.
So the protocol exists, but without a name:
client.pyimports the concrete class:from .backend import Backend, Entry, Selection.local()lives inclient.py, which is why the client module imports the backend at all.- The rules are spread over:
- the
Clientdocstrings, which point todocs/developer/lifetimes.mdandaccumulators.md; - the root
docs/developer/README.md; - ADRs 0002, 0003, 0004, and 0006;
- the 139-line module docstring of
backend.py, which mixes rules with implementation.
- the
Proposal
A BackendProtocol in ess/apps/protocol.py, next to Entry, Selection, and the protocols FileSource and Store. Client.__init__ takes a BackendProtocol. local() moves next to the in-process Backend, and ess.apps keeps re-exporting it.
| Group | Methods |
|---|---|
| Sessions | open_client, close_client |
| Specs | spec, specs |
| Requests | submit, cancel, status, wait, failure |
| History | record, records, changes, plain_request |
| Values | outputs, describe, readable, persist, release |
| Stages and accumulators | open_stage, open_accumulator, push, freeze, accumulator_outputs |
| Files | files, watch_files, file_metadata |
Backend.close is the lifecycle of the server, not something a client calls, so it stays off the protocol.
The two sides differ as follows:
Client |
BackendProtocol |
|
|---|---|---|
| Serves | one proposal, one session | many clients and proposals, named by ID |
| Speaks in | Python objects and shapes | IDs, pydantic models, and values; nothing that could not cross a wire |
| Promises | ergonomics: shapes and shortcuts | the semantics: when a call returns, what is kept and readable, the order of the change feed, what each call may raise |
Rule: anything that changes what happens belongs in the protocol. The client only adapts.
Docs move, they are not copied. The rules from lifetimes.md, accumulators.md, and the client docstrings move into the protocol's docstrings. The Client docstrings then describe shapes and shortcuts and link to the protocol. The backend.py module docstring keeps only how the in-process backend implements the rules. Copying the rules instead would add another place to keep in sync.
What it gives us
- One home for the guarantees. App work needs only the client and the protocol, not the backend docs.
- Contract changes are their own diff.
changesanddescribe(#156) touched the client, the backend,views.py, ADR 0004, the README, and the app together. With a protocol, the new methods and their promises are a small diff to review, apart from the implementation behind them. - The seams of the backend are all named. Up to the client is the protocol. Down are
FileSourceandStore. Sideways isBindingfrom essspec.
What it does not give: it does not make backend.py smaller. That is a separate split. Test fakes of the backend would add little, since local() is cheap.
Toward an HTTP wrapper for a hosted backend
The protocol is the server's API surface. A hosted backend is then built as follows:
- Server: a thin layer that maps each route to a protocol call on an in-process
Backend. - Client side: a
RemoteBackendthat implements the protocol by making HTTP calls.connect(url, proposal)isClient(RemoteBackend(url), ...), andClientdoes not change. - Tests: the client and story tests run against both
local()andClient(RemoteBackend(test_server(Backend()))), through one parametrized fixture. That shows the two deployments behave the same, whichdocs/developer/README.mdpromises ("the caller sees the same records and outputs either way").
Writing the protocol now makes every method's types say what crosses the wire. These methods would need a decision:
| Method | In-process today | Over HTTP |
|---|---|---|
open_client(proposal, submitter) |
the caller names the submitter | the submitter comes from authentication, and access to the proposal is checked. The returned ID becomes a session with a lease (#27) |
every method's client: str |
an argument | from the session or token |
spec, specs |
return WorkflowSpec with live pydantic models |
return SpecId and SerializedWorkflowSpec (#88). A Python client maps the SpecId to installed spec modules (ADR 0007) |
submit(entries), push(rows), open_stage, open_accumulator |
Request.params and rows may hold pydantic model instances |
encoded through the params schema and request types (#88, #140) |
wait(ids) |
blocks without a timeout | blocking does not suit HTTP: make it a long poll with a timeout, with the client looping (#81: timeout= is undecided) |
watch_files(selector) |
returns an iterator | an iterator does not cross a wire: give it a cursor form like changes, and let the client build the iterator (new-file signal in #155) |
outputs, accumulator_outputs |
return the value the workflow returned, not a copy | a copy, through a codec per output type (#152); describe and select= (#149) limit what is sent |
SubmitError (with FieldErrors), NotReadable, RecordFailed, ClientEnded |
Python exceptions | part of the contract: a structured error body each |
bindings, local(bind=...) |
code from the notebook | not part of the protocol: a hosted backend finds bindings through entry points (ADR 0007) |
This suggests one more rule: protocol methods are request and response; whatever blocks or iterates is built in Client on top. Today wait and watch_files break this rule.
Not settled by the protocol: authentication and access across proposals, leases and memory caps (#27), wire format and codecs (#152), and versioning of the HTTP API.
Steps
- Add
protocol.pywithBackendProtocol, and moveEntry,Selection,FileSource, andStorethere. TypeClientagainst the protocol. Movelocal()next toBackend. Public imports do not change. - Move the rules into the protocol's docstrings, and trim the client and backend docstrings and the docs pages that held them.
- Decide
waitandwatch_files(request/response, with the client looping). - Later, with #27:
RemoteBackend, the HTTP server, and the parametrized test fixture.
This goes with splitting ess.apps into subpackages (client/, backend/, files/, ui/, panel/, automatic/), with the layering checked by import-linter. That split is a separate issue.
- Lenguaje dominante
- Python
- Estrellas
- 0
- Forks
- 1
- Merge medio
- 15 h 40 min
- PR fusionados (30 d)
- 59
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de scipp/essapps
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
A number that is not finite is stored as None at a field that accepts NonePosiblemente ocupada @jeevanabhi-r la tomó hace 2 días. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
scipp/essapps#140 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Los mantenedores suelen responder en 1 día
Todos los issues de scipp/essapps
Issues similares
-
Remove the `pull_request_target` workflow before GitHub blocks itPosiblemente ocupada @jat255 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 2 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
IBM/mcp-context-forge#7483 ·
Los mantenedores suelen responder en 2 días
-
bug good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
[Bug Report]: OpenAI 辅助 API 连通性测试因输出上限仅 1 token 误报“未知错误”Posiblemente ocupada @fjfanjian la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Project-N-E-K-O/N.E.K.O#3640 ·
Los mantenedores suelen responder en 1 día
-
author-page correction
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
acl-org/acl-anthology#10808 · 1 comentario ·
Los mantenedores suelen responder en 1 día