Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
63a5062
docs(plans): plan the Railway use case on the InteractiveAI pipeline.
chenkins Nov 7, 2026
ba54610
chore(railway): add the scripted Railway simulator under usecases_exa…
chenkins Nov 8, 2026
1979e78
feat(railway): add ZWL distances, planned paths and the link map to t…
chenkins Nov 8, 2026
b82cbb3
feat(railway): run the platform locally without Docker
chenkins Nov 8, 2026
a5fdde4
test(railway): screenshot and record the Railway page on the dev stack
chenkins Nov 8, 2026
4c41d66
docs(plans): decide the Railway recommendations file, run list and st…
chenkins Nov 10, 2026
549cdd4
docs(plans): decide the two-step Ko-Lernen choice and show both Q8 op…
chenkins Nov 10, 2026
b978bcd
docs(plans): decide the end-of-session questionnaire and draw the Rai…
chenkins Nov 10, 2026
6565aee
docs(plans): identify the Railway Experiment by the platform's trace …
chenkins Nov 10, 2026
cbfcd0f
docs(plans): keep the Railway extension backwards compatible and deci…
chenkins Nov 10, 2026
c972540
docs(plans): revise the Railway plan and explain Q28 with a mockup of…
chenkins Nov 10, 2026
893d538
docs(plans): decide Q29 and fix the session end, questionnaire and st…
chenkins Nov 10, 2026
e313c69
docs(plans): decide Q21, the study lead decides the Railway reflectio…
chenkins Nov 10, 2026
eb3ff62
docs(plans): decide Q27, the Railway simulator runs as its own always…
chenkins Nov 10, 2026
81edf24
docs(plans): decide Q17 and Q18 with mockups and the Ko-Lernen flow o…
chenkins Nov 10, 2026
75263b6
docs(plans): show the Q22 end screen options and plan the open findin…
chenkins Nov 11, 2026
3e9fdd2
docs(plans): compare the technical cost of the two Q22 end screen opt…
chenkins Nov 11, 2026
7a00b35
docs(plans): decide Q22 and Q23, which settles Q13 for the Railway st…
chenkins Nov 11, 2026
0c21ca8
docs(plans): decide Q19, the Railway progress bar names the run's mode
chenkins Nov 11, 2026
091b3cc
docs(plans): decide Q4, Q2, Q28 and Q10 and confirm Q6 and Q8, which …
chenkins Nov 11, 2026
b7e61eb
feat(railway): accept scenario, session and infrastructure fields in …
chenkins Nov 11, 2026
84391bc
feat(i18n): show the Railway page in German, English and French
chenkins Nov 11, 2026
1b83049
feat(railway): publish events and contexts from a session runner and …
chenkins Nov 11, 2026
2b4c7da
feat(railway): answer recommendation requests from a file generated b…
chenkins Nov 11, 2026
8da776c
feat(railway): draw the track network and the trains from the context
chenkins Nov 11, 2026
69b0200
feat(railway): draw the time-distance diagram from the context history
chenkins Nov 11, 2026
bb3d04a
feat(railway): draw the link map from the context
chenkins Nov 11, 2026
6c44c50
feat(railway): show scenario status and the open decision in the cent…
chenkins Nov 11, 2026
d0129eb
feat(railway): choose and apply recommendations in German, train then…
chenkins Nov 11, 2026
17e8657
feat(railway): start sessions, move on between scenarios and ask the …
chenkins Nov 11, 2026
6a4ee06
ci(railway): run the simulator and Railway schema tests
chenkins Nov 11, 2026
4190e38
test(railway): check the full run in both modes against the reference…
chenkins Nov 11, 2026
c663b77
feat(deploy): deploy the Railway simulator next to the platform
chenkins Nov 11, 2026
ba78cf3
docs(plans): record the commits and shots of S3 to S15 and plan the K…
chenkins Nov 11, 2026
b959c09
docs(plans): mark the five decision findings fixed in the commit that…
chenkins Nov 11, 2026
43f9dff
feat(railway): open the geographic map for an external simulation fro…
chenkins Nov 12, 2026
b490b9c
fix(railway): pin Werkzeug below 3 for the simulator's Flask 2.3
chenkins Nov 12, 2026
2ffa188
feat(railway): end the current scenario or the whole Experiment from …
chenkins Nov 12, 2026
9a68f92
fix(railway): show the consent question in the language of its buttons
chenkins Nov 12, 2026
339c2db
docs(plans): record the commits of S24 to S27 and refresh the introdu…
chenkins Nov 12, 2026
915b0dd
docs(plans): plan the code review's findings and the user's notes as …
chenkins Nov 12, 2026
ba509c7
docs(plans): move the Railway plan onto the plan template
chenkins Nov 12, 2026
21f157c
docs(plans): name the Railway plan's IDs by kind with a dash and mark…
chenkins Nov 12, 2026
13d7d67
feat(railway): clear the previous scenario's cards when the next one …
chenkins Nov 13, 2026
13df4fb
feat(railway): show each train's origin and destination in the train …
chenkins Nov 13, 2026
c67f8a1
feat(railway): write each train's name on its symbol and point it in …
chenkins Nov 13, 2026
f0254a8
docs(plans): record the commits of S-31, S-40, S-42 and S-43 and the …
chenkins Nov 13, 2026
856b266
docs(plans): refresh the Railway shots that show the map or the feed
chenkins Nov 13, 2026
82ddd62
docs(plans): plan Railway's code in grid and experiment layers (DP-16…
chenkins Nov 13, 2026
5f5bc59
feat(railway): show a decision's recommendations as soon as its card …
chenkins Nov 17, 2026
2baaa90
docs(plans): record the commit of S-32 and the fix of F-23
chenkins Nov 17, 2026
cbded69
docs(plans): record F-27 to F-35, decide Q-33 and plan S-46 to S-54
chenkins Nov 19, 2026
5bc05b7
fix(railway): give every run's events their own ids
chenkins Nov 19, 2026
ce61dcc
fix(railway): mark only the trains held by an event or decision as di…
chenkins Nov 19, 2026
08ac741
fix(railway): send events and contexts outside the session lock
chenkins Nov 19, 2026
145ead0
fix(railway): show the geographic map whichever tab was open before
chenkins Nov 19, 2026
4668f74
fix(railway): show only this login's session in the progress bar
chenkins Nov 19, 2026
8c1cf16
fix(railway): keep the start dialog when a single run fails to start
chenkins Nov 19, 2026
4e05ff9
fix(railway): ignore recommendations that arrive for another card
chenkins Nov 19, 2026
55dcaf4
feat(railway): compute the options' KPIs from the simulation
chenkins Nov 19, 2026
361f8eb
feat(railway): draw each train in its own cell on a grid, in its tabl…
chenkins Nov 19, 2026
b6b6d96
feat(railway): say that the simulation is paused in the decision line
chenkins Nov 19, 2026
6966180
feat(railway): mark the cards that open a decision in the feed
chenkins Nov 19, 2026
3f1e638
feat(railway): show each train's cell and heading in the train table
chenkins Nov 19, 2026
7af1888
feat(railway): show each train's standstill so far in the train table
chenkins Nov 19, 2026
681bb63
docs(plans): record the commits of S-28 to S-30, S-33 to S-37, S-46 t…
chenkins Nov 19, 2026
ea25cc3
feat(railway): do not ask to close the cards after a decision in the …
chenkins Nov 19, 2026
303d211
feat(railway): end an event's card when its disruption ends
chenkins Nov 19, 2026
dab304f
docs(plans): plan the end of events (F-36, S-55) and record the commi…
chenkins Nov 19, 2026
ce8bedb
docs(plans): describe the computed KPIs in REQ-18 and the limitations
chenkins Nov 19, 2026
f85c9f8
docs(plans): retake the Railway shots that show the map, the feed or …
chenkins Nov 19, 2026
01629ed
docs(plans): record the resolved F-5 thread and today's test counts
chenkins Nov 19, 2026
f61821f
docs(plans): record the new walk-through of all 15 Cypress tests
chenkins Nov 21, 2026
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
4 changes: 3 additions & 1 deletion .github/workflows/docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
# VITE_* values are baked into the bundle at build time. VITE_POWERGRID_SIMU
# is the same-origin base the frontend posts "apply action" to; without it the
# POST lands on / and nginx answers 405. Blank lines are ignored by the action.
# POST lands on / and nginx answers 405. VITE_RAILWAY_SIMU is the Railway
# simulator's (/railway-simu/, RAILWAY_SIMU_UPSTREAM). Blank lines are ignored by the action.
# Secrets must NOT be passed here: a build-arg ends up readable in the public
# bundle. The cognitive API token is a runtime env var on the container instead
# (COGNITIVE_TOKEN, injected into the nginx proxy by start-webui.sh).
build-args: |
${{ matrix.service == 'cab-standalone-frontend' && 'VITE_POWERGRID_SIMU=/powergrid-simu' || '' }}
${{ matrix.service == 'cab-standalone-frontend' && 'VITE_RAILWAY_SIMU=/railway-simu' || '' }}
cache-from: type=gha
cache-to: type=gha,mode=max
77 changes: 77 additions & 0 deletions .github/workflows/railway-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Railway CI

# The Railway use case: the scripted simulator's tests and the services' Railway tests (schemas,
# RailwayManager). The Railway frontend tests run in Frontend CI (Vitest); the Cypress spec needs
# the dev stack and is run by hand (usecases_examples/Railway/README.md, "Screenshots and video").

on:
push:
branches:
- main
paths:
- 'usecases_examples/Railway/**'
- 'backend/*/resources/Railway/**'
- 'backend/*/tests/test_railway*.py'
- '.github/workflows/railway-ci.yml'
pull_request:
branches:
- main
paths:
- 'usecases_examples/Railway/**'
- 'backend/*/resources/Railway/**'
- 'backend/*/tests/test_railway*.py'
- '.github/workflows/railway-ci.yml'
workflow_dispatch:

jobs:
simulator:
runs-on: ubuntu-latest
defaults:
run:
working-directory: usecases_examples/Railway
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: pip
cache-dependency-path: usecases_examples/Railway/requirements.txt

- name: Install dependencies
run: pip install -r requirements.txt

# test_sim.py, test_integration.py, and test_recommendations.py, which fails while
# recommendations.json or the Recommendation Service's copy differs from the scenario files
- name: Run tests
run: python -m pytest -q

services:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: pip
cache-dependency-path: usecases_examples/Railway/devstack/requirements.txt

# What the services import on the Railway path (without the Recommendation Service's
# PowerGrid dependencies), as the dev stack installs it
- name: Install dependencies
run: |
pip install -r usecases_examples/Railway/devstack/requirements.txt
pip install pytest pytest-mock

- name: Run the Railway tests of each service
env:
PYTHONPATH: ${{ github.workspace }}/backend/cab_common
run: |
for service in event-service context-service recommendation-service; do
(cd "backend/$service" && python -m pytest -q tests/test_railway*.py) || exit 1
done
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,9 @@ go.sh
hmisurveys/


tmp
/docs/plans/railway-use-case/handover/

tmp

# local caches (Railway dev stack: venv, SQLite files, logs)
/.cache/
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
# Changelog


## Unreleased

### Added

- Railway: the Event and Context services accept the fields of the scripted Railway simulator (scenario, decision, run mode and session in events; session, scenario state, track network, history and decisions in contexts). All are optional, so existing Railway publishers keep working.
- Railway: the page is in German when the browser is set to German, including the platform texts it shows; English and French stay as before.
- Railway simulator: plays the six scripted scenarios on the platform. It sends its events and contexts through the Event and Context services, pauses at each decision until the operator's choice arrives, and is started, moved on and stopped through `/railway-simu/` (an Experiment of six runs, or a single run).
- Railway: "Get recommendation" on a decision card of the simulator shows the scenario's options with their KPIs, or the Ko-Lernen choices of train and action. Other Railway events still get the recommendation catalog.
- Railway: for the simulator's contexts the centre panel shows the "Kartenansicht": the scenario's track network, its stations and the trains with their direction, held trains in red. Contexts without a track network keep the geographic map.
- Railway: a "ZWL Diagramm" tab shows each train's distance along the scenario's line against the step, the planned paths dashed and the current step as a line.
- Railway: a "Linienansicht" tab shows the scenario's line straight, in three rows (the main line and the side tracks above and below it), with its stations and trains.
- Railway: a status line above the drawing shows the step and, while a decision is open, "Simulation pausiert – Entscheidung erforderlich, bitte Ereigniskarte öffnen" with the held trains highlighted; a train table lists planned and actual departures and arrivals, delays and states.
- Railway: the operator applies a simulator recommendation from the assistant ("Lösung anwenden"); in Ko-Lernen they pick a train, then an action (actions not offered are greyed out, infeasible ones say why), and propose it. The choice goes to the simulator through the frontend's new `/railway-simu/` nginx proxy (`RAILWAY_SIMU_UPSTREAM`, default `http://host.docker.internal:5124/`), which resumes the run. Catalog recommendations are still applied through `/transport_plan`.
- Railway: when the simulator is reachable, a start dialog over the page starts the Experiment (six runs, each with its introduction and "Weiter") or a single run, and ends with "Experiment abgeschlossen" and a hint to log out; a bar above the timeline shows "Experiment i/6 · scenario — mode · Schritt N" and "✕ Beenden". Without the simulator the page stays as before.
- Railway: "Karte ansehen" in the start dialog's "Standalone-Modus" section shows the geographic map for an external simulation (events and trains with GPS positions), as the page was before the start dialog; "▶ Szenario-Loader" in the bar above the timeline goes back.
- Railway: in the Experiment, the bar above the timeline offers "Szenario beenden", which ends the current scenario early and shows the next introduction, and "✕ Experiment beenden" (formerly "✕ Beenden"); a single run keeps "✕ Beenden". The simulator's new `POST /api/v1/session/end-run` does the ending.
- Survey: after logging out of Railway, the post-logout survey asks the experiment's reflection questions, in German (`CHAINS.Railway`).
- Railway simulator: a `Dockerfile` and its own `docker-compose.yml` run it next to the platform, always on and idle until a participant starts the Experiment; the frontend image is built with `VITE_RAILWAY_SIMU=/railway-simu`. The users service loads the `cabProcess` perimeter of the Dispatcher, Planner and Supervisor groups from its config, so `railway_user` gets its cards on a fresh database without `loadTestConf.sh`.
- Railway: the feed shows only the running scenario's cards, so each scenario of the Experiment starts with an empty feed; cards of other publishers stay. The timeline still lists the earlier runs' cards.
- Railway: the train table shows where each train comes from and goes to ("Von", "Nach").
- Railway: in the Kartenansicht each train fills its cell, with the bounds of a station's box, with its name on it and a "▶" pointing the way it runs; the tag above the train is gone. A light grid shows the cells' boundaries.
- Railway: opening a decision card of the simulator shows its options (Empfehlungsmodus) or the train choice (Ko-Lernen) at once, without "Empfehlung anfordern"; other cards still open on the event view with the button.
- Railway: the feed marks the cards that open a decision, "⚠ Entscheidung" while it is open and "✓ Entschieden" once it is taken.
- Railway: in the simulator's runs the feed no longer asks "Event ended, would you like to close the corresponding notifications?" after a decision; the geographic map keeps the question.
- Railway: the train table shows each train's cell and heading ("7, 9 → Ost") and its standstill so far ("Stillstand", steps stood still on the grid).
- Railway simulator: an event that holds a train is sent again when its hold runs out, with its end and criticality `ND`: its card turns grey and the Timeline shows its end.
- Railway simulator: the options' KPIs are computed from the simulation (`compute_kpis.py`): the delay summed and per train and the energy (train steps on the grid); they replace the hand-written "Lokale Verspätung", "Gesamtverspätung", "Energie" and "Anschlüsse".

### Fixed

- Login: in a German browser on the Railway page, the consent question for cognitive data was in English under German buttons; the question now follows the page's language, as the buttons do.

## 1.5.2 (2026-11-05)

### Added
Expand Down
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ It is a prototype of a bi-directional virtual assistant, open in terms of indust

As it is designed, the platform is generic, it can be used for different use cases. As an example, the use case of managing **power line** overloads at **PowerGrid** (Réseau de Transport d'Electricité français) is provided. To install and run the PowerGrid simulator, please refer to the detailed guide available in the file PowerGrid simulator's [README](/usecases_examples/PowerGrid/README.md). This guide provides specific instructions for setting up and running the PowerGrid use case.

A second example is the **Railway** dispatcher experiment: six scripted Flatland scenarios, played by a simulator next to the platform, in which a participant resolves dispatching conflicts with the platform's recommendations ("Empfehlungsmodus") or by choosing a train and an action ("Ko-Lernen"). Its simulator, dev stack and deployment are described in the Railway [README](/usecases_examples/Railway/README.md).

The platform uses the project **OperatorFabric** for notification management.


Expand Down Expand Up @@ -83,12 +85,16 @@ Key variables (see `.secrets.example` for all options and per-environment values

- `VITE_POWERGRID_SIMU` — the frontend's simulator endpoint. Use the same-origin proxy
value `/powergrid-simu` (avoids CORS); set it to `false` to disable the PowerGrid UI.
`VITE_RAILWAY_SIMU` / `VITE_ATM_SIMU` are the equivalents for the other use cases.
`VITE_RAILWAY_SIMU` / `VITE_ATM_SIMU` are the equivalents for the other use cases; the
Railway simulator's proxy value is `/railway-simu`.
- `POWERGRID_SIMU_UPSTREAM` — where nginx actually forwards `/powergrid-simu/`:
- Local dev : `http://host.docker.internal:5122/` (simulator container on the host)
- LAN : `http://192.168.208.61:5100/`
- Public/k8s: same variable, set as an env var on the **frontend pod** (see
`deploy-chart/values.ovh.yaml`).
- `RAILWAY_SIMU_UPSTREAM` — where nginx forwards `/railway-simu/`, the Railway simulator
(default `http://host.docker.internal:5124/`, the simulator's own compose on the same host; see
[the Railway README](/usecases_examples/Railway/README.md#3-deployment)).
- `COGNITIVE_TOKEN` — bearer token for the INESCTEC cognitive API. nginx attaches it to
every `/cognitive-api/` request, so the frontend never sees it. It used to be
`VITE_COGNITIVE_TOKEN`, a build-time value inlined into the public JS bundle; that meant
Expand All @@ -110,7 +116,7 @@ Key variables (see `.secrets.example` for all options and per-environment values
>
### How runtime nginx configuration works

`POWERGRID_SIMU_UPSTREAM` and `COGNITIVE_TOKEN` are **runtime** values, not
`POWERGRID_SIMU_UPSTREAM`, `RAILWAY_SIMU_UPSTREAM` and `COGNITIVE_TOKEN` are **runtime** values, not
build-time ones. They appear in the nginx config as `__NAME__` placeholders, and
`frontend/start-webui.sh` substitutes them from the matching env var when the container
starts. Changing one is: update the env var (or the k8s secret) and restart the
Expand Down Expand Up @@ -245,6 +251,9 @@ containers via `host.docker.internal`:
* PowerGrid simulator (provided example): 5122
* PowerGrid expert agent API: 5123

The Railway simulator runs the same way, in its own compose on the host:
* Railway simulator: 5124

### Authentication data

For a development environment, the system uses predefined initial data for Keycloak setup.
Expand All @@ -257,6 +266,9 @@ Some examples of credentials:
| `admin` | `test` |
| `powergrid_user` | `test` |
| `railway_user` | `test` |

`railway_user` is also the one login of the Railway experiment's participants: each login's trace
session id identifies the participant's session (see the Railway [README](/usecases_examples/Railway/README.md#3-deployment)).
| `atm_user` | `test` |


Expand Down
8 changes: 8 additions & 0 deletions backend/context-service/resources/Railway/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ class MetadataSchemaRailway(MetadataSchema):
list_of_target = Dict(required=False)
direction_agents = List(Integer(), required=False)
position_agents = Dict(required=False)
# Sent by the scripted Railway simulator (usecases_examples/Railway/): the Experiment, the
# running scenario, the static track network, the train history for the ZWL diagram and the
# applied decisions. Optional, so contexts with the fields above stay valid.
session = Dict(required=False, allow_none=True)
scenario = Dict(required=False, allow_none=True)
infra = Dict(required=False, allow_none=True)
history = List(Dict(), required=False, allow_none=True)
decisions = List(Dict(), required=False, allow_none=True)
86 changes: 86 additions & 0 deletions backend/context-service/tests/test_railway.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
"""Railway contexts: the snapshot of the scripted simulator (usecases_examples/Railway/) and
today's GPS contexts are both accepted; unknown fields are still rejected."""

import pytest

from api.models import UseCaseModel, db
from api.utils import load_usecases_db

HEADERS = {"Authorization": "Bearer railway-test-token"}

TODAY_CONTEXT = {
"use_case": "Railway",
"date": "2026-11-20T09:00:00+00:00",
"data": {"trains": [{"id_train": "AB001", "nb_passengers_onboard": 468,
"latitude": 46.58, "longitude": 0.33, "failure": True}]},
}

SIMULATOR_CONTEXT = {
"use_case": "Railway",
"date": "2026-11-20T09:00:16+00:00",
"data": {
"trains": [{"id_train": "Train_0", "name": "G 3", "position": [7, 9], "direction": 1,
"done": False, "failure": False, "planned_departure": 1,
"planned_arrival": 40, "actual_departure": 1, "actual_arrival": None,
"delay": 0, "route": [[7, 2], [7, 3]]}],
"session": {"session_id": "4f1c",
"scenario_order": [{"scenario_id": "scenario3", "mode": "colearning"}],
"scenario_position": 0,
"started_at": "2026-11-20T08:59:00+00:00", "ended_at": None},
"scenario": {"id": "scenario3", "name": "Szenario 3 — Güterverkehr vs Personenverkehr",
"mode": "colearning", "step": 16, "state": "paused_for_decision",
"decision_open": True},
"infra": {"map": "maps/map3.json", "rows": 15, "cols": 20, "grid": [[0, 0]],
"stations": [{"id": 1, "r": 7, "c": 17, "name": "Station 1"}],
"marey_link": {"start": [7, 1], "end": [7, 18]},
"marey_mapping": {"7,2": 1, "7,3": 2},
"planned_paths": {"Train_0": [[1, 1], [3, 2]]},
"link_map": {"grid": [[1025]], "mapping": [[[7, 2], [1, 1]]], "levels": []}},
"history": [{"0": {"position": [7, 2], "direction": 1, "moving": True,
"target": [7, 17], "done": False}}],
"decisions": [],
},
}


@pytest.fixture
def railway_auth_mocker(mocker):
mocker.patch(
"cab_common_auth.decorators.keycloak.introspect",
return_value={"active": True, "preferred_username": "publisher_test",
"username": "publisher_test", "entitiesId": "Railway"},
)


@pytest.fixture
def railway_use_case(client):
with client.application.app_context():
from flask import current_app

db.session.add(UseCaseModel(name="Railway", context_manager_class="RailwayContextManager",
metadata_schema_class="MetadataSchemaRailway"))
db.session.commit()
load_usecases_db(current_app.use_case_factory)


def post(client, payload):
return client.post("/api/v1/contexts", headers=HEADERS, json=payload)


@pytest.mark.usefixtures("railway_use_case", "railway_auth_mocker")
class TestRailwayContexts:
def test_today_payload_still_accepted(self, client):
assert post(client, TODAY_CONTEXT).status_code == 201

def test_simulator_payload_accepted_and_returned(self, client):
assert post(client, SIMULATOR_CONTEXT).status_code == 201
response = client.get("/api/v1/contexts?use_case=Railway", headers=HEADERS)
assert response.status_code == 200
data = response.json[0]["data"]
assert data["scenario"]["state"] == "paused_for_decision"
assert data["infra"]["marey_mapping"] == {"7,2": 1, "7,3": 2}
assert data["session"]["scenario_order"][0] == {"scenario_id": "scenario3", "mode": "colearning"}

def test_unknown_field_still_rejected(self, client):
payload = {**SIMULATOR_CONTEXT, "data": {**SIMULATOR_CONTEXT["data"], "render": "x.png"}}
assert post(client, payload).status_code == 422
10 changes: 10 additions & 0 deletions backend/event-service/resources/Railway/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,13 @@ class MetadataSchemaRailway(MetadataSchema):
longitude = Float(allow_none=True, default=None)
latitude = Float(allow_none=True, default=None)
simulation_name = String(allow_none=True, default=None)
# Sent by the scripted Railway simulator (usecases_examples/Railway/); optional, so
# publishers of the fields above stay valid. scenario_id, decision_index and run_mode are
# the key of the recommendations RailwayManager returns; session_id is the Experiment's id.
scenario_id = String(required=False, allow_none=True)
timestep = Integer(required=False, allow_none=True)
decision_index = Integer(required=False, allow_none=True)
session_id = String(required=False, allow_none=True)
run_mode = String(
required=False, allow_none=True, validate=OneOf(["recommendation", "colearning"])
)
Loading