smartem_backend.api_server#

Members

acknowledge_instruction

HTTP endpoint for instruction acknowledgements with database persistence

agent_heartbeat

Agent heartbeat endpoint to update connection health status.

check_database_health

Check database connectivity and basic functionality

check_rabbitmq_health

Check RabbitMQ connectivity

close_managed_session

Close a session using the connection manager

create_acquisition

Create a new acquisition

create_acquisition_grid

Create a new grid for a specific acquisition

create_atlas_tile_for_atlas

Create a new tile for a specific atlas

create_foilhole_micrograph

Create a new micrograph for a specific foil hole

create_grid_atlas

Create a new atlas for a grid

create_grid_gridsquare

Create a new grid square for a specific grid

create_gridsquare_foilhole

Create a new foil hole for a specific grid square

create_managed_session

Create a session using the connection manager

create_prediction_model

create_quality_prediction

create_test_instruction

Debug endpoint to create test instructions

create_test_session

Debug endpoint to create test sessions

delete_acquisition

Delete an acquisition

delete_atlas

Delete an atlas by publishing to RabbitMQ

delete_atlas_tile

Delete an atlas tile by publishing to RabbitMQ

delete_foilhole

Delete a foil hole by publishing to RabbitMQ

delete_grid

Delete a grid by publishing to RabbitMQ

delete_gridsquare

Delete a grid square by publishing to RabbitMQ

delete_micrograph

Delete a micrograph by publishing to RabbitMQ

delete_prediction_model

get_acquisition

Get a single acquisition by ID

get_acquisition_grids

Get all grids for a specific acquisition

get_acquisitions

Get all acquisitions

get_active_connections

Debug endpoint to view active agent connections

get_active_sessions

Debug endpoint to view all active sessions

get_atlas

Get a single atlas by ID

get_atlas_tile

Get a single atlas tile by ID

get_atlas_tiles

Get all atlas tiles

get_atlas_tiles_by_atlas

Get all tiles for a specific atlas

get_atlases

Get all atlases

get_connection_stats

Get real-time connection and session statistics

get_db

get_foilhole

Get a single foil hole by ID

get_foilhole_micrographs

Get all micrographs for a specific foil hole

get_foilhole_quality_prediction_time_series_for_gridsquare

Get time ordered predictions for all models that provide them for this square

get_foilhole_quality_prediction_time_series_for_gridsquare_for_metric

Get time ordered predictions for all models that provide them for this square

get_foilholes

Get all foil holes

get_grid

Get a single grid by ID

get_grid_atlas

Get the atlas for a specific grid

get_grid_atlas_image

Get a single grid by ID

get_grid_gridsquares

Get all grid squares for a specific grid

get_grid_latent_representation

get_grid_predictions

get_grids

Get all grids

get_gridsquare

Get a single grid square by ID

get_gridsquare_foilhole_quality_predictions

get_gridsquare_foilholes

Get all foil holes for a specific grid square

get_gridsquare_image

Get a single grid square by ID

get_gridsquare_quality_prediction_time_series

Get time ordered predictions for all models that provide them for this square

get_gridsquare_quality_predictions

get_gridsquares

Get all grid squares

get_health

Health check endpoint with actual connectivity checks

get_latent_rep

get_micrograph

Get a single micrograph by ID

get_micrographs

Get all micrographs

get_model_weights_for_grid

Get time series of model weights for grid

get_overall_prediction_for_gridsquare

get_prediction_for_grid

get_prediction_for_gridsquare

get_prediction_model

get_prediction_models

get_quality_metrics

get_session_instructions

Debug endpoint to view instructions for a session

get_square_latent_rep

get_status

Get API status and configuration information

get_suggested_square_collections

grid_registered

All squares on a grid have been registered at low mag

gridsquare_registered

All holes on a grid square have been registered at square mag

lifespan

Manage application lifespan events.

link_atlas_tile_to_gridsquare

Connect a grid square to a tile with its position information

link_atlas_tile_to_gridsquares

Connect mutliple grid squares to a tile with its position information

log_requests

stream_instructions

SSE endpoint for streaming instructions to agents for a specific session

update_acquisition

Update an acquisition

update_atlas

Update an atlas

update_atlas_tile

Update an atlas tile

update_foilhole

Update a foil hole

update_grid

Update a grid

update_gridsquare

Update a grid square

update_micrograph

Update a micrograph

update_prediction_model

smartem_backend.api_server.lifespan(app: FastAPI)[source]#

Manage application lifespan events.

smartem_backend.api_server.check_database_health()[source]#

Check database connectivity and basic functionality

smartem_backend.api_server.check_rabbitmq_health()[source]#

Check RabbitMQ connectivity

smartem_backend.api_server.get_status()[source]#

Get API status and configuration information

smartem_backend.api_server.get_health()[source]#

Health check endpoint with actual connectivity checks

smartem_backend.api_server.get_acquisitions(db: Session = Depends(get_db))[source]#

Get all acquisitions

smartem_backend.api_server.create_acquisition(acquisition: AcquisitionCreateRequest, db: Session = Depends(get_db))[source]#

Create a new acquisition

smartem_backend.api_server.get_acquisition(acquisition_uuid: str, db: Session = Depends(get_db))[source]#

Get a single acquisition by ID

smartem_backend.api_server.update_acquisition(acquisition_uuid: str, acquisition: AcquisitionUpdateRequest, db: Session = Depends(get_db))[source]#

Update an acquisition

smartem_backend.api_server.delete_acquisition(acquisition_uuid: str, db: Session = Depends(get_db))[source]#

Delete an acquisition

smartem_backend.api_server.get_grids(db: Session = Depends(get_db))[source]#

Get all grids

smartem_backend.api_server.get_grid(grid_uuid: str, db: Session = Depends(get_db))[source]#

Get a single grid by ID

smartem_backend.api_server.update_grid(grid_uuid: str, grid: GridUpdateRequest, db: Session = Depends(get_db))[source]#

Update a grid

smartem_backend.api_server.delete_grid(grid_uuid: str, db: Session = Depends(get_db))[source]#

Delete a grid by publishing to RabbitMQ

smartem_backend.api_server.get_acquisition_grids(acquisition_uuid: str, db: Session = Depends(get_db))[source]#

Get all grids for a specific acquisition

smartem_backend.api_server.create_acquisition_grid(acquisition_uuid: str, grid: GridCreateRequest, db: Session = Depends(get_db))[source]#

Create a new grid for a specific acquisition

smartem_backend.api_server.grid_registered(grid_uuid: str) bool[source]#

All squares on a grid have been registered at low mag

smartem_backend.api_server.get_atlases(db: Session = Depends(get_db))[source]#

Get all atlases

smartem_backend.api_server.get_atlas(atlas_uuid: str, db: Session = Depends(get_db))[source]#

Get a single atlas by ID

smartem_backend.api_server.update_atlas(atlas_uuid: str, atlas: AtlasUpdateRequest, db: Session = Depends(get_db))[source]#

Update an atlas

smartem_backend.api_server.delete_atlas(atlas_uuid: str, db: Session = Depends(get_db))[source]#

Delete an atlas by publishing to RabbitMQ

smartem_backend.api_server.get_grid_atlas(grid_uuid: str, db: Session = Depends(get_db))[source]#

Get the atlas for a specific grid

smartem_backend.api_server.create_grid_atlas(grid_uuid: str, atlas: AtlasCreateRequest, db: Session = Depends(get_db))[source]#

Create a new atlas for a grid

smartem_backend.api_server.get_atlas_tiles(db: Session = Depends(get_db))[source]#

Get all atlas tiles

smartem_backend.api_server.get_atlas_tile(tile_uuid: str, db: Session = Depends(get_db))[source]#

Get a single atlas tile by ID

smartem_backend.api_server.update_atlas_tile(tile_uuid: str, tile: AtlasTileUpdateRequest, db: Session = Depends(get_db))[source]#

Update an atlas tile

smartem_backend.api_server.delete_atlas_tile(tile_uuid: str, db: Session = Depends(get_db))[source]#

Delete an atlas tile by publishing to RabbitMQ

smartem_backend.api_server.get_atlas_tiles_by_atlas(atlas_uuid: str, db: Session = Depends(get_db))[source]#

Get all tiles for a specific atlas

smartem_backend.api_server.create_atlas_tile_for_atlas(atlas_uuid: str, tile: AtlasTileCreateRequest, db: Session = Depends(get_db))[source]#

Create a new tile for a specific atlas

Connect a grid square to a tile with its position information

Connect mutliple grid squares to a tile with its position information

smartem_backend.api_server.get_gridsquares(db: Session = Depends(get_db))[source]#

Get all grid squares

smartem_backend.api_server.get_gridsquare(gridsquare_uuid: str, db: Session = Depends(get_db))[source]#

Get a single grid square by ID

smartem_backend.api_server.update_gridsquare(gridsquare_uuid: str, gridsquare: GridSquareUpdateRequest, db: Session = Depends(get_db))[source]#

Update a grid square

smartem_backend.api_server.delete_gridsquare(gridsquare_uuid: str, db: Session = Depends(get_db))[source]#

Delete a grid square by publishing to RabbitMQ

smartem_backend.api_server.get_grid_gridsquares(grid_uuid: str, db: Session = Depends(get_db))[source]#

Get all grid squares for a specific grid

smartem_backend.api_server.create_grid_gridsquare(grid_uuid: str, gridsquare: GridSquareCreateRequest, db: Session = Depends(get_db))[source]#

Create a new grid square for a specific grid

smartem_backend.api_server.gridsquare_registered(gridsquare_uuid: str, count: int | None = None, db: Session = Depends(get_db)) bool[source]#

All holes on a grid square have been registered at square mag

smartem_backend.api_server.get_foilholes(db: Session = Depends(get_db))[source]#

Get all foil holes

smartem_backend.api_server.get_foilhole(foilhole_uuid: str, db: Session = Depends(get_db))[source]#

Get a single foil hole by ID

smartem_backend.api_server.update_foilhole(foilhole_uuid: str, foilhole: FoilHoleUpdateRequest, db: Session = Depends(get_db))[source]#

Update a foil hole

smartem_backend.api_server.delete_foilhole(foilhole_uuid: str, db: Session = Depends(get_db))[source]#

Delete a foil hole by publishing to RabbitMQ

smartem_backend.api_server.get_gridsquare_foilholes(gridsquare_uuid: str, on_square_only: bool = False, db: Session = Depends(get_db))[source]#

Get all foil holes for a specific grid square

smartem_backend.api_server.create_gridsquare_foilhole(gridsquare_uuid: str, foilholes: list[FoilHoleCreateRequest], db: Session = Depends(get_db))[source]#

Create a new foil hole for a specific grid square

smartem_backend.api_server.get_micrographs(db: Session = Depends(get_db))[source]#

Get all micrographs

smartem_backend.api_server.get_micrograph(micrograph_uuid: str, db: Session = Depends(get_db))[source]#

Get a single micrograph by ID

smartem_backend.api_server.update_micrograph(micrograph_uuid: str, micrograph: MicrographUpdateRequest, db: Session = Depends(get_db))[source]#

Update a micrograph

smartem_backend.api_server.delete_micrograph(micrograph_uuid: str, db: Session = Depends(get_db))[source]#

Delete a micrograph by publishing to RabbitMQ

smartem_backend.api_server.get_foilhole_micrographs(foilhole_uuid: str, db: Session = Depends(get_db))[source]#

Get all micrographs for a specific foil hole

smartem_backend.api_server.create_foilhole_micrograph(foilhole_uuid: str, micrograph: MicrographCreateRequest, db: Session = Depends(get_db))[source]#

Create a new micrograph for a specific foil hole

async smartem_backend.api_server.stream_instructions(agent_id: str, session_id: str, db: Session = Depends(get_db)) EventSourceResponse[source]#

SSE endpoint for streaming instructions to agents for a specific session

async smartem_backend.api_server.acknowledge_instruction(agent_id: str, session_id: str, instruction_id: str, acknowledgement: AgentInstructionAcknowledgement, db: Session = Depends(get_db)) AgentInstructionAcknowledgementResponse[source]#

HTTP endpoint for instruction acknowledgements with database persistence

async smartem_backend.api_server.agent_heartbeat(agent_id: str, session_id: str, db: Session = Depends(get_db))[source]#

Agent heartbeat endpoint to update connection health status.

Parameters:
  • agent_id – The agent identifier

  • session_id – The session identifier

  • db – Database session

Returns:

Heartbeat response with status and timestamp

async smartem_backend.api_server.get_active_connections(db: Session = Depends(get_db))[source]#

Debug endpoint to view active agent connections

async smartem_backend.api_server.get_session_instructions(session_id: str, db: Session = Depends(get_db))[source]#

Debug endpoint to view instructions for a session

async smartem_backend.api_server.get_active_sessions(db: Session = Depends(get_db))[source]#

Debug endpoint to view all active sessions

async smartem_backend.api_server.get_connection_stats()[source]#

Get real-time connection and session statistics

async smartem_backend.api_server.create_managed_session(session_data: dict)[source]#

Create a session using the connection manager

async smartem_backend.api_server.close_managed_session(session_id: str)[source]#

Close a session using the connection manager

async smartem_backend.api_server.create_test_instruction(session_id: str, instruction_data: dict, db: Session = Depends(get_db))[source]#

Debug endpoint to create test instructions

async smartem_backend.api_server.create_test_session(session_data: dict, db: Session = Depends(get_db))[source]#

Debug endpoint to create test sessions

smartem_backend.api_server.get_model_weights_for_grid(grid_uuid: str, db: Session = Depends(get_db))[source]#

Get time series of model weights for grid

smartem_backend.api_server.get_gridsquare_quality_prediction_time_series(gridsquare_uuid: str, db: Session = Depends(get_db))[source]#

Get time ordered predictions for all models that provide them for this square

smartem_backend.api_server.get_foilhole_quality_prediction_time_series_for_gridsquare(gridsquare_uuid: str, db: Session = Depends(get_db))[source]#

Get time ordered predictions for all models that provide them for this square

smartem_backend.api_server.get_foilhole_quality_prediction_time_series_for_gridsquare_for_metric(metric_name: str, gridsquare_uuid: str, db: Session = Depends(get_db))[source]#

Get time ordered predictions for all models that provide them for this square

smartem_backend.api_server.get_grid_atlas_image(grid_uuid: str, x: int | None = None, y: int | None = None, w: int | None = None, h: int | None = None, db: Session = Depends(get_db))[source]#

Get a single grid by ID

smartem_backend.api_server.get_gridsquare_image(gridsquare_uuid: str, db: Session = Depends(get_db))[source]#

Get a single grid square by ID