Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I. #1260 avoid adding duplicate kernel task. #1358

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/natcap/invest/pollination.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ def execute(args):
pollinator_abundance_task_map = {}
floral_resources_index_path_map = {}
floral_resources_index_task_map = {}
alpha_kernel_map = {}
for species in scenario_variables['species_list']:
# calculate foraging_effectiveness[species]
# FE(x, s) = sum_j [RA(l(x), j) * fa(s, j)]
Expand Down Expand Up @@ -762,11 +763,17 @@ def execute(args):
intermediate_output_dir, _KERNEL_FILE_PATTERN % (
alpha, file_suffix))

alpha_kernel_raster_task = task_graph.add_task(
task_name=f'decay_kernel_raster_{alpha}',
func=utils.exponential_decay_kernel_raster,
args=(alpha, kernel_path),
target_path_list=[kernel_path])
# to avoid creating duplicate kernel rasters check to see if an
# adequate kernel task has already been submitted
try:
alpha_kernel_raster_task = alpha_kernel_map[kernel_path]
except:
alpha_kernel_raster_task = task_graph.add_task(
task_name=f'decay_kernel_raster_{alpha}',
func=utils.exponential_decay_kernel_raster,
args=(alpha, kernel_path),
target_path_list=[kernel_path])
alpha_kernel_map[kernel_path] = alpha_kernel_raster_task

# convolve FE with alpha_s
floral_resources_index_path = os.path.join(
Expand Down
Loading