Services API

API reference for sim2l services.

sim2l.services

Sim2l microservices.

Standalone services that can be run independently: - cache_service: Distributed cache with session-based auth - catalog_service: Master registry for simulations - auth_service: Authentication and session management

cache_service

Standalone cache service for distributed caching.

Provides REST API for cache operations with session-based authentication. Supports both SQLite (default) and PostgreSQL backends.

sim2l.services.cache_service.adapt_postgres_schema_for_sqlite(schema_sql: str) str[source]

Convert a PostgreSQL schema SQL to SQLite-compatible SQL.

Handles type substitutions and strips PostgreSQL-specific constructs (functions, views, custom operators) that SQLite doesn’t support.

class sim2l.services.cache_service.CacheServiceBackend[source]

Bases: object

Abstract backend for cache service.

get(cache_key: str, session_id: str)[source]
set(data: dict, session_id: str)[source]
invalidate(filters: dict, session_id: str)[source]
delete(cache_key: str, session_id: str)[source]
get_stats(simulation_id: int | None)[source]
health_check()[source]
class sim2l.services.cache_service.SQLiteCacheBackend(db_path: str)[source]

Bases: CacheServiceBackend

SQLite backend for cache service.

Uses a per-thread connection pool (threading.local) so that concurrent Flask requests each get their own SQLite connection, avoiding ‘OperationalError: database is locked’ errors under load. WAL journal mode is enabled for better read concurrency.

__init__(db_path: str)[source]
get(cache_key: str, session_id: str)[source]
set(data: dict, session_id: str)[source]
invalidate(filters: dict, session_id: str)[source]
delete(cache_key: str, session_id: str)[source]
get_stats(simulation_id: int | None)[source]
health_check()[source]
list_entries(limit=25, offset=0, simulation_id=None, simulation_name=None, status=None, session_id=None)[source]

List cache entries with pagination and filters.

class sim2l.services.cache_service.PostgreSQLCacheBackend(connection_string: str, no_auth: bool = False)[source]

Bases: CacheServiceBackend

PostgreSQL backend for cache service.

Uses a per-thread connection pool (threading.local) for thread safety under concurrent Flask requests.

__init__(connection_string: str, no_auth: bool = False)[source]
get(cache_key: str, session_id: str)[source]
set(data: dict, session_id: str)[source]
invalidate(filters: dict, session_id: str)[source]
delete(cache_key: str, session_id: str)[source]
get_stats(simulation_id: int | None)[source]
health_check()[source]
list_entries(limit=25, offset=0, simulation_id=None, simulation_name=None, status=None, session_id=None)[source]

List cache entries with pagination and filters.

sim2l.services.cache_service.health()[source]
sim2l.services.cache_service.get_cache(cache_key)[source]
sim2l.services.cache_service.delete_cache(cache_key)[source]
sim2l.services.cache_service.set_cache()[source]
sim2l.services.cache_service.invalidate_cache()[source]
sim2l.services.cache_service.get_stats()[source]
sim2l.services.cache_service.list_cache_entries()[source]

List all cache entries with pagination and filters.

sim2l.services.cache_service.main()[source]

catalog_service

Standalone catalog service for simulation registry.

Provides REST API for tool discovery, registration, and statistics with session-based authentication. Supports both SQLite and PostgreSQL.

class sim2l.services.catalog_service.CatalogServiceBackend[source]

Bases: object

Abstract backend for catalog service.

search(query, tags, status, limit)[source]
get_simulation(name, version)[source]
register_simulation(data, session_id)[source]
update_simulation(simulation_id, updates, session_id)[source]
delete_simulation(simulation_id, session_id)[source]
record_execution(data)[source]
get_stats(simulation_id)[source]
sync_pending_requests(installation_id)[source]
approve_sync(request_id, session_id)[source]
get_overview_stats()[source]
health_check()[source]
class sim2l.services.catalog_service.SQLiteCatalogBackend(db_path: str)[source]

Bases: CatalogServiceBackend

SQLite backend for catalog service.

Uses a per-thread connection pool (threading.local) so that concurrent Flask requests each get their own SQLite connection, avoiding ‘OperationalError: database is locked’ errors under load. WAL journal mode is enabled for better read concurrency.

__init__(db_path: str)[source]
search(query, tags, status, limit)[source]
get_simulation(name, version)[source]
register_simulation(data, session_id)[source]
update_simulation(simulation_id, updates, session_id)[source]
delete_simulation(simulation_id, session_id)[source]
record_execution(data)[source]
get_stats(simulation_id)[source]
sync_pending_requests(installation_id)[source]
approve_sync(request_id, session_id)[source]
get_overview_stats()[source]

Get overview statistics for dashboard.

health_check()[source]
class sim2l.services.catalog_service.PostgreSQLCatalogBackend(connection_string: str)[source]

Bases: CatalogServiceBackend

PostgreSQL backend for catalog service.

Uses a per-thread connection pool (threading.local) for thread safety under concurrent Flask requests.

__init__(connection_string: str)[source]
search(query, tags, status, limit)[source]
get_simulation(name, version)[source]
register_simulation(data, session_id)[source]
update_simulation(simulation_id, updates, session_id)[source]
delete_simulation(simulation_id, session_id)[source]
record_execution(data)[source]
get_stats(simulation_id)[source]
sync_pending_requests(installation_id)[source]
approve_sync(request_id, session_id)[source]
get_overview_stats()[source]
health_check()[source]
sim2l.services.catalog_service.health()[source]
sim2l.services.catalog_service.search_simulations()[source]
sim2l.services.catalog_service.get_simulation(name)[source]
sim2l.services.catalog_service.register_simulation()[source]
sim2l.services.catalog_service.update_simulation(simulation_id)[source]
sim2l.services.catalog_service.delete_simulation(simulation_id)[source]
sim2l.services.catalog_service.record_execution()[source]
sim2l.services.catalog_service.run_simulation()[source]

Run a simulation and return the execution results.

sim2l.services.catalog_service.get_stats(simulation_id)[source]
sim2l.services.catalog_service.get_pending_sync()[source]
sim2l.services.catalog_service.approve_sync(request_id)[source]
sim2l.services.catalog_service.get_overview_stats()[source]

Get overview statistics for the dashboard.

sim2l.services.catalog_service.main()[source]

results_service