workflow-manager.app.api.scanhub_requests#

Handler for exam requests.

This module defines functions to interact with the exam manager service, including fetching tasks, sequences, and results. It provides a way to create and update acquisition tasks and results, ensuring that the data is properly formatted and authenticated.

Copyright (C) 2023, BRAIN-LINK UG (haftungsbeschränkt). All Rights Reserved. SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-ScanHub-Commercial

Attributes#

Functions#

get_task(...)

Fetch acquisition task by ID from the exam manager service.

set_task(...)

Update an acquisition task on the task service with the provided payload.

create_blank_result(→ scanhub_libraries.models.ResultOut)

Create a blank result in the exam manager service.

set_result(→ scanhub_libraries.models.ResultOut)

Update a result in the exam manager service.

get_result(→ scanhub_libraries.models.ResultOut)

Fetch a result by ID from the exam manager service.

delete_result(→ None)

Fetch a result by ID from the exam manager service.

get_exam_id(→ str)

Fetch acquisition task by ID from the exam manager service.

Module Contents#

workflow-manager.app.api.scanhub_requests.TASK_URI = 'http://exam-manager:8000/api/v1/exam/task'#
workflow-manager.app.api.scanhub_requests.RESULT_URI = 'http://exam-manager:8000/api/v1/exam/result'#
workflow-manager.app.api.scanhub_requests.WORKFLOW_URI = 'http://exam-manager:8000/api/v1/exam'#
workflow-manager.app.api.scanhub_requests.get_task(task_id: str | uuid.UUID, user_access_token: str) scanhub_libraries.models.AcquisitionTaskOut | scanhub_libraries.models.DAGTaskOut#

Fetch acquisition task by ID from the exam manager service.

Args#

task_id (str | UUID): The unique identifier of the task to retrieve. user_access_token (str): The user’s access token for authentication.

Returns#

AcquisitionTaskOut | None: The acquisition task object if found and valid.

Raises#

HTTPException: If the task is not found (404) or is not an acquisition task (400).

workflow-manager.app.api.scanhub_requests.set_task(task_id: str | uuid.UUID, payload: scanhub_libraries.models.AcquisitionTaskOut | scanhub_libraries.models.DAGTaskOut, user_access_token: str) scanhub_libraries.models.AcquisitionTaskOut | scanhub_libraries.models.DAGTaskOut#

Update an acquisition task on the task service with the provided payload.

Parameters#

task_idstr | UUID

The unique identifier of the task to update.

payloadAcquisitionTaskOut

The updated task data to send to the task service.

user_access_tokenstr

The access token used for authorization with the task service.

Returns#

AcquisitionTaskOut

The updated task object returned from the task service.

Raises#

HTTPException

If the task update fails (e.g. non-200 response from the task service).

workflow-manager.app.api.scanhub_requests.create_blank_result(task_id: str, user_access_token: str) scanhub_libraries.models.ResultOut#

Create a blank result in the exam manager service.

Returns#

ResultOut: The created blank result object.

Raises#

HTTPException: If the result creation fails (status code not 201).

workflow-manager.app.api.scanhub_requests.set_result(result_id: str | uuid.UUID, payload: scanhub_libraries.models.SetResult | scanhub_libraries.models.ResultOut, user_access_token: str) scanhub_libraries.models.ResultOut#

Update a result in the exam manager service.

Args#

result_id (str): The unique identifier of the result to update. payload (SetResult): The data to update the result with. user_access_token (str): The user’s access token for authentication.

Returns#

ResultOut: The updated result object.

Raises#

HTTPException: If the result update fails (status code not 200).

workflow-manager.app.api.scanhub_requests.get_result(result_id: str | uuid.UUID, user_access_token: str) scanhub_libraries.models.ResultOut#

Fetch a result by ID from the exam manager service.

Args#

result_id (str): The unique identifier of the result to retrieve. user_access_token (str): The user’s access token for authentication.

Returns#

ResultOut: The result object if found.

Raises#

HTTPException: If the result is not found (404).

workflow-manager.app.api.scanhub_requests.delete_result(result_id: str | uuid.UUID, user_access_token: str) None#

Fetch a result by ID from the exam manager service.

Args#

result_id (str): The unique identifier of the result to retrieve. user_access_token (str): The user’s access token for authentication.

Returns#

ResultOut: The result object if found.

Raises#

HTTPException: If the result is not found (404).

workflow-manager.app.api.scanhub_requests.get_exam_id(workflow_id: str, user_access_token: str) str#

Fetch acquisition task by ID from the exam manager service.

Args#

task_id (str): The unique identifier of the task to retrieve. user_access_token (str): The user’s access token for authentication.

Returns#

AcquisitionTaskOut | None: The acquisition task object if found and valid.

Raises#

HTTPException: If the task is not found (404) or is not an acquisition task (400).