File indexing completed on 2026-12-02 10:28:07
0001 """
0002 Utilities for scout jobs
0003 """
0004
0005
0006 def get_num_scout_chunks_for_dataset(remaining_chunks: int, remaining_datasets: int) -> int:
0007 """
0008 Get the number of scout chunks to allocate to a master input dataset, so that the scout chunks
0009 of a task are spread over its master input datasets instead of being consumed by the first ones.
0010 When there are as many master input datasets as scout chunks or more, the first datasets get one
0011 chunk each and the rest get none. Otherwise, the chunks are distributed almost evenly. The caller
0012 subtracts the chunks actually consumed, so chunks left unused by a small dataset go to the following ones.
0013
0014 :param remaining_chunks: The number of scout chunks not yet consumed by the preceding datasets.
0015 :param remaining_datasets: The number of master input datasets still to be fed, including this one.
0016
0017 :return: The number of scout chunks for the dataset.
0018 """
0019 if remaining_chunks <= 0:
0020 return 0
0021 if remaining_datasets <= 1:
0022 return remaining_chunks
0023
0024 return -(-remaining_chunks // remaining_datasets)