Skip to content

Add support for A3S in Interactive AI - #27

Open
emuskardin wants to merge 9 commits into
ainetus:mainfrom
emuskardin:RL-2628-update-interactiveAI-to-support-A3S
Open

emuskardin wants to merge 9 commits into
ainetus:mainfrom
emuskardin:RL-2628-update-interactiveAI-to-support-A3S

Conversation

@emuskardin

Copy link
Copy Markdown

Local setup script + A3S support for PowerGrid recommendations

Adds a local setup script that does all setup processes in one go (for the local/single PC use). Added support for A3S in InteractiveAI, that is recommendations and KPI projections can now be received from an A3S service.
It is a separate standalone docker service, that can be installed from <ULR will be provided shortly, once we make a public repo>.

1. InteractiveAI setup: fixes and small features

  • local_setup.sh / local_stop.sh: one command brings everything up: backend, Keycloak config, OperatorFabric resources, rebuilding frontend and recommendation service from source, the simulator, and an end-to-end check. --clean and --wipe reset containers or volumes.
  • README: minimal mention of A3S and local_setup
  • nginx: the cognitive API host is now looked up on each request, so an unreachable host no longer stops the frontend from starting. clien64m.
  • Recommendation service: if the agent is down or returns an error, the service now answers 502 (UpstreamAgentError) instead of an empty 200. The agent timeout can be set with RL_AGENT_API_TIMEOUT (default 120s, was 30s).
  • Logging: disable_existing_loggers: False, so services keep the loggers they already set up.
  • Tests: smoke test for the path from a posted context to a recommendation.
  • Simulator Dockerfile: removed the unused ffmpeg/libsm6/libxext6 apt install.

2. A3S support

  • Simulator publishes an optional environment_state with each context: the environment's seed, scenario and library versions, plus a gzippn. A3S uses it to rebuild the exact environment. It can be turned off and has a size limit (serialize_env_state, max_state_mb).
  • Context and recommendation schemas accept environment_state, options (kpi_prediction_steps), branch_index and step.
  • Frontend asks for 6 steps of KPI projection. The recommendation cards show only step 1. A new KPI projection chart plots the projected ever the next steps.
  • local_setup.sh --a3s [URL] points the stack at an A3S that is already running, without editing .secrets.

The expert agent still works as before. None of the A3S fields are required.

Changed files with minimal description of what changed:

  • .gitignore - ignore .secrets.pre-simplify
  • README.md - note on local_setup.sh and A3S
  • local_setup.sh - NEW one-shot local setup (--clean / --wipe / --a3s)
  • local_stop.sh - NEW teardown (--wipe / --pause)
  • backend/
    • cab_common/cab_common_auth/settings.py - keep existing loggers
    • context-service/resources/PowerGrid/schemas.py - optional environment_state
    • recommendation-service/
      • api/exceptions.py - NEW UpstreamAgentError (502)
      • api/schemas.py - options, branch_index, step
      • resources/PowerGrid/manager.py - configurable timeout, errors raised instead of swallowed
      • settings.py - keep existing loggers
      • tests/test_smoke_pipeline.py - NEW pipeline smoke test
  • config/dev/
    • cab-standalone/
      • .secrets.example - note about --a3s
      • docker-compose.sh - RL_AGENT_API_URL from the env overrides .secrets
      • docker-compose.yml - RL_AGENT_API_TIMEOUT
      • nginx-cors-permissive.conf - cognitive host looked up per request, 64m body
      • nginx-kubernetes.conf - 64m body
      • nginx.conf - 64m body
    • recommendation-service/nginx.conf - 64m body
  • frontend/
    • default.conf - 64m body
    • src/api/services.ts - options type
    • src/stores/services.ts - sends kpi_prediction_steps: 6
    • src/types/services.ts - branch_index / step / done / env_timestep
    • src/entities/PowerGrid/
      • types.ts - environment_state type
      • locales/{en,fr}.json - projection strings
      • CAB/Assistant.vue - cards show step 1 only, adds projection chart
      • CAB/KpiProjectionChart.vue - NEW projection chart and table
      • CAB/kpiProjection.ts - NEW groups steps by candidate
  • usecases_examples/PowerGrid/
    • Dockerfile.app - dropped unused apt packages
    • app/models/Communicate.py - attaches environment_state to the context
    • app/models/Simulator.py - records actions for replay
    • app/models/env_serialization.py - NEW replay recorder and environment_state builder
    • config/API_POWERGRID_CAB.toml - serialize_env_state, max_state_mb
    • tests/test_env_serialization.py - NEW serialization tests

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant