(samples_cloud: SamplesCloud)
| 45 | |
| 46 | |
| 47 | async def get_from_samples_cloud(samples_cloud: SamplesCloud) -> np.ndarray: |
| 48 | blob_client = get_blob( |
| 49 | samples_cloud.account_name, |
| 50 | samples_cloud.container_name, |
| 51 | samples_cloud.file_path, |
| 52 | samples_cloud.sas_token, |
| 53 | ) |
| 54 | |
| 55 | if samples_cloud.byte_length: |
| 56 | download_stream = await asyncio.to_thread( |
| 57 | blob_client.download_blob, |
| 58 | samples_cloud.byte_offset, |
| 59 | samples_cloud.byte_length, |
| 60 | ) |
| 61 | else: |
| 62 | # TODO: This is timing out, we need to find an asychronus way of |
| 63 | # processing the file without blocking a successful response |
| 64 | download_stream = await asyncio.to_thread(blob_client.download_blob) |
| 65 | |
| 66 | buffer = np.frombuffer( |
| 67 | io.BytesIO(download_stream.readall()).read(), |
| 68 | dtype=data_mapping[samples_cloud.data_type], |
| 69 | ) |
| 70 | buffer = get_float32_buffer(buffer) |
| 71 | |
| 72 | return buffer.view(dtype=np.complex64) |
| 73 | |
| 74 | |
| 75 | def get_float32_buffer(buffer: np.ndarray): |
no test coverage detected