|
19 | 19 | from rasterio.warp import Resampling |
20 | 20 |
|
21 | 21 | from hybig.browse import ( |
| 22 | + MAX_WARP_THREADS, |
22 | 23 | convert_multiband_to_raster, |
23 | 24 | convert_singleband_to_raster, |
24 | 25 | create_browse, |
|
31 | 32 | reprojected_output_is_empty, |
32 | 33 | validate_file_crs, |
33 | 34 | validate_file_type, |
| 35 | + warp_thread_count, |
34 | 36 | write_georaster_as_browse, |
35 | 37 | ) |
36 | 38 | from hybig.color_utility import ( |
@@ -241,6 +243,8 @@ def test_create_browse_imagery_with_mocks(self, rasterio_open_mock, reproject_mo |
241 | 243 | self.assertEqual(actual_call.kwargs['dst_crs'], CRS.from_string('EPSG:4326')) |
242 | 244 | self.assertEqual(actual_call.kwargs['dst_nodata'], 0) # TRANSPARENT |
243 | 245 | self.assertEqual(actual_call.kwargs['resampling'], Resampling.nearest) |
| 246 | + # Reprojection runs multithreaded to speed up large jobs. |
| 247 | + self.assertEqual(actual_call.kwargs['num_threads'], warp_thread_count()) |
244 | 248 |
|
245 | 249 | self.assertEqual( |
246 | 250 | (self.tmp_dir / 'input_file_path.jpg').resolve(), actual_image.resolve() |
@@ -442,6 +446,12 @@ def test_process_tile_returns_false_for_all_nan_window(self, rasterio_open_mock) |
442 | 446 | f'Skipping all-NaN tile: {self.tmp_dir / "output.png"}' |
443 | 447 | ) |
444 | 448 |
|
| 449 | + def test_warp_thread_count_is_bounded(self): |
| 450 | + """Thread count is between 1 and MAX_WARP_THREADS.""" |
| 451 | + count = warp_thread_count() |
| 452 | + self.assertGreaterEqual(count, 1) |
| 453 | + self.assertLessEqual(count, MAX_WARP_THREADS) |
| 454 | + |
445 | 455 | def test_reprojected_output_is_empty(self): |
446 | 456 | """Test reprojected_output_is_empty across output types.""" |
447 | 457 | # Paletted single-band: every cell holds the fill index -> empty. |
|
0 commit comments