def disable(task_key: str) -> None: """Disable existing Task.""" with db_transaction_session(): disabling_query = Task.query.filter(Task.key == task_key) updated = disabling_query.update({'disabled': True}, synchronize_session='fetch') if not updated: raise InternalErrorException(f'Task "{task_key}" was not disabled due to unknown database error.')
def enable(key: str) -> None: """Enable existing Dataset.""" enabling_query = Dataset.query.filter(Dataset.key == key) updated = enabling_query.update({'disabled': False}, synchronize_session='fetch') if not updated: raise InternalErrorException( f'Dataset "{key}" was not enabled due to unknown database error.')
def enable(label_tag_key: str) -> None: """Enable existing Label Tag.""" enabling_query = LabelTag.query.filter(LabelTag.key == label_tag_key) updated = enabling_query.update({'disabled': False}, synchronize_session='fetch') if not updated: raise InternalErrorException( f'Label Tag "{label_tag_key}" was not enabled due to unknown database error.' )
def handle_raw_string(value: Any) -> Any: """Parse raw string values of Enum and return list of values.""" if not value: return [] inner = re.match(r"^{(.*)}$", value) if not inner: raise InternalErrorException( 'Enum values did not match the pattern!') return inner.group(1).split(",")
def add_new_slice(scan_id: ScanID, image: bytes) -> Slice: """Add new Slice for given Scan. :param scan_id: ID of a Scan for which it should add new slice :param image: bytes representing DICOM image :return: Slice object """ scan = ScansRepository.get_scan_by_id(scan_id) _slice = scan.add_slice() try: SlicesRepository.store_original_image(_slice.id, image) except WriteTimeout: SlicesRepository.delete_slice(_slice) raise InternalErrorException('Timeout during saving original image to the Storage.') parse_dicom_and_update_slice.delay(_slice.id) return _slice