Skip to content

Commit 39487e7

Browse files
committed
Enable parallel processing for key rules
Add global thread configuration (4 threads)
1 parent b2e2170 commit 39487e7

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

Snakefile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ YEARS = ORTHOMOSAICS.year
1919
site_year_combos = {*zip(SITES, YEARS)}
2020
SITES_SY, YEARS_SY = list(zip(*site_year_combos))
2121

22+
threads = 4
23+
2224
def flights_in_year_site(wildcards):
2325
basepath = f"{working_dir}/predictions"
2426
flights_in_year_site = []
@@ -49,32 +51,35 @@ rule project_mosaics:
4951
output:
5052
projected=f"{working_dir}/projected_mosaics/{{year}}/{{site}}/{{flight}}_projected.tif",
5153
webmercator=f"{working_dir}/projected_mosaics/webmercator/{{year}}/{{site}}/{{flight}}_projected.tif"
54+
threads: threads
5255
conda:
5356
"everwatch"
5457
shell:
55-
"python project_orthos.py {input.orthomosaic}"
58+
"python project_orthos.py {input.orthomosaic} --threads {threads}"
5659

5760
rule predict_birds:
5861
input:
5962
projected=f"{working_dir}/projected_mosaics/{{year}}/{{site}}/{{flight}}_projected.tif"
6063
output:
6164
f"{working_dir}/predictions/{{year}}/{{site}}/{{flight}}_projected.shp"
65+
threads: threads
6266
conda:
6367
"everwatch"
6468
resources:
6569
gpu=1
6670
shell:
67-
"python predict.py {input.projected}"
71+
"python predict.py {input.projected} --threads {threads}"
6872

6973
rule combine_birds_site_year:
7074
input:
7175
flights_in_year_site
7276
output:
7377
f"{working_dir}/predictions/{{year}}/{{site}}/{{site}}_{{year}}_combined.shp"
78+
threads: threads
7479
conda:
7580
"everwatch"
7681
shell:
77-
"python combine_birds_site_year.py {input}"
82+
"python combine_birds_site_year.py {input} --threads {threads}"
7883

7984
rule combine_predicted_birds:
8085
input:
@@ -92,20 +97,22 @@ rule detect_nests:
9297
f"{working_dir}/predictions/{{year}}/{{site}}/{{site}}_{{year}}_combined.shp"
9398
output:
9499
f"{working_dir}/detected_nests/{{year}}/{{site}}/{{site}}_{{year}}_detected_nests.shp"
100+
threads: threads
95101
conda:
96102
"everwatch"
97103
shell:
98-
"python nest_detection.py {input}"
104+
"python nest_detection.py {input} --threads {threads}"
99105

100106
rule process_nests:
101107
input:
102108
f"{working_dir}/detected_nests/{{year}}/{{site}}/{{site}}_{{year}}_detected_nests.shp"
103109
output:
104110
f"{working_dir}/processed_nests/{{year}}/{{site}}/{{site}}_{{year}}_processed_nests.shp"
111+
threads: threads
105112
conda:
106113
"everwatch"
107114
shell:
108-
"python process_nests.py {input}"
115+
"python process_nests.py {input} --threads {threads}"
109116

110117
rule combine_nests:
111118
input:

0 commit comments

Comments
 (0)