results
get_results(simulation_id, token, db=Depends(get_db_session))
async
¶
Retrieve the results of a simulation based on the given simulation id. This endpoint checks the current status of the simulation and provides appropriate responses based on that status. If the simulation is finished, the results are returned. If the status indicates in-progress, failed, or canceled, it responds with corresponding error messages. Errors are also returned if the simulation does not exist or if the request is unauthenticated.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation_id
|
int
|
The unique identifier of the simulation. |
required |
token
|
Annotated[str, Depends(oauth2_scheme)]
|
The OAuth2 token for authentication. |
required |
db
|
Session
|
Database session dependency, used to query the database. |
Depends(get_db_session)
|
Returns:
Type | Description |
---|---|
ResultResponse | ErrorResponse
|
A ResultResponse object containing simulation results if successful, or an ErrorResponse object containing error details if an error occurs. |
Raises:
Type | Description |
---|---|
HTTPException
|
If the request is unauthenticated. |
HTTPException
|
If the simulation does not exist. |
HTTPException
|
If the simulation status is unknown. |
Source code in backend/app/results/router.py
get_results_from_dump(simulation_id, db)
¶
Fetches results from a simulation dump file based on the simulation ID. This function retrieves the energy system data from a serialized dump file stored in the local directory based on a simulation token. It processes the dump files, restores the energy system, and aggregates result sequences for each identified energy bus into structured data. The results are returned in the form of a ResultDataModel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
simulation_id
|
int
|
ID of the simulation for which results are being fetched |
required |
db
|
Session
|
Database session used to query the simulation information |
required |
Returns:
Type | Description |
---|---|
ResultDataModel
|
A ResultDataModel containing the result data extracted from the dump and the total count of data entries |
Raises:
Type | Description |
---|---|
HTTPException
|
Raised with status code 404 if the simulation ID does not exist or if the required dump file is not found |